
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.
Thanks Alan.
I did think of setting the direction commands as variables might be the way to go, and after my other try's at composing a working script, I did start to write one using this idea but I gotta be honest, I hit a wall pretty early on as I'm not sure how to fully write the script. I don't normally ask for script examples as I like to try to work it out for myself, but in this case I'd be grateful if someone could post a "stop from forwards" and "stop from reverse" example as I'm at a loss of how to write it. I can work out the turning scripts from there.
Thanks.
At the end of each direction script, set a variable to the current direction like:
The your stop script, insert your ramp down code in the appropriate sections of this script:
Alan
I was never able to successfully get a script to ramp down. The hardest part was figuring out when to start the ramp and how fast to ramp down so you reach zero speed at the very end of movement. I was kinda close once when I used some math in the script to figure out the length of the move and start the ramp down script about 20% before I reached the end. Then I started the declining PWM commands. It was mostly timing and luck. I think I got the idea and tips from toymaker. Sorry I don't have though scripts anymore. I ditched them when I switched over to Sabertooth and Kangaroo's.
Great stuff. Thanks for that Alan. When I started writing the script using the variables, I was going to use "elseif's", so I had that wrong straight off, lol (over thinking things as usual). This makes much more sense, and simpler than I thought. Thanks again.
@Dave.
Yeah, when I tried this on my Roomba a while back, I never really got a great effect for ramping down either. But in this situation it actually works quite well. I played around with the sleep() values to see what worked best, and 150 seemed to be the magic number for both ramping up and down for this particular setup. I'll do a quick video demo of the ramping in action and post it on my E4-B4 showcase.
The motor controller this thread is about has an automatic braking function which stops the motors dead, and I was always worried that E4 might tip over from or to maximum speed. This is a great help.
Thanks again guys.
Steve.
You could probably get fancy with the left and right scripts too so that you don't need to stop first and it continues at previous speed instead of suddenly dropping speed before ramping back up into the turn, but that is more than I can wrap my head around thia morning.
Alan
Cheers Alan, that is a good thought and something for me to play about with. I've also got to incorporate two ping sensors in to this as well for object avoidance, so I'll have a go at adding it all together over the next few days.
Thanks again.