Shop OBEX P1 Docs P2 Docs Learn Events
Dual Motor Driver Object for SN754410 — Parallax Forums

Dual Motor Driver Object for SN754410

Martin_HMartin_H Posts: 4,051
edited 2012-11-29 18:52 in Propeller 1
I was wondering if there's any popular object for driving a sn754410 or similar H-bridge? I SN754410.spin by Javier R. Movellan, but that only drivers a single motor. While I could tweak it to allow configuring the control pins and create two instances, each instance would want its own cog. Ideally what I'm looking for would implement a full control loop, so I would set a direction and speed for each motor and it would ramp them for me.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-26 19:34
    Kye's "PWM2C_HBDEngine" controls two H-bridges with a single cog. It doesn't take care of ramping though.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-27 07:28
    Duane, thanks for the pointer. I'll take a look.

    Update: I don't think that will work because I'm using three pins (ena, dir1, dir2) per channel. I want to PWM the ena channel while holding dir1 and dir2 fixed.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-28 08:03
    Martin_H wrote: »
    Duane, thanks for the pointer. I'll take a look.

    Update: I don't think that will work because I'm using three pins (ena, dir1, dir2) per channel. I want to PWM the ena channel while holding dir1 and dir2 fixed.

    The way I've used Kye's object is to tie the enable pin high and use negative speed to make the motor turn backward.

    I just found a modified version of Kye's code that uses the enable pins. It looks like I also made easier to modify the resolution of the driver.

    I also found a simple demo for the driver.

    It's been a while since I've used these so let me know if there's a problem.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-28 08:17
    Thanks Duane, I'll take a look at this tonight.
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2012-11-28 11:17
    Have you seen the motor control schematic for the Handyboard? It normally uses a pair of L293D chips but you can use the SB754410 chips instead. It can control up to four motors so you only need to look at half the schematic. It just adds a 74HC04 inverter so you can just use two I/O lines per motor. If you use that 74HC04 just make sure you tie any un-used inputs to ground or the supply since CMOS chips don't like inputs that aren't connected.

    http://www.handyboard.com/oldhb/schemv12/motor.gif

    Robert
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-28 11:36
    Robert, thanks for the pointer. I am using three pins because I want to be able to pull both lines low for dynamic braking. I'm pretty sure that if ena is off the driver doesn't care about its inputs, but if ena is high and dir1 and dir2 are low the motor's terminals are shorted across ground and the robot stops rather than rolling freely.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-11-28 12:50
    Can't a 754410 chip be controlled with just two lines per motor normally?

    I thought if you tied the enable pin high you could power the motor one direction by pulsing dir1 with dir2 held low. To reverse direction pull dir1 low and pulse dir2.

    I'm I missing something?

    After reading Martin's last post, I wonder if pulsing the enable pin is more efficient than the method I just described?

    I'm pretty sure I've use these chip with both these methods, maybe I should only use the pulsed enable method?
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-28 13:09
    Duane, the data sheet http://www.ti.com/lit/ds/symlink/sn754410.pdf contains a function table. It sure looks to me like you sacrifice tri-state logic if you tie ena high. At that point when you apply PWM to dir1 or dir2 you have to flip it from the opposite state of the other pin. In doing that you'll either short both leads high or low which should apply the brakes.

    If you only want to use two pins you use an invertor like the Handyboard does. Then you have a direction bit and an pwm bit at the cost of dynamic braking.
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2012-11-28 13:17
    Duane Degn wrote: »
    Can't a 754410 chip be controlled with just two lines per motor normally?

    I thought if you tied the enable pin high you could power the motor one direction by pulsing dir1 with dir2 held low. To reverse direction pull dir1 low and pulse dir2.

    I'm I missing something?

    Two pins work just fine. The link I posted to the schematic of the Handyboard motor control section uses it with only a two pin interface. The extra pin is only needed if you want more control over it for braking. It depends upon what motors you're using it with. If the motors have a worm gear drive then not having braking shouldn't be an issue.

    Robert
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-28 18:52
    Duane, I took a look at the code and it looks like I can adapt this to what I need. I downloaded it and was able to ramp the motors just fine. Thanks a bunch.
  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-11-29 09:13
    I have done motor control for a camera platform using the attached (dirt simple) object. The great thing about using the counters in a synchronized loop is that you can create precise pwm signals without resorting to PASM. The object does not control enable pins because that's not necessary; if you're controlling those pins you would do it from the application code, anyway. I think it's a good idea to do that, because it allows you to let the motors coast.

    On a side note, the L293D/754410 (and compatible chips) are pretty handy. In the very near future the chaser lights on the Eiffel Tower in Small World (Anaheim Disneyland) will be controlled by a Propeller driving an LED rope (matrix) that they already had. They needed the ability to chase and dim, and the matrix requires high, low, and hi-z outputs for control. I designed a circuit and code for the L293D to drive all the lines with a PWM (brightness) signal being applied the the enable pin that controls the common line to the matrix. I spoke with them yesterday; the circuit is running on the bench and they will install it shortly.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-11-29 18:52
    Thanks, I will take a look at this tomorrow.
Sign In or Register to comment.