Shop OBEX P1 Docs P2 Docs Learn Events
Motor Control for Animatronic Head — Parallax Forums

Motor Control for Animatronic Head

ajajackajajack Posts: 26
edited 2008-09-02 15:32 in General Discussion
Hello,

I am working on an Animatronic Head for Halloween this year. I want to use a RS-445PPA motor to control the head. The head will be able to rotate as if it's spine was the imaginary axis. The datasheet for this motor can be found here: www.mabuchi-motor.co.jp/cgi-bin/catalog/e_catalog.cgi?CAT_ID=rs_445papd. In order for the head to turn, the polarity of the motor must be changed. I wanted to use an SX 28 to do this but I am not sure how and I am also afraid that the motor will draw too much current and blow a pin on the SX. I don't want to have to use a motor controller but maybe I could use a relay or something. Can anybody help me?

-AJ

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-01 18:34
    You should NEVER connect a motor directly to the SX; you want to use an H-Bridge circuit or chip. You could use a chip like the L293D and proper code to control speed and direction.
  • ajajackajajack Posts: 26
    edited 2008-09-01 22:10
    I understand this but would some sort of relay work, like this from RadioShack: http://www.radioshack.com/product/index.jsp?productId=2062478&cp=2032058.2032230.2032277&pg=1&parentPage=family.
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-01 23:08
    Go ahead, hook it up. Your next post will be, "Why did my SX blow up?" Trust me on this, I've done enough damage to micros to know what works and what doesn't. Never connect any kind of inductive device (anything with a coil) directly to a microcontroller; at the very least use a transistor buffer.

    Here's the deal: That relay -- which will likely break your SX IO pin -- costs $3; if you put buffering in place (as you should -- see attached schematic) you're in it for about $4 for one channel of on or off control. An L293D costs $4 from Mouser and needs no additional components. Also, the L293D won't hurt your SX and will give you four channels of on/off or even PWM (proportional) control. You can combine two channels with PWM programming to give your motor speed and direction control, something you'll never get from a single relay. See the attached program for an example of SX software for motor speed and direction control.

    Post Edited (JonnyMac) : 9/1/2008 11:13:45 PM GMT
    450 x 302 - 28K
  • datacpsdatacps Posts: 139
    edited 2008-09-02 02:28
    Jon as always thanks for giving so much to the SX members. . If it where not for your support and Beans I don't think the SX Chip would be where it is at now.. I just want to comment on the code. I see you using more assembly lately I was wondering is it beacuse that piece of code needs to be in assembly or you just using it more to teach us.. Thanks again
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-02 03:03
    SX/B was designed to be a language that helps users make the transition from BASIC to Assembly -- if they choose. I have written hundreds of programs in pure SX/B but as you've noticed, have been dropping in more Assembly of late. SX/B produces really great code but by it's nature any compiler will not be as efficient as hand-coded assembly. Listen, I'm no Assembly guy. I get good stuff from my pal Guenther Daubach (like the PWM code in this program) and others, as well as from the compiled output of SX/B and put it to use. You don't have to. I choose to because I want to be able to unleash as much horsepower from the SX as I can handle. I'm doing a DMX application for a big amusement park right now and there's really no way around using Assembly in many sections (DMX runs 250K baud). If it wasn't for SX/B and the hard work Bean has put into it, I would have never been able to pull off that project.

    Thanks for your kind comments.
  • John BondJohn Bond Posts: 369
    edited 2008-09-02 10:12
    Hey Jon

    That motor code is Mamba - Thanks

    John Bond

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-02 15:32
    Snake like?.... It's actually quite simple, and the PWM routine is something that Guenther created; I just modified it a bit so that the output is pure, that is, it doesn't preset the output and then turn it right back off -- costs a couple cycles but I think this is okay. Glad you found it useful (I've been using that PWM algorithm a lot lately).
Sign In or Register to comment.