Stopping Servo32 object. and powering down the servos.
Dgswaner
Posts: 795
when my bot is in IR Remote mode, there is no need to have the servos on and holding a position. I tried adding a cogstop(CogID) line to the Servo object when 9999 was sent as the Width. SERVO.Set(PanServo,9999). but this didn't seem to have the desired effect.
here is what I used.
I even tried a version where I made the pins go low, but it still didn't work. is there a way to stop this object?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
here is what I used.
PUB Set(Pin, Width) 'Set Servo value If width == 9999 stopcog(cogid) else Width := 1000 #> Width <# 2000 'limit Width value between 1000uS and 2000uS Pin := 0 #> Pin <# 31 'limit Pin value between 0 and 31 ServoData[noparse][[/noparse]Pin] := (clkfreq / _1uS * Width) 'calculate # of clocks for a specific Pulse Width dira[noparse][[/noparse]Pin] := 1 'set selected servo pin as an OUTPUT ServoPinDirection := dira 'Read I/O state of ALL pins
I even tried a version where I made the pins go low, but it still didn't work. is there a way to stop this object?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Comments
You have to modify the Start method of Servo32, add a long variable called "cogNo" to the VAR section at the beginning, add "cogNo :=" just in front of the COGNEW in the Start method so you'll save the cog #, then use "IF cogNo => 0" followed by "COGSTOP( cogNo )" in your Set method.
cog 0: running main control loop
cog 1: servo handler
if the code Cog 1 is running executes a COGID command it would return 0?
I have no doubt that your right, but reading the manual made me thing it would return 1. and therefor work. I have a lot to learn!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
COGNEW returns the number of the cog that's started or -1 if there are no cogs available.
Thanks for your help. and patience
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner