Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: arixII on June 09, 2009, 01:54:08 PM

Title: H-bridge dual motor synchronous driver
Post by: arixII on June 09, 2009, 01:54:08 PM
Hi,
Maybe this is a question for which the answer is known to everyone except me - a novice :)
I have two hobby motors:
http://www.pololu.com/catalog/product/187 (http://www.pololu.com/catalog/product/187)

 with these specifications:

    * Description: Offset/inline
    * Gear ratio: 143:1
    * 3 V Operation:
          o No-load RPM: ~ 41
          o No-load current: ~ 52 mA
          o Stall current: ~ 390 mA
          o Stall torque: ~ 34.4 oz-in
    * 6 V Operation:
          o No-load RPM: ~ 80
          o No-load current: ~ 57 mA
          o Stall current: ~ 630 mA
          o Stall torque: ~ 59.3 oz-in
    * L x W x H: 55 x 48 x 23 mm
    * Weight: 32 g

and I need to test a Kalman algorithm for balancing with them, so there are such requirements for the motor driver:
1. speed control: for accurate turning of robot, also for PID and so on, I need to control for various speeds.
2. synchronous motor control: the ability to forward and reverse and stop motors exactly at the same time.

I saw the usage of L293D for two motors which seems ok, but I am not sure if the requirements would be satisfied with this chip or not. Please give some suggestions for a circuit to assemble and solder by myself, thank you!

Title: Re: H-bridge dual motor synchronous driver
Post by: Webbot on June 09, 2009, 02:21:23 PM
I did a tut on motor controllers here http://www.societyofrobots.com/member_tutorials/node/159 (http://www.societyofrobots.com/member_tutorials/node/159)

But if you want a closed loop system you will also need an encoder to provide the feedback on each motor re how fast it is actually turning. Here is an encoder made specifically for your motor http://www.solarbotics.com/products/gmww02/ (http://www.solarbotics.com/products/gmww02/)
Title: Re: H-bridge dual motor synchronous driver
Post by: arixII on June 09, 2009, 02:41:58 PM
I did a tut on motor controllers here http://www.societyofrobots.com/member_tutorials/node/159 (http://www.societyofrobots.com/member_tutorials/node/159)

But if you want a closed loop system you will also need an encoder to provide the feedback on each motor re how fast it is actually turning. Here is an encoder made specifically for your motor http://www.solarbotics.com/products/gmww02/ (http://www.solarbotics.com/products/gmww02/)

Thank you, I already read those nice tutorials with tri-state switches! What I am confused with, is that, you know in ssc-32 from linxmotion you can program like this (in Arduino term):
Code: [Select]
Serial.println("#0 P1400 #1 P1600");
and what happens is that, as microcontroller sends this via serial, the ssc-32 takes care for the motors to go synchronously. Meanwhile we can program like:
Code: [Select]
Serial.println("#0 P1400");
Serial.println("#1 P1600");
i.e. first command one motor, and then command the other. Here even though the lag is small, but there it is! Motors start not exactly at the same time (or I'm not right?). Well could you please write a line of code to show me, say, using a PIC and programming in C, how I can command both motors at the same time with 1 line of code?

p.s. I obtained encoders too, thank you for mentioning.
Title: Re: H-bridge dual motor synchronous driver
Post by: Soeren on June 09, 2009, 04:11:06 PM
Hi,

To start/stop both motors at the same time, just change the bits of a byte that you transfer to a port they're hanging on, no big deal.

However, you seem to think that your vehicle will move a measureable amount in the time between two instructions?
Even with a low speed controller say a PIC with a slow 4MHz X-tal in a vehicle going 100km/h, the displacement between two instructions will be less than 30µm (0.03mm). Consider that yous will probably have a higher clock speed and will most likely not outrun a sleepy turtle, lets say 4km/h max. (downhill), we're talking displacements of around 1µm (1/1000mm) or less (maximum). You really think that will make a difference?
Title: Re: H-bridge dual motor synchronous driver
Post by: Webbot on June 09, 2009, 05:25:32 PM
Although if its going via a UART then it will depend on baud rate. However: the difference between sending one command vs two commands will be very negligible particularly if the the UART is buffered - ie the cpu is much faster than uart so its queues up the first command and the second cmd will be added to the uart buffer before the first one has gone.

Of course if you want to reduce any timing issues then just use PWM rather than Uart serial link. Since this is digital I/O then the output effect is almost instantaneous (say a few microseconds).
Title: Re: H-bridge dual motor synchronous driver
Post by: Soeren on June 09, 2009, 05:39:05 PM
Hi,

Yeah, the differences between the two motors will probably be more significant.
Title: Re: H-bridge dual motor synchronous driver
Post by: Ro-Bot-X on June 09, 2009, 07:57:23 PM
For balancing, the motor drivers need to be directly connected to the microcontroller pins. A setup like Microcontroller - UART - SSC32 - motors will not work properly, because of the delays introduced by the serial communication. You can try to reprogram the microcontroller on the SSC32 to drive the motors and read the sensors directly. Anyways, SSC32 is a servo controller. That implies you are using modified servos as driving motors. So the advise here is to get a SN754410 (or L293D) H-bridge and attach it directly to the microcontroller that will run the balancing program. Also connect the encoders to the same micro. Personally, I think the motors are too slow for this application. You will be able to make the robot balance, but if you give it a push, it will not be able to recover in time. I was looking to get motors with over 200 RPM and built in encoders for a balancing robot.
Title: Re: H-bridge dual motor synchronous driver
Post by: arixII on June 09, 2009, 11:22:11 PM
To start/stop both motors at the same time, just change the bits of a byte that you transfer to a port they're hanging on, no big deal.

Could you please give me a small example in a fragment of code? (suppose it is a PIC micro controller and C language)
Title: Re: H-bridge dual motor synchronous driver
Post by: arixII on June 09, 2009, 11:31:02 PM
Personally, I think the motors are too slow for this application. You will be able to make the robot balance, but if you give it a push, it will not be able to recover in time. I was looking to get motors with over 200 RPM and built in encoders for a balancing robot.

Well close to my application, thank you! could you give more information about your own experience, or may be a link to your work if you published it online? Maybe you suggest motors? Actually I wrote a program with Kalman algorithm based on standard approach, and also want to test with complementary filters to see what suits best. Also, finally - in the experiment with hobby motors goes well - I would like to implement a real DIY-Segway based on Dalf OSMC Combo:
http://www.robotpower.com/catalog/ (http://www.robotpower.com/catalog/)
and maybe I test a Linksys router as the system processor and main board, in place of the Dalf micro controller board as in the link. Maybe you already now what works best?
Title: Re: H-bridge dual motor synchronous driver
Post by: Ro-Bot-X on June 10, 2009, 05:03:48 AM
I don't know what works best. Sorry.

I have done a simple balancing robot (http://www.societyofrobots.com/member_tutorials/node/185) using servos and a Ping))) ultrasonic sensor to read the distance to the surface. I am not such a good programmer to be able to write the Kalman filter or even adapt one to my specific board. But you are on the right track motor and sensor wise.