Asked
Resolved Resolved by DJ Sures!

Servo Command Code Through A Uart Port. EZB To Kangaroo/Sabertooth To DC Moto

The answer may be easy but the question is very hard to ask. I don't know why this happened...

Anyway, here's my setup: I have several servos on my robot and a DC motor controlled through a Kangaroo X2 attached to a Sabertooth 2X32.  I have the Kangaroo attached to a uart port 1 on an EZB v4 (Digital ports 5 and 6 for Rx & Tx). I usually control the DC motor using simply serial commands in ARC, through the Uart to the Roo. It works great tis way.

Question: I was playing around inside the EZBv4's web interface. In the diagnostic section of the interface there are several buttons that move servos different distances. I'm sure these are to check if your servos are getting the proper signals and work. Anyway, I tried one of these tests and as expected all my servos moved the expected distance. What shocked me was the DC motor attached to the Kangaroo and Uart 1 port on the EZB also moved this distance. Obviously the Roo is getting proper commands from the EZB's web interface to move the DC motor.  Like mentioned above, I have always used Simple Serial code to move DC motors attached to the Roo/Sabertooth. For example (this assumes that the Uart has already been initiated and the Roo's channel has already been started:

uartWrite(2, 2, "2, p412 s750", 0x0d)

Why did the DC motor attached to the Roo move the same amount as all the servos when I told EZB to move all servos? Can I send a servo command to Roo to move a DC motor through a Uart port? If so any idea how it would be written in ARC?

My guess but it doesn't look or seem correct:

uartWrite(2, 2, "2, Servo(D14, 25)", 0x0d)

I can't find any information on this at Dimention Engineering, EZ Robot or Synthiam.


Related Hardware EZ-B v4
Related Control EZ-B v4 Info

ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

PRO
Synthiam
#1   — Edited

LOL Dave you’re losing it :D. A servo is moved using a servo command. The kangaroo manual states that you can instruct the movement by using either servo pwm pulses or uart commands. So just use any servo control. I demonstrates this in the live hack I did with the kangaroo a year or two ago :)

when you press the button in the web interface, it’s just sending a servo pwm. It’s the same pwm that’s sent when ARC sets a servo position. So just use the kangaroo as a regular servo. It works that way

Servo (servoPort, position) Move servo to the specified position Servo position is between 1 and 180 Example: Servo(D14, 25)

or any servo control will work

#2   — Edited

LOL, You're probably right. I'm falling behind and not taking the time to try and test. Maybe I'm just getting lazy in my old age. ;)

So.....

To send the command through a Uart I guess I need to write the EZ code like this:  UARTWrite( boardIndex, port, data).

I'll give it a go. Till now I've always sent servo commands through the digital ports of the EZB and didn't know if it would work through a Uart.

Thanks!

PRO
Synthiam
#3   — Edited

No you don’t send any uart commands. Just use a simple servo. Use it as a servo. Just use servos and set the port that the kangaroo is on. The kangaroo is a servo. It becomes a servo soon as it gets servo commands.

forget uart ever existed if you want to use the kangaroo in servo mode

you do have to configure the servo pwm range in the software. Or through the self learning. That’s in their manual, which I find hard to understand lol

#5  

Ok, that was so simple I feel embarrassed. LOL. I understand now and I have control of the kangaroo with servo commands instead of simple Serial commands. I don't know why it wasn't sinking in. Maybe I was thinking RC servo control and Serial control was the same.

Bottom line is: When using Simple Serial commands with the kangaroo I should attach to one of EZB's Uart ports. On the Roo side the connections are: Ground S1 (TX) S2 (RX)

When sending (RC) servo commands I attach a signal wire to an EZB digital port. On the Roo side the connections for the two servos are: Servo 1 - S1 and Ground Servo 2 - S2 and ground

The same Kangaroo ports S1 and S1 are used in each mode. The difference is on the EZB side. My feedback device and connections from the motor stayed the same in both modes.

I also rewatched your Kangaroo live hack. Although I was watching it back when you did it live, it really helped to see it again. These are such a valuable tool for us. Thanks again!

PRO
Synthiam
#6  

Nice - that's great to hear. Using the kangaroo as a servo will make your project way more versatile :)

#7   — Edited

Yes I agree, however it has it's place I think.

I'd like to test the good and bad of using two DC motors with encoders and Limit switches for feedback through the Kangaroo both ways, Uart control and Digital Port.  Here are some early thoughts, questions and observations:

*Motor and encoder attached to Roo through the Uart sending simple serial commands from ARC. Because I'm using an encoder, the motor needs to be homed the first time the Roo channel is started so the position of the motor is known. This would be needed for motors easily moved or loose their resting position when powered down. To send my desired position command ARC needs to know where the motor actually is. Homing the motor every time at start up solves this by moving the motor to one of the limit switchs. Once the Roo was set up by having a successful tuned it will know where the limit switches are and how far apart and stay within it's travel points among other things. The Roo will not accept simple serial commands and move until the motors have been homed in this mode.

The EZ Script to Initialize an EZB uart port, start a motor channel on the Kangaroo X2 and home the motor attached to it (before a Simple Serial movement command can be sent) are :

UARTInit(0, 0, 9600 ) #Turn on EZB 0, Uart #0 port at 96 baud (Only needs to be done once before first command or the EZB will crash and disconnect!)
uartWrite(0, 0, "1, start", 0x0d) #Start channel 1 on Kangaroo and attached to EZB 0 (Only needs to be done once before first command)
uartWrite(0, 0, "1, Home", 0x0d) #Will home the motor attached to channel 1 on Kangaroo and attached to EZB 0. 

Only after the above code is sent and is successfully received can the following code be sent to move the motor:

uartWrite(0, 0, "1, p675 s75", 0x0d) #Will move the motor attached to channel 1 on Kangaroo and attached to EZB 0 to Position 675 at the speed of 75

The P (position) and S (speed) were tuned and set in the Kangaroo's computer during it's tune process.

More to come using the Uart port as I test and install.......................................

*Motor and encoder attached to Roo through a Digital Port sending servo commands from ARC. Even though I have an encoder and limit switches attached to the to the Roo for feedback there is no homing done before any EZ Script servo Command is sent. I don't know if the Kangaroo uses the encoder or limit switches when reacting to a servo command. However It does need the encoder for the first Kangaroo tune to know the travel distance between the end points among other things. The limit switches may keep the servo command from sending the motor outside of the actual endpoints but that is yet to be determined. There is also no need to Initialize an EZB uart port or use complicated simple serial commands.  Any EZ Script servo command can be used. However unlike the Kangaroo simple serial commands you can not send the position and speed at the same time. You need to send the EZ Script commands on different lines (just like you were controlling a regular servo) within a movement script like this. You must follow the EZ Script rules to apply servospeed. See the EZ Script manual or you may have problems setting your desired motor speed :

Servo(D14, 25) #Digital Port D14, Position 25
servospeed(D14, 3) #Set speed of motor attached to Digital Port D14 to servospeed 3. All servo rules apply when using servospeed command. See manual!


Unlike the Uart mode above where a Kangaroo is receiving Simple Serial commands and will not move until the motor is homed, there has no way to home the motor through a digital port so the Roo knows where the motor is when it starts up. This may cause problems when sending servo commands to send a motor to a desired position. How can the motor be sent to a certain position if it does not know where it's starting from? If a motor position is moved when it's powered down your desired positions may not be as expected.

More come using a Digital Port as I test and install..................................

Thanks for reading and all the help so far!! Have fun!!!

#8  

@Dave,  I think potentially the reason you thought you needed to use serial is because that is the mode used without the Kangaroo in the Sabertooth Movement Panel.  Although the Sabertooth does support R/C mode (ie, PWM) for some reason users (might have even been you, I don't recall) were not successful getting that mode to work back on the EZ-B 3, so everyone started using simple serial.  It very well may work fine on the V4.  I'll give it a try one day since once I am comfortable enough with the Navigator to allow a bot with wheelchair motors to roam free in my house I'll finally take my 2x25 out of the box (after 10 years... lol).

Alan

#9   — Edited

Hi @Alan, You may be correct. I remember trying to use PWM mode in the Roo back with the V3. I also tried a few other ways to control position. Nothing worked well or at all for me. I really wanted precise position control with feedback and ramping. Ramping was key to me as I wanted a natural looking start and stop of the motors. I almost gave up on the Kangaroo but Toymaker convinced me to keep trying and helped me quite a lot towards my eventual success. Ahhh, those were the days! LOL.

Anyway, as this new thread shows I went back and tried RC mode again feeding the Roo servo commands from ARC through EZB. Thanks to DJ's help I did get it to work by using a digital port instead of the Uart. As stated above I think there is a place for both ways, Simple Serial through the Uart and servo Commands through the Digital ports. I think it mostly depends what you want to e motors to do and where they are used.