Shop OBEX P1 Docs P2 Docs Learn Events
PWM for multiple DC motors? — Parallax Forums

PWM for multiple DC motors?

kutalinelucaskutalinelucas Posts: 80
edited 2011-08-05 16:27 in Propeller 1
Hey guys...

I'm looking to control 4 dc motors with quadrature encoders from a propeller chip through two L293D drivers. The motors will be driven from a 2-way, 4-bit data bus with individual enable lines for each motor from a PIC18F...
This is my first bash at spin and I was wondering if each motor and encoder feedback could have its own cog, and generate the PWM for each motor independently and simultaneously?

Cheers

Martyn

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-02 17:46
    I believe so and you ay find some code in the Obex.
  • HarrisracingHarrisracing Posts: 10
    edited 2011-08-03 06:52
    To answer a couple of your questions:

    1) Yes you can independently control 4 different motors bidirectionally and completely simultaneously (and separately) with the propeller and two L293 IC's.
    2) I am currently running my own type of PWM to an L293 right now, but it's not the way that most of the objects run PWM. I made code that breaks down duty cycle and drives pulses since my application didn't need to be extremely precise. It does, however, work flawlessly on my projects and I have code that reads two different RC decay circuits on one cog and runs two motors on two other independent cogs. Bad news for you is that I did NOT require the enable nor did I require bi-directional rotation for them so you can't just use my code directly. I am simply reading two POTs and PWM driving two motors in one direction to correlate.
    3) I am completely unfamiliar with PIC's. I did learn C in college, but I'm a Mechanical Engineer who is learning Microprocessors and I really needed the level of learning that Parallax offers with their products, and after seeing the power of the Prop, I'm totally sold on it. I'm curious WHY you would need a PIC in this project when you could likely do it all with a PROP? Learning SPIN is the tough part and to use a PROP at all you will need to learn it, so why bother with the PIC afterwords? Just curious here.

    I can post code when I get home tonight.
    I hope this helps at least a little.

    Patrick
  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-08-05 16:27
    Hi Patrick...
    Sorry for the ridiculsly late reply but my attention has been fixated on the billion other things I need to do! I'm in the middle of my masters degree in robotics...everybody decided to take the localisation or the machine vision path for their dissertation so I thought I'd go old-school and build an anthroporphic actuator (as the uni made me name it...I was happy with the robot hand!)
    For the best part of the past 10 months I have been sat in front of some high level language and to be honest, it doesn't really hold my attention. I wanted to do something novel, so I decided to design a hand with comparable dexterity AND noticable torque, with seems to have evaded the world of anthrobotics...so...the plan was/is to actuate the bottom 4 knuckles and thumb with stepper motors for accuracy and the middle knuckles (with a planar link to the 'top' knuckles, as humans can't move them individually without intervention...) using dc motors through 'twisted-actuated joints'. The twisted actuation is a fairly new concept and there has been little research into it (there is a crazy German that loves it, the link is pretty long but so just google ''twisted string actuation' and download the top link).
    The general idea is a geared DC motor has one end of a looped string attached to it, where the other end is attached to the axis of a revolute joint. As the motor rotates, the string twists, spools up and translation is achieved at the load (or on the other end)... I have no idea of the figures, but I've seen the results and its pretty cool and proper tourquy, you're looking at about 1/2" translation through 4 revolutions over ~ 5cm with piece of string of about 4mm...and more direct tourqe than the motor could offer through a tendon thingy.

    OK, to finally answer you question...

    The pic is there because I've built (shamelessly, through various tutorials ) a generic HID USB interface, so I can communicate with everything I build through a c++ mfc application. There's lots of reasons for this really...
    1. Most importantly, I want each articulated joint to act independantly and simultainiously, which would have required some intense programming and debugging would have been almost impossible...plus I would have needed much more that an 8-core processor.
    2. I wanted the device to have the ability to be retro-fitted to any existing piece of hardware. I can map each instruction sent to and from each motor just by looking at a bit of code, which can easily be modified by anybody, and I look forward to writing this **** up and posting it on the net.
    3. If I have time (and I REALLY hope I do) I want to hook my hand up to a NO-dna data glove, which is pretty much just a USB glove with a series of flex resistors...and theres **** loads of sample code where a certain deviation in motion is directly proportional to a variable value in c++...
    4. Thought it would look cool.

    So far, I've hooked up the 5 stepper motors using 5 basic-stamp 2 modules and L293D drivers, which I know seems a little over-kill, but as I said, if each finger can't operate individually and simultainiously, whats the point? I might as well have built a gripper and gone on the Smile for the last month. Each stepper rotates over 45 degrees in 30 steps and has feedback from two flexiforce sensors, which will be attached to the inside of each finger. When an object is sensed, the motor stalls, maintains holding torque and sends the stall data back to the PIC through a 2-way 4 bit data bus and this information is updated through the application, so both the computer and stamp knows which step has resistance...which was a pain in the *** to design as I don't have a scope, so there's just a ****-load of hand-shaking going on between all processors, but the whole process, each way takes about 150mS, but i'd like it to be quicker.

    So now, I just have the top knuckles to do, and about three weeks to do it! Today, I think I got the last of my bugs out of my system so my full attention will be paid to spin...problem is this is my first attempt at spin. I've done some interesting things with 8052's (asm) and PICbasic (the old school 32-instruction asm) a few years ago, so I'm preying things go smoothly and I pick it up, otherwise I'm pretty fucked!

    Anyhoo, today i've ordered high-torque, 71->1 spur-geared dc brushed DC motors with built-in encoders which I intend to hook up to my prop...but I have no experiance or faintest idea of either! so if you could send me a bit of your code i'd appriciate it sooooo much, and if theres anything I could help you out with just give me a shout

    All the best...

    Martyn
Sign In or Register to comment.