Award
Congratulations Rich, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

How To: Controlling 2 X Dc Motors Independently On The Ezb?

Assistance Requested

Help Anthony XLRobots.com with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Anthony XLRobots.com claims to have checked these sources:
 
#1

Ok im all set and ready to power my arms, except the sabertooth moves both arms at the same time. How can I control each motor separately. my only option would be to use 2 ezb's but that would mean 2 sabertooths meaning I wouldn't have room for the drive train. I saw a board called jrk 21v3 motor controller (pic below) I think this would be great but the amps peak at 5a and are steady at 3a. I need this in its next size,like a 5a -15a range though the motor runs at 4v 9a.

User-inserted image


JrK 21v3

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

I would have to see your wiring and you code, but sabertooth motor controller has two channels, which you can control independently using Analog, R/C, simplified serial, packetized serial.....

#3

From the manual

Quote:

Mode 3: Simplified Serial Mode

Simplified serial uses TTL level single-byte serial commands to set the motor speed and direction. This makes it easy to interface to microcontrollers and PCs, without having to implement a packet-based communications protocol. Simplified serial is a one-direction only interface. The transmit line from the host is connected to S1. The host's receive line is not connected to the Sabertooth. Because of this, multiple drivers can be connected to the same serial transmitter. If using a true RS-232 device like a PC's serial port, it is necessary to use a level converter to shift the -10V to 10V RS-232 levels to the 0V to 5V TTL levels the Sabertooth is expecting. This is usually done with a Max232 type chip. If using a TTL serial device like a microcontroller or a USB-to-TTL serial converter, the TX line may be connected directly to S1.

Because Sabertooth controls two motors with one 8 byte character, when operating in Simplified Serial mode, each motor has 7 bits of resolution. Sending a character between 1 and 127 will control motor 1. 1 is full reverse, 64 is stop and 127 is full forward. Sending a character between 128 and 255 will control motor 2. 128 is full reverse, 192 is stop and 255 is full forward.
Character 0 (hex 0x00) is a special case. Sending this character will shut down both motors.



The last paragraph is what you are looking for...
Sending a character between 1 and 127 will control motor 1. 1 is full reverse, 64 is stop and 127 is full forward. Sending a character between 128 and 255 will control motor 2. 128 is full reverse, 192 is stop and 255 is full forward.

So to move the motors simply use a SendSerial() command with the correct sabertooth command.

#4

Also, you may want to consider using one of these Kangaroo boards to control the Sabertooth. It'll basically turn the DC motors in to servos if you add in some feedback pots or encoders and simplify the coding needed for smooth arm movements.

Kangaroo Manual

#5

@rich. You my friend are the Best! Thank you for the info, you have made my day!

#6

I agree with Rich on the Kangaroo. Just remember to somehow put a potentiometer in there for feedback. Perhaps if you can't mount a pot directly you can try a sprocket and chain arrangement that is also attached to the potentiometer. I listed a multiturn because the sprocket you may use on the shoulder may very well be larger that the one attached to the feedback pot resulting in more turns. Im sure you will figure out the specifics. Best of luck.

#7

Hi all,

This Kangaroo board looks neat and like it would come in handy but isn't it just duplicating what the EZB can already do via it's ADC ports and an H-Bridge? If a pot is used for feedback info you can just attach it to a ADC port and attach the power for the motor to a h-bridge that can handle the load. The only advantage I can see using this Kangaroo board is it can read encoders directly where the EZB cant.

So, am I missing something here? Is the Kangaroo a better solution then letting the EZB do the work because it's more exact in position and quicker by taking the overhead away from EZB and is also adjustable?

I know there was a thread about this board a few weeks ago and I had these same questions in the back of my head then.

Thanks for any clarity, Winky
Dave Schulpius

#8

@Dave, yes it does do what can already be done in EZ-Builder.

However, it does simplify the coding required. And as you have said it will be more accurate, quicker and take the load off of the EZ-B.

It's one of those things where it really only comes down to cost vs convenience.

#9

Thanks for clarifying this Rich.

Do you have a simple and quick example or explanation on how the coding would be simpler then using the Get ADC, PWM and digital port coding used when letting EZB do the work? I cant seem to open the manual link you supplied above. I think it my computer, not the link.

#10

As far as I can tell (from the manual as I don't have a Kangaroo or a Sabertooth to play with yet)...

Rather than having a script constantly looping to get the ADC of the pots (which I understand can create quite a load on the EZ-B comms and on the PC) you wouldn't have that at all.

A simple SendSerial() to the Kangaroo would tell the Kangaroo what you want to do. The Kangaroo would then monitor pots, limit switches etc. and send PWM etc. to the Sabertooth. The sabertooth isn't connected to the EZ-B directly therefore the whole load of monitoring and moving the Sabertooth motors is carried out by the Kangaroo.

An example (which may not be 100% correct since I can't test it so don't expect it to work - but it might);

Code:

SendSerial(D0,9600,"1,p400 s50")



That's all you would need to move the motors 400 units at 50 units per second. No GetADC, no looping scripts monitoring everything, no bottlenecks on the comms.