Award
Congratulations irobot58, 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.

Lumpy, Lets Compare Notes On Kangaroo X2 Please

Assistance Requested

Help Dave Schulpius 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.

Dave Schulpius claims to have checked these sources:
 
#1

Hey Lumpy (or anyone who can advise). I'm addressing this first to Lumpy because I know he is using and working with the Kangaroo X2 / Sabertooth setup. If anyone has some insight please chime in.

Anyway, as mentioned in other posts I'm working through issues with my Kangaroo X2 / Sabertooth setup where I'm using two DC motors that have pots for feedback and limit switches. I now have both motors responding through serial commands from EZ Builder. I had an issue where I was continually getting error codes at power up and would have to power cycle the unit to get it to respond to serial commands. However I found I had to make sure the Sabertooth/Kangaroo powered down completely when the robot and EZB was switched off and then powered up after the EZB was powered up.

My issue now is trying to get the speed ramping feature of the Kangaroo to work. There are different ways to set up the Kangaroo; Velocity or Position control. I cant get the speed ramping to work when serial commands are sent from EZB in either control setting. However, I can get ramping to work nicely in Velocity but not Position tests when using the "Live Test" section of the Describe software used to set up the Kangaroo. When doing these test I'm attached directly to the Kangaroo with a Serial Adapter from a USB port of my laptop and EZB is not connected.

Without any ramping my motor will jerk to full speed and stop suddenly. I've e been working with Dimension Engineering on this for weeks but it's been painfully slow. The only way I can get help from them is through e-mail and it sometimes takes days for them to respond. Then I'll get a one sentence question or answer like "sounds like you need to make sure to upload your settings and reboot" or please send us a copy of your settings. This must be a newer product with limited users. I've found no community forums and few people posting info on this board.

One other thing. What is the best way to set servo control to work independently on the Sabertooth/Kangaroo's second motor channel? So far the only way I've been able to get it to work is if I start the first motor Chanel with a servo command and don't release it. I am using a second cable attached to a second digital port on EZB and attached to S2 of the kangaroo. I'll call that port when I want motor 2 to respond to a servo command.

I must say it is a great little board and from what I've been able to set up, it works great. I like the idea of being able to send servo commands to control my DC motors. Very precise and quick. If I can get this speed ramping issue figured out it will be an excellent addition to my B9 robot motor control.

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

Off the wall, first thing that comes to mind is can you send the serial command to start the motor but then put a " long" delay/sleep serial command ie 100uS then motor on then a short delay ie 80 uS etc until the motor is at your full desired speed!? Akin to PWM.....sometimes a crazy question can lead to a new perspective Smile

#3

Thanks Glen but it didn't work. I'm hitting dead end walls now with this issue. If I cant get it worked out I'll have to abandon the Kangaroo X2 and go back to having EZB ramp speed using progressing PWM commands. I cant put up with the jerky start up and stop. Now I'm even having problems with giving servo commands. I cant get ServoSpeed to work and servo position is resulting in jerky movement. Cant understand what happened. I had the servo commands working OK yesterday.

Tomorrow I'm going to do a factory reset on the Kangaroo and if that doesn't get things working again I'm moving on.

#4

Dang! That's just weird *confused*.....Lumpy! where are you? and or other Kangaroo people Smile

#5

Well, I got my answer I needed from Dimension Engineering. They say Kangaroo X2 does not support speed ramping in Position Mode. Speed ramping only works in Velocity Mode. The only thing I can control in Position Mode is Speed and position. From what I can tell Velocity Mode seems to be best used with RC controllers. They seemed to say that the only way I can get my motor to stop exactly at certain spots in Velocity Mode is to write script in one of the supported languages (C+, C++, VB and others). With a script like that I could also set ramping, speed and stopping points and send that script through the serial port. Problem is that Velocity Mode is not very precise or exact where it stops. Image an RC car rolling to a stop when you bring the joy stick back to center. I guess you could reverse to stop quickly or break.

To tell the truth if I have to learn all that language and write all these scripts to get a gradual ramp up and down I'm really not gaining much using the Kangaroo X2. I need speed ramping in position mode to get my B9 joint movements to look natural. I can see where this Sabertooth / Kangaroo would be a great little combo for other people in other types of platforms. It does a great job converting RC Signals and magically controlling a DC motor and accepting servo commands. If you really don't mind your motor starting up and stopping fast then the coolness of sending servo commands to a DC motor is for you.

With that said I still have this Sabertooth / Kangaroo X2 combo installed and I did a lot of rewiring to get it installed and working with B9's waist and hip motors. I'm not one to give up and hoped to get this setup to work the way I want in my B9 robot and EZB. So.... I started to rethink Glen's (irobot58) suggestion of sending gradual increasing speeds through a EZB serial port to the Kangaroo. Thanks Glen! . After some trials and more then a few errors I got it to work! I've got a first draft of a nice speed ramp up and down. The trick that works is to send a very low speed setting like s050 with a very short Sleep delay like 0050 before I go to the next gradual speed increase of s100. I continue this (keeping the Sleep to a very short 0050) up to about s300 or s400 then jump to the speed I want. In my case the best natural speed in about s500 or s600. The trick is the timing at full speed so it starts to reverse the ramp code at the right time so it drops speed back down to s050 at the very end of rotation. The result is a nice start up and a very slow cost to a stop. So the code looks something like this:

Code:


#This is the Ramp up section
SendSerial(D0, 9600, "1,p2450 s050", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s100", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s150", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s200", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s250", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s300", 0x0d)
Sleep(0050)

#This is the full speed setting. The Sleep setting is adjusted to the amount of time of rotation before speed ramps down
SendSerial(D0, 9600, "1,p2450 s500", 0x0d)
Sleep(1500)

#This is the ramp down section. It needs to reach the last command just before the end of rotation
SendSerial(D0, 9600, "1,p2450 s300", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s250", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s200", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s150", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s100", 0x0d)
Sleep(0050)
SendSerial(D0, 9600, "1,p2450 s050", 0x0d)

#This section turns off and releases the motor control
Sleep(1500)
SendSerial(D0, 9600, "1,Powerdown", 0x0d)



Like I said this is a ruff script that ramps nicely. I still need to work on it to see if I really need all the speed commands and if I can cut the Sleep commands even shorter. I also would like to see If I can send this script using only one SendSerial command with the speed changes called as a script.

If there are any suggestions on refining or tuning this I would really appreciate it.

#6

That's awesome Dave! Of course the script is cumbersome to build and not as elegant as we like....but...it will do what you want! Smile I am doubly pleased today as I was able to help out .....and...am currently holding my day old, first grandchild, Oliver in my arms Grin Grin
Perhaps a script that incorporates a variable that adds by certain increments and subtracts will fulfil the "elegant" quality!
I have been helped so many times by the awesome people of this Forum its a pure pleasure and joy to assist someone in whatever way possible ....... Thanks for the accolade Dave Grin

#7

Hey, congratulations on the grandchild! I know you must be proud.

Writing scripts is not one of my strong points. I'm going to have to think about this and try a few things out. Variables may work if I can figure out how to implement them.

#8

Some snippets of code which may help you out Smile

Increase a variable by a set amount

Code:


$X2_Speed = $X2_Speed + 50



So to ramp up from 0 to 300;

Code:


$X2_Speed = 0
:loop
IF($X2Speed < 300)
$X2_Speed = $X2_Speed + 50
Else
Halt()
EndIF
Sleep(50)
Goto(loop)



So if you put the send serial command below the :loop label and above the IF it'll run the command, starting at 0 speed, increase by 50, loop back up, send the serial data again, increase by 50 and so on until it hits 300, when it hits 300 (after sending the speed 300) the IF will terminate the script with the halt command.

To add in the speed variable to the serial data, i.e. SendSerial(D0, 9600, "1,p2450 s300", 0x0d) you simply need to break the data at the s and add in the variable so it would be like SendSerial(D0, 9600, "1,p2450 s"+$X2_Speed, 0x0d)

The same could be done for position, but break it at the p like SendSerial(D0, 9600, "1,p"+$X2_Position+" s300", 0x0d)

Note: I haven't tested this, I am unable to as I don't have a sabertooth or a Kangaroo (yet)

Unfortunately I'm out of time, it's late and I need sleep, but hopefully that will have explained a few things and helped guide you in the right direction. If not feel free to ask about whatever you are stuck with and I'll try to explain better.

#9

@Rich Your awesome! I wish I could give you half of Dave's accolade Smile You have articulated my vague script suggestion Smile very well. When Dave reads this I am sure he will be very pleased ...and anyone else who needs Kangaroo ramping Grin

#10

Thanks Rich for poppping in here with help on this code. It helps more then you know and is very welcomed. Smile I dont think I would have ever thought of writing it this way. Very nice and just what I was needing. I can see how it will be much smoother. It will be fun to get this code to ramp up, go to the right spot and ramp down as the motor gets there.

I only have a few free hours over the next few days so it may be a while till I get this working. Please keep an eye on me over the next week as I may need a helping hand on this code if your still willing and available.