Problem: prop chip controlling servo using servo32 obj
seadog13
Posts: 9
hey all, ran into a really weird problem with the servo32 object. We have eliminated a lot of our code to take it out of the equation. For some reason when we add a simple line of code setting a variable to 0, the servo quits working. If we have 3 variables the servo runs fine, if we put a fourth variable in the servo will not work. Not sure why this is happening. Below is a copy of our code. If we add any other variable the servo does not work.
This could be related to timing or memory, But have no reason why just adding a simple (variable := 0) will make the servo object quit working....
Any thoughts or suggestions are appreciated
thanks in advance
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
RUDDER = 1 'Servo Rudder pin
VAR
long theta,hbx,hby,tiltx,tilty,temp,temp2,thetafix,thetatemp
OBJ
HM55B : "HM55B Compass Module Asm"
acc : "memsic2125"
Debug : "FullDuplexSerialPlus"
SERVO : "Servo32v3"
MATH : "Float32Full"
PUB MAIN | thetanew
SERVO.Start 'Start Servo handler
repeat
tilty := 0
HBX := 0
HBY := 0
'tiltx := 0
'ThetaTemp:= 0 'Reset values to Zero
'Theta := 0
'thetafix := 0
'temp := 0
SERVO.Set(rudder,1250)
waitcnt(clkfreq*4 + cnt)
SERVO.Set(rudder,1750)
waitcnt(clkfreq*4 + cnt)
This could be related to timing or memory, But have no reason why just adding a simple (variable := 0) will make the servo object quit working....
Any thoughts or suggestions are appreciated
thanks in advance
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
RUDDER = 1 'Servo Rudder pin
VAR
long theta,hbx,hby,tiltx,tilty,temp,temp2,thetafix,thetatemp
OBJ
HM55B : "HM55B Compass Module Asm"
acc : "memsic2125"
Debug : "FullDuplexSerialPlus"
SERVO : "Servo32v3"
MATH : "Float32Full"
PUB MAIN | thetanew
SERVO.Start 'Start Servo handler
repeat
tilty := 0
HBX := 0
HBY := 0
'tiltx := 0
'ThetaTemp:= 0 'Reset values to Zero
'Theta := 0
'thetafix := 0
'temp := 0
SERVO.Set(rudder,1250)
waitcnt(clkfreq*4 + cnt)
SERVO.Set(rudder,1750)
waitcnt(clkfreq*4 + cnt)
Comments
In order for the servo32 object to work properly you need to 'set' an initial·servo position before you 'start' the servo handler.· This is by design so that the servo32 object knows what pins will be used, and that the servo starts up in a known or valid position.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Below is working code that issues the Servo.Set command before the Servo.Init, as Beau mentioned.
I also attached a photo of my breadboard used with this code and the SPIN code in a ZIP file for reference.