PWM Motor Driver (H Bridge) Object from OBEX
JeremyJ
Posts: 30
Hello all,
I just soldered up an eval board with a L298 full bridge driver and I found this software in the Propeller OBEX:
http://obex.parallax.com/objects/455/
I loaded in onto my Propeller and I see that the pwm object initiates signals to drive one of the two bridges on the L298. I checked the signal output on an O-scope and it looks good. I looked at the code a little and it wasn't apparent to me how you would get the object to work with a two phase, bipolar motor, which is what I'd like to drive.
Has anyone worked with this object before or something similar? The switching of the "Enable" pin for the two phases has to be 180 degrees out of phase for it to work.
Thanks
I just soldered up an eval board with a L298 full bridge driver and I found this software in the Propeller OBEX:
http://obex.parallax.com/objects/455/
I loaded in onto my Propeller and I see that the pwm object initiates signals to drive one of the two bridges on the L298. I checked the signal output on an O-scope and it looks good. I looked at the code a little and it wasn't apparent to me how you would get the object to work with a two phase, bipolar motor, which is what I'd like to drive.
Has anyone worked with this object before or something similar? The switching of the "Enable" pin for the two phases has to be 180 degrees out of phase for it to work.
Thanks
Comments
2-phase bipolar motor sounds like a stepper-motor which were driven completely different than dc-motors.
Can you post a schematic of the motor?
best regards
Stefan
Besides possible objects in the OBEX, you might want to check out JonnyMac's Spin Zone article about driving a stepper motor with a Prop. It's the last article listed #136.
StefanL38 - I'm not sure why you think that the L298 can't drive a bipolar stepper. Can you explain? The IC should be able to drive one small (up to 2A per bridge, per spec) DC motor per bridge or a single bipolar, 2 phase stepper (I'm sure you could wire up a unipolar stepper also, but I'd have to think about the wiring a little on that one...)
idBruce - the L297 is shown as a possible application on the spec sheet, but I don't see why it can't be driven directly from the Propeller with the referenced object. The signals look good....I just need a Phase B that sends a Enable signal out of phase with Phase A.
So what I'm thinking you need to do to drive this motor using said pwm object is to get EnableA and EnableB shifted...so the sequence is something like this.
1: EnA - high | EnB - low
2: EnA - low | EnB - high
3: EnA - high | EnB - low
4: EnA - low | EnB - high
.....etc
I'd be happy to get the referenced object to give me that output for the enable pins. The direction of revolution is controlled by the Input 1,2,3,4 pins. 1 and 3 high with 2 and 4 low with be one direction and the opposite will correspond to the reverse direction. You can follow the logic of the IC's internal bridge schematic on the first page of the IC specification - http://www.sparkfun.com/datasheets/Components/General/L298N.pdf
OK....I will mention as a caveat that I have some doubt as to the stepping required by this motor, since it is of the permanent magnet type and not the variable relucance type (for which current direction in the coil is inconsequential). I'm not sure if it is:
Option 1:
Phase A pulse
Phase B pulse
Phase A pulse
Phase B pulse
or
Option 2:
Phase A Pos pulse (current sent in positive direction through coil)
Phase B Pos pulse (current sent in positive direction through coil)
Phase A Neg pulse (current sent in negative direction through coil)
Phase B Neg pulse (current sent in negative direction through coil)
Phase A Pos pulse....etc.
I have no experience with steppers, and know they are designed differently from standard PM and SR motors that are used for motion rather than precision stepping.
So then what are the two sense resistors and Vsense outputs doing on the L298? My understanding per the spec is that they are controlling the chopping to do exactly what you say....to limit the current to 2A, and you can as mentioned adjust the duty cycle further (once Vsense exceeds some value, your IC knows to limit duty cycle based on current consideration vs input into the Enable pins).
I didn't hook these up, as I didn't see them critical to basic (rough or "jerky") operation.
Oh wow....it just dawned on me that you are right. Sometimes you look at these things and look at these things and just don't get it....of course you need to connect these outputs to another chip...nothing is reading them!
Regardless, my setup should work just fine without the L297, since I am limiting current on the power supply. Thoughts?
Won't work why?
You're the one that said the L298 was dumb, right? How does it know if I have a 0.05Ohm wire path to ground or a short ground path with the 0.5Ohm resistor. The useful information in this scenario is being transmitted by the inputs (Vsenses) into the L298, as you mention. This is just going to be I(phase) x R(sense) <= 2V (at which point the L298 will being its current-limiting, PWM magic).
Also, since you have some knowledge on the subject, do you have any feedback on my stepping question?
Here's what I asked....
OK....I will mention as a caveat that I have some doubt as to the stepping required by this motor, since it is of the permanent magnet type and not the variable relucance type (for which current direction in the coil is inconsequential). I'm not sure if it is:
Option 1:
Phase A pulse
Phase B pulse
Phase A pulse
Phase B pulse
or
Option 2:
Phase A Pos pulse (current sent in positive direction through coil)
Phase B Pos pulse (current sent in positive direction through coil)
Phase A Neg pulse (current sent in negative direction through coil)
Phase B Neg pulse (current sent in negative direction through coil)
Phase A Pos pulse....etc.
Thanks
The L297 is just a controller, which makes life a whole lot easier for controlling a stepper. You should be able to control the stepper with a dual h-bridge like the L298, but it is much more difficult without the L297 to back it up.
Bruce
I should add that I'm not really trying to build a serious stepper motor controller here. I'm actually taking a course at the moment on embedded systems design and I need to give a presentation to my class tomorrow. We've been working on an ARM microcontroller platform. It can be a bit cumbersome programming on that platform, so I wanted to demo a simple .spin program to control a stepper motor to show how a propeller MCU masks a lot of the complexity required to build a simple motor driver, particularly the issues of dealing with timer registers all all that fun stuff. Therefore, it's not absolutely critical that I have a finished product - I would, however, like to get one of these objects working. I'll try the Spin Zone article too.
If that is the case, it would be a lot easier to just use a ULN2803 and a unipolar stepper motor. One SpinZone article and you would be ready for a demonstration.
Bruce
You said you omitted the sense resistors, but didn't say you simply jumpered them to ground; the statement I made was to ensure you have the sense pins connected to ground somehow.