Servo32 behaving unexpectedly
Jay Kickliter
Posts: 446
I have two servos connected to a PPDB. They're powered from VDD.
The strange thing is that only the first servo I set actually gets activated. Unplugging them and hooking up the signal lines to LEDs confirms that only the first servo set is receivng a signal, any after that are inactive. If I comment out the first servo.set(), then the next servo does get a signal. I've tried all the normal swapping and ohming troubleshooting, but I can't find anything.
The servo32 object seems pretty straight forward, but here's my code:
Anybody see anything?
The strange thing is that only the first servo I set actually gets activated. Unplugging them and hooking up the signal lines to LEDs confirms that only the first servo set is receivng a signal, any after that are inactive. If I comment out the first servo.set(), then the next servo does get a signal. I've tried all the normal swapping and ohming troubleshooting, but I can't find anything.
The servo32 object seems pretty straight forward, but here's my code:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 'Note Clock Speed for your setup!! CR = $0D LF = $0A PAN_SERVO = 12 TILT_SERVO = 14 VAR word servoPanSetPoint, servoTiltSetPoint byte rxByte, packetBuffer[noparse][[/noparse]20], validPacket OBJ servo : "Servo32v3" serial : "FullDuplexSerial" PUB main | i, temp serial.start(31, 30, 0, 9600) servo.start servoPanSetPoint := 1100 servoTiltSetPoint := 1900 validPacket := 0 servo.set(PAN_SERVO, servoPanSetPoint) servo.set(TILT_SERVO, servoTiltSetPoint) repeat if validPacket serial.str(string("Setting pan to: ")) serial.dec(servoPanSetPoint) serial.str(string(" and tilt to: ")) serial.dec(servoTiltSetPoint) serial.tx(CR) servo.set(PAN_SERVO, servoPanSetPoint) servo.set(TILT_SERVO, servoTiltSetPoint) i := 0 temp := 0 repeat until serial.rx == "@" repeat until (rxByte := serial.rx) == "," temp := temp * 10 + (rxByte - "0") servoPanSetPoint := 1000 #> temp <# 2000 temp := 0 repeat until (rxByte := serial.rx) == 13 or rxByte == 10 temp := temp * 10 + (rxByte - "0") servoTiltSetPoint := 1000 #> temp <# 2000 validPacket := 1
Anybody see anything?
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
To initialize the servo32 object, you need to initialize "servo.set" before you initialize "servo.start"...· This is a safety feature that presets the servo position to a known state, and tells the servo object which pins will be used for the servo(s).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.