Prop / Servo32v7 & Servo32_Ramp_v2 questions
Spiral_72
Posts: 791
First I'd be happy to read the manual if there's a full documentation available.... I haven't found one.
I feel pretty confident with the Servo32v7 object, however due to a problem I can't seem to find in "MY" servo ramping code I decided it was time to try out the Servo32_Ramp_v2 object suggested by someone.
Here's my code which started as Servo32v7_RampDemo code. I edited it to learn how it works:
As I understand it, SetRamp is called with the following three parameters:
Correct me, cause this isn't working like I think it should. Where am I wrong?
Instead it centers, moves in about two seconds, waits ten seconds, moves in two seconds, waits ten, then back to center!!??!!
What gives?
I feel pretty confident with the Servo32v7 object, however due to a problem I can't seem to find in "MY" servo ramping code I decided it was time to try out the Servo32_Ramp_v2 object suggested by someone.
Here's my code which started as Servo32v7_RampDemo code. I edited it to learn how it works:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 'Note Clock Speed for your setup!! ServoCh1 = 0 'Select DEMO servo _RampDelay = 10 ' ramp time in seconds VAR OBJ SERVO : "Servo32v7.spin" PUB Servo32_DEMO | temp SERVO.Start 'Start Servo handler SERVO.Ramp 'Start Background Ramping 'Note: Ramping requires another COG ' If ramping is not started, then ' 'SetRamp' commands within the ' program are ignored ' 'Note: At ANY time, the 'Set' command overides ' the servo position. To 'Ramp' from the ' current position to the next position, ' you must use the 'SetRamp' command repeat ' 'Set(Pin, Width) SERVO.Set(ServoCh1,1500) 'Move Servo to Center 'SetRamp(Pin, Width,Delay)<-- 100 = 1 sec 6000 = 1 min SERVO.SetRamp(ServoCh1,2000,_RampDelay*100) 'Pan Servo N seconds waitcnt(clkfreq * _RampDelay + cnt) 'Wait for ramp to complete SERVO.SetRamp(ServoCh1,1000,_RampDelay*100) 'Pan Servo, duration = 1/2 original sweep time waitcnt(clkfreq * _RampDelay + cnt) 'Wait for ramp to complete SERVO.Set(ServoCh1,1500) 'Force Servo to Center
As I understand it, SetRamp is called with the following three parameters:
Pin the servo is connected to
PulseWidth (position) to send the servo to, from it's current position
Delay (Duration) of time for the move where 100 = 1sec, 6000 = 60sec so n = seconds * 100
PulseWidth (position) to send the servo to, from it's current position
Delay (Duration) of time for the move where 100 = 1sec, 6000 = 60sec so n = seconds * 100
Correct me, cause this isn't working like I think it should. Where am I wrong?
Prop set to 80Mhz
Constant _RampDelay is set to 10 seconds
Send the servo to center (1500us) with Servo.Set
Ramp the servo to 2000us over 10 seconds ( _RampDelay * 100)
Wait for the ramp to complete (10 seconds)
Ramp the servo to 1000us over 5 seconds ( _RampDelay * 50) or (_RampDelay / 2 *100)
Wait for the ramp to complete (10 seconds)..... so the servo should move to position in 5sec then wait 5sec
Send the servo to center (1500us) with Servo.Set
Instead it centers, moves in about two seconds, waits ten seconds, moves in two seconds, waits ten, then back to center!!??!!
What gives?
Comments
the CoreSpeed constant in Servo32_Ramp_v2 is a scaling function. You change it according to your clock speed. I realized this after saying "It's off by a scale of FOUR".
CoreSpeed was set to 620..... 620 / 4 is 155 or really close to 160.... the minimum option mentioned in the code comments. Change the CoreSpeed and it works just like I intended.
Can I delete all this? I've been working on it for an hour and half I swear!
The file in ObEx has demo code that shows you how to use the features.
-- http://obex.parallax.com/objects/445/
I hope you don't delete this. I was also having trouble understanding the ramping option of Servo32v7. These posts have helped me understand it better.
Thank you.
Duane: What!? You led me the way man, surely I can't help you!.................I won't delete it.... The way things worked out was kinda silly and a little embarrassing maybe. I answered my own question after giving up and posting it here.
Like I mentioned the ServoRamp object does not have the intermittent issue that my interpolation routine does, but my code is MUCH smoother. Gosh I wish I knew what was wrong with mine....... I guess that comment doesn't mean much if y'all haven't been following my biped build.
Don't get me wrong, the servo32_ramp_v2 is fantastic. I loved it with all the large test moves, but the data points I'm feeding it are fine control.... small movements.