
E4-B4 has been a little neglected lately, so or been playing trying to give him more graceful drive movements, so I'm looking for a little help with a ramping script to be used in a custom Movement Panel for my motor controller. I read a thread some time ago where DJ posted that ServoSpeed() commands can be used, so I have tried the following script for moving forwards...
servospeed(d3,5)
servospeed(d1,5)
PWM(D3, 0)
PWM(D1, 0)
Set(D2, Off)
Set(D0, Off)
PWM(D3, 65)
PWM(D1, 65)
I have setting tried different servo speeds, but the ramping part does not seem to work. I have also had a go at converting @Rich's Sabertooth ramping script, but could not get my head around where I needed to make the changes. Can anyone help me with a ramping script to ramp up when I hit forward or reverse, and ramp down when I hit "Stop" for the following movement commands...
#Forwards
Set(D2, Off)
Set(D0, Off)
PWM(D3, 65)
PWM(D1, 65)
#Reverse
Set(D2, On)
Set(D0, On)
PWM(D3, 65)
PWM(D1, 65)
#Stop
Set(D2, Off)
Set(D0, Off)
PWM(D3, 0)
PWM(D1, 0)
Thanks.
Lol, Alan, I know exactly what you mean.
Anyway, thanks.
I got a pretty good ramping effect by sending multiple increasing PWM values to my h-bridge when I was using them before I switched to Sabertooth. Just put a short sleep() between each one. It's easy to ramp up like that. The hard part is ramping back down. Even if you are able to get feedback of some kind it's hard to get a good rampdown to zero speed.
Thanks Dave. I did play about with that idea with a Roomba a while back, although it didn't work very well. I'll try it with the motor controller and see what happens.
I ended up using Dave's idea of using sleeps In between different PWM values. It's not pretty with the ramping down to stop part, but it's better than it was. If anyone has any better suggestions, I'd love to know what they are.
Anyway, thanks guys, and Dave especially for giving me a nudge in the right direction.
@Alan.
Did you get to play around with the L298 ramping idea with Roli?
Not yet.
Alan
Okay Alan. No worries.
I've not had much time to myself recently, but managed to find a couple of hours today to play robots, and set about sorting out E4-B4's movement ramping. I have a Sabertooth 2x25 on order now to replace the current motor controller, but in the meantime while I,m still using this controller, I'd like a little help with a "ramp down" script. Currently on my mobile interface, I have an if($pressed) variable so when the forwards button is pressed, the robot moves forwards. Press the same button again, the robot will stop using the following script that Dave S suggested...
and have similar scripts for reverse, turning differential left/right and U turn left/right. This works great, and gives a good effect, both ramping up and ramping down. But here is where I need the help. I also use the iPhone sensor stream control for drive movement as well, and use the movement commands such as Forwards() etc in a custom movement panel. So an example of the movement control panel scripts are as follows...
and the "STOP" button to ramp down to "Stop"...
This is all good. But the issue arises when I use a reverse or turning ramping script. For example, reverse ramping "up" is no problem... but when I press "STOP" to ramp "down" to stop the motors, it will obviously still use the "ramp down" from forwards script which causes problems, and excess strain on the gearboxes instantly changing direction at speed. So I need a "STOP" script to do a if moving forwards, ramp down from forwards. If moving in reverse, ramp down from reverse. Same for turn left and turn right.. I've had a play using "IF" and "ELSEIF" commands in various testing scripts, but have not had much success getting it to do what I need it to.
Like I said, I have a ST2x25 coming soon, but I still have a couple of robots that use the motor controllers this thread is talking about, so having a solution for this would be very useful... and maybe for others too.
Any help anyone can offer with with this custom Movement Panel ramping "STOP" script, would be appreciated.
Just throwing out an idea without trying it, but what if you have each directional script set a variable when it starts and have the stop look for the value of that variable and take the appropriate steps to ramp down from that direction, and also setting the variable back to "stopped"?
Alan