That fixed it i had to use servo 32 though. BS2 Functions didn't work, it moved the servo about 5 degrees and then stopped.
How do i convert the BS2's 500 to 1000 servo pulses 750 being center to servo32 servo pulses.
Servo32 seams to use higher numbers (i am assuming this is because of the propellers 5mhz external clock).
Sorry I didn't see this one earlier. The BS2 functions didn't work because it was never started which sets up the timing variables needed for things like PULSOUT.
BS2.Start(31,30)
I need to change that. I keep having to point this out.
-Martin
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!
SpeedServo = 8
DirectionServo = 9
OBJ
SERVO : "Servo32"
PUB Servo32_DEMO | temp
'Preset Servo's you want to use to center position
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
'Note: Servo pins that will be used must be preset before running "SERVO.Start".
' This is because the I/O direction is set here and is only executed
' at the beginning of "SERVO.Start". Servo pins that aren't used will remain
' in their original direction state.
SERVO.Start 'Start Servo handler
repeat 200
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
repeat 100
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,1000)
repeat 200
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
repeat 100
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,2000)
Thank you
Post Edited (computer guy) : 3/12/2007 8:51:49 PM GMT
try replacing the repeats with waits, when you set the servos the cog that was launched with servo.start handles all the repetitions
like waitcnt(2*clkfreq + cnt) for the 100s
and waitcnt(4*clkfreq + cnt) for the 200s
the main cog is likely finishing the program before the servos move, think of it as more of a servo controller that you set only when you need to change the servo position or direction in the case of continuous rotation ones
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!
SpeedServo = 8
DirectionServo = 9
OBJ
SERVO : "Servo32"
PUB Servo32_DEMO | temp
'Preset Servo's you want to use to center position
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
'Note: Servo pins that will be used must be preset before running "SERVO.Start".
' This is because the I/O direction is set here and is only executed
' at the beginning of "SERVO.Start". Servo pins that aren't used will remain
' in their original direction state.
SERVO.Start 'Start Servo handler
repeat
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,1000)
waitcnt(clkfreq + cnt)
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,2000)
waitcnt(clkfreq + cnt)
I tested this code, it works, you never stated what exactly you were trying to make it do, I made it so one servo moves back and forth and the other spins in one direction, each pause for a second between.
Ok, you are misunderstanding the mechanics of Servo32. It is not a PULSOUT substitute, it is a servo controller in and of itself, in that you send it a value and it generates a stream of pulses for you. Sending the value to it 200 times has no additional effect over sending it once. To use it the way that you are thinking, compute the time it will take to generate the pulses and do a waitcnt for that period (20ms*100 = 2 seconds = clkfreq << 1) and (20ms*200 = 4 seconds = clkfreq << 2)
The clkfreq << x is a relative time, you need to add this to the present time (cnt) to make the value absolute, so the commands would be waitcnt(clkfreq << 1 + cnt) and waitcnt(clkfreq << 2 + cnt). In this case it doesn't matter but as general practice place cnt at the end of a waitcnt equation.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!
SpeedServo = 8
DirectionServo = 9
OBJ
SERVO : "Servo32"
PUB Servo32_DEMO | temp
'Preset Servo's you want to use to center position
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
'Note: Servo pins that will be used must be preset before running "SERVO.Start".
' This is because the I/O direction is set here and is only executed
' at the beginning of "SERVO.Start". Servo pins that aren't used will remain
' in their original direction state.
SERVO.Start 'Start Servo handler
repeat
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq << 1 + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,1000)
waitcnt(clkfreq << 2 + cnt)
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq << 1 + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,2000)
waitcnt(clkfreq << 2 + cnt)
but it still only moves both servo's once.
Any idea.
What do you mean by once? Your indent structure is off, make the waitcnt's the same indentation with the other SERVO statements. Remember indentation imparts block structure in this language.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!
SpeedServo = 8
DirectionServo = 9
OBJ
SERVO : "Servo32"
PUB Servo32_DEMO | temp
'Preset Servo's you want to use to center position
SERVO.Set(SpeedServo,1500)
SERVO.Set(DirectionServo,1500)
'Note: Servo pins that will be used must be preset before running "SERVO.Start".
' This is because the I/O direction is set here and is only executed
' at the beginning of "SERVO.Start". Servo pins that aren't used will remain
' in their original direction state.
SERVO.Start 'Start Servo handler
repeat
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq << 1 + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,1000)
waitcnt(clkfreq << 2 + cnt)
SERVO.Set(SpeedServo,1250)
SERVO.Set(DirectionServo,1500)
waitcnt(clkfreq << 1 + cnt)
SERVO.Set(SpeedServo,1000)
SERVO.Set(DirectionServo,2000)
waitcnt(clkfreq << 2 + cnt)
Comments
How do i convert the BS2's 500 to 1000 servo pulses 750 being center to servo32 servo pulses.
Servo32 seams to use higher numbers (i am assuming this is because of the propellers 5mhz external clock).
Thank you
BS2.Start(31,30)
I need to change that. I keep having to point this out.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters
Southern Illinois University Carbondale, Electronic Systems Technologies
Would still like to know how to convert BS2 timing into Servo32 timing.
Thank you
BS2_Functions and the BS2 only have a resolution of 2uS, so a value of 500 really means 1000uS.
So, your range of values instead of being 500 to 1000 (750 center/stop) would be 1000 to 2000, (1500 center/stop).
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters
Southern Illinois University Carbondale, Electronic Systems Technologies
Thank you
Post Edited (computer guy) : 3/12/2007 8:51:49 PM GMT
like waitcnt(2*clkfreq + cnt) for the 100s
and waitcnt(4*clkfreq + cnt) for the 200s
the main cog is likely finishing the program before the servos move, think of it as more of a servo controller that you set only when you need to change the servo position or direction in the case of continuous rotation ones
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
I tested this code, it works, you never stated what exactly you were trying to make it do, I made it so one servo moves back and forth and the other spins in one direction, each pause for a second between.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
SpeedServo at 1ms moves full speed forward and at 2ms full speed backward.
DirectionServo sets the direction so 1ms is full left and 2ms is full right.
So what my program was meant to do was for 200 pulses go forward at half speed.
for 100 pulses turn full left at full speed.
for 200 pulses go forward at half speed.
for 100 pulses turn full right at full speed.
and then repeat (i havent gotten to doing this part yet).
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
So would i put:
and
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
but it still only moves both servo's once.
Any idea.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Please explain.
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
I didn't realize what a big difference indentation made, will have to look out for that next time.
Is working great now.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
This is one of the most useful and innovative feature I have ever seen in a structured
programming editor!
Thank you