Maker Pro
Maker Pro

DC motor speed control using 8051 and l298

Hi Everyone out there!
I am new to microcontrollers. I am using AT89C55WD to control H-Bridge (L298) which in turn drives the DC motor.
Circuits for AT89C55WD and L298 work separately very well but hen I give inputs to L298 from microcontroller I don't get the desired behavior.
What is the problem with this and what is the solution...If any one can assist!
 

KrisBlueNZ

Sadly passed away in 2015
There are some obvious problems with your circuit diagram.
1. The two capacitors from the crystal to ground are shown as 1uF but they should be in the picofarad range, typically around 22-33 pF each depending on the specifications of the crystal.
2. The way you've drawn a battery connecting to the two switches is very suspicious. These switches should be connected to the VCC rail for the whole circuit, which also needs to connect to the microcontroller.
3. The microcontroller's RESET input (pin 9) probably needs to be connected to something.

Beyond that, you need to provide MUCH more information than just that the microcontroller and motor driver circuits "work well separately" (what do you mean, and how have you tested them?) and "I don't get the desired behaviour" - a full description of the problem, along with measurements and tests you've done so far, is a minimum. A firmware listing may also be needed.
 
2. The way you've drawn a battery connecting to the two switches is very suspicious. These switches should be connected to the VCC rail for the whole circuit, which also needs to connect to the microcontroller.

In addition to that, just pull those pins low with a pull down resistor and use a spst switch to drive them high when needed... Or reverse that logic and pull them high and switch to low, doing this can take advantage of the internal pull ups of the mircro...

I also assume you have enabled the internal pull ups on port 3?

I also suggest a three pin resonator over the crystal to simplify it...

And last but not least, hook an LED up to an unused port and blink it so that you know the chip is actually alive... Even better hook two up and put one in the begging of the code, blink a few times and proceed so that you can see if the chip is actually firing up, second put one in your main loop so you know that the chip is in that loop... Poor mans debugging since you have so many unused ports you can switch on and off multiple LEDs at different stages of the code......
 
In proteus there are not much issues the circuit is working accurately.
On breadboard I have used the right capacitors and have made the right connections for reset pin etc.
When I observe the out put of micro controller i.e. P1.2, P1.3 and P1.4 through which I am controlling L298, I get the the desired output on oscilloscope. But logic does not work as desired when I connect these pins to L298 through which I am driving the dc motor.
I assume there are issues in interfacing 8051 with L298...
 
Should I use optocupler or op-amp as buffer to interface 8051 with L298? But AT89C55WD datasheet says Port 1 can source sink eight TTLs...
How to enable internal pullups on 8051 ports?
 
In proteus there are not much issues the circuit is working accurately.

Simulations are fine and give you a good idea of what will happen, but that doesn't mean it will work the same in the real world...

Lack of pull ups and pull down are things that work just fine in simulations (as they assume too much) but in the real world things can float or do whacky things...

I assume there are issues in interfacing 8051 with L298...

Shouldn't be, but you also have not posted the whole schematic, where are the three lines from the micro going and is the rest of the L298 hooked up with it's support components and stuff?

How to enable internal pullups on 8051 ports?

Not an AVR guy, but it should be a setting in the script/fuses for those ports... It might be automatic in some compilers when you turn them to input, might not... Thus personally many times I just use external resistors just to be sure...
 

KrisBlueNZ

Sadly passed away in 2015
I agree with CocaCola's comments.
Regarding port pullups, IIRC the standard 8051 port architecture (this is an 8051 device not an AVR) have pullups by default if the output is driven high. Driving a port pin low forces it low with a hard pull-down, and means it will always read low; driving it high enables a pullup and it can then be used for input.
The obvious issue now is a schematic of the L298 motor driver circuit.
You've said that it works OK as a separate circuit. What tests have you done to determine this?
There should be no need to opto-isolate the microcontroller from the motor driver.
Next step is to post the motor driver schematic and explain what testing you have done with it.
 
This is how I am using L298 to drive DC motor.
I am very thankful to all you guys for showing interest in solving my problem.
 

Attachments

  • Motor_Control.jpg
    Motor_Control.jpg
    76.5 KB · Views: 3,458
Top