Remote control car not working!

Discussion in 'The Projects Forum' started by corefinder, Feb 16, 2014.

  1. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    Hello, I made a rc car with at89s52 micro controller and l293d motor driver. I am using two 12 v geared dc motor. Here is the schematic of my connection and C code for its working.
    [​IMG]
    Code:
    Code ( (Unknown Language)):
    1.  
    2. sbit up at P1_0_bit;
    3. sbit down at P1_1_bit;
    4. sbit left at P1_2_bit;
    5. sbit right at P1_3_bit;
    6. sbit led1 at P3_4_bit;
    7. sbit led2 at P3_5_bit;
    8. sbit IN1 at P2_0_bit;
    9. sbit IN2 at P2_1_bit;
    10. sbit IN3 at P2_2_bit;
    11. sbit IN4 at P2_3_bit;
    12. void main()
    13. {
    14. P1=0xff;
    15. P2=0x00;
    16. while(1)
    17. {
    18. led1=0;
    19. led2=0;
    20. IN1=0;
    21. IN2=0;
    22. IN3=0;
    23. IN4=0;
    24.  while(up==0)
    25.    {
    26.    led1=1;
    27.    IN1=1;
    28.    IN2=0;
    29.    IN3=1;
    30.    IN4=0;
    31.    }
    32.  while(down==0)
    33.    {
    34.    led1=1;
    35.    IN1=0;
    36.    IN2=1;
    37.    IN3=0;
    38.    IN4=1;
    39.    }
    40.  while(left==0)
    41.    {
    42.    led2=1;
    43.    IN1=0;
    44.    IN2=1;
    45.    IN3=1;
    46.    IN4=0;
    47.    }
    48.  while(right==0)
    49.    {
    50.    led2=1;
    51.    IN1=1;
    52.    IN2=0;
    53.    IN3=0;
    54.    IN4=1;
    55.    }
    56.    }
    57. }
    Problem:
    When I press any button it starts motor but after sometime motor stops and led remains glowing and when I press any button nothing works but led remain glowing.So I reset micro controller and then its starts working again but then again same problem arises. So I have to reset controller again and again. Please tell me why its happening like that and how to correct it.
     
  2. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. -- AT89S52 datasheet page 4 port 1.
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,398
    497
    L293D missing ground, maybe.
     
  4. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    yeh, but that should not be a problem..I guess.
    Also I checked the output voltage of 7805 its about 3 volt and sometime its 4v but its never been 5 volt. Also when I changed power source,i.e., when I used output of transformer it didn't work at all. Earlier when I was using battery motor atleast worked for 10-20 second. I am really frustrated :confused:
    I am using push button b/w pin and ground. Could it be that too much current is drawn from uc as button is pressed and uc hangs and stop working.
     
  5. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    If the hardware not on the right voltage level, and the software not follow the rule, it could cause the system unstable, and then not easy to find out the real problem.

    1. Write 1 to port 1.0~1.7 before you want to use it as input.
    2. I can't find the status of reset signal when the power up, what is the reset pin?.
    3. /EA should connecting to +5V.
    4. If the 7805 can't providing a stable voltage around 4V~6V for AT89C51, it could be a problem, post the detail of 7805 circuit, including the current, transformer, and the current of the other device.
    5. The LEDs connected to P3.4 and P3.5, they need a limiting resistor.

    TA = 21°C to 27°C, VCC = 5.0 ± 10%,Vcc=4.5V~5.5V
    TA = -40°C to 85°C, VCC = 5.0 V ± 20% (unless otherwise noted),Vcc=4V~6V.
     
  6. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    What is your power supply? Battery? What are its characteristics? It seems like your supply can't keep up with your current demand.

    You may want to add external pullup resistors for your buttons. How far away from the car are these buttons?
     
  7. TANDBERGEREN

    Member

    Jan 20, 2014
    74
    4
    The 7805 needs probably to be a very low drop type.
    It is essentiaslly that the 5V is kept stable, or you will suffer instability for your uP.

    What is the other powersupply voltages?
     
  8. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    1. Yes I have written 1 on port 1 nothing works. I checked with multimeter the pins were getting low so I guess uc not working.
    2. I connected reset pin although not shown in pic. I connected it to ground.
    3. EA pin is at 5v although not shown in picture.
    4. 7805 working strange. When I connect it to 12 volt battery its output is around 3 volts but or less than it. I also have another power supply which takes power from main and convert to dc voltage and with it I am getting around 4 volts.
    5. I have connected limiting resistor although not shown in picture..sorry.
    Yes you may be thinking 7805 output is very low but when the power source is battery it uc works fine but for few time but after that the same problem comes as I mentioned earlier. It seems like uc hangs and dont respond to push buttons anymore.Strange!
     
  9. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    Its kind of strange as when I apply 12 volt to 7805 when its open circuits it gives around 5 volts but in circuit it shows voltage below it 3-4 volts.
     
  10. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    How is the reset pin when power up?
    uC need a reset signal from low to high and back to low to initial the original setup for the system when the power up.

    Reset input - A high on this pin for two machine cycles while the oscillator is running resets the device.

    You had missing so much labels on the circuit, have you adding the diodes to protecting the L293 for the back-emf of the motor?
     
    Last edited: Feb 18, 2014
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Reset pins are typically active-low (low to perform the function). If the reset is, indeed, active-low, it's no wonder why it doesn't work, it should be pulled high
    How about when you connect it without a load?
     
  12. TANDBERGEREN

    Member

    Jan 20, 2014
    74
    4
    Do you have any idea of the current running?
    A 7805 should cope with a full amp without any problem.

    BUT: Don't forget to decouple the powerlines. As close to the 7805 as possible.
    Well suitable is a couple of 100nF filmcapasitors. One at the input, and one at the output. This will take care of most presumeable oscillations wich in their self may make trouble for 7805 under even relatively light loads.

    An easy way to identify the problem is to put a 0.1 Ohm resistor in series with the input of the 7805. You should not meassure more than 0.15V over that one.
    (Equals 1.5A current)
     
Loading...