Remote control car not working!

Thread Starter

corefinder

Joined Oct 6, 2011
55
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.

Code:
Rich (BB code):
sbit up at P1_0_bit;
sbit down at P1_1_bit;
sbit left at P1_2_bit;
sbit right at P1_3_bit;
sbit led1 at P3_4_bit;
sbit led2 at P3_5_bit;
sbit IN1 at P2_0_bit;
sbit IN2 at P2_1_bit;
sbit IN3 at P2_2_bit;
sbit IN4 at P2_3_bit;
void main() 
{
P1=0xff;
P2=0x00;
while(1)
{
led1=0;
led2=0;
IN1=0;
IN2=0;
IN3=0;
IN4=0;
 while(up==0)
   {
   led1=1;
   IN1=1;
   IN2=0;
   IN3=1;
   IN4=0;
   }
 while(down==0)
   {
   led1=1;
   IN1=0;
   IN2=1;
   IN3=0;
   IN4=1;
   }
 while(left==0)
   {
   led2=1;
   IN1=0;
   IN2=1;
   IN3=1;
   IN4=0;
   }
 while(right==0)
   {
   led2=1;
   IN1=1;
   IN2=0;
   IN3=0;
   IN4=1;
   }
   }
}
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.
 

ScottWang

Joined Aug 23, 2012
7,397
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.
 

Thread Starter

corefinder

Joined Oct 6, 2011
55
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.
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.
 

ScottWang

Joined Aug 23, 2012
7,397
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.
 

tshuck

Joined Oct 18, 2012
3,534
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?
 

TANDBERGEREN

Joined Jan 20, 2014
90
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?
 

Thread Starter

corefinder

Joined Oct 6, 2011
55
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.
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!
 

Thread Starter

corefinder

Joined Oct 6, 2011
55
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?
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.
 

ScottWang

Joined Aug 23, 2012
7,397
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:

tshuck

Joined Oct 18, 2012
3,534
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.
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
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.
How about when you connect it without a load?
 
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.
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)
 
Top