Servo Controller Board problems
neuromit
Posts: 7
I've been trying to go through the Servo Controller Manual, to control multiple servos at the same time.
I'm starting with one servo and when I figure that one out I'll move to the others...
I've tried running the code in the manual that lets you get the Baud Rate of your PSC
But when I try to compile I get: Error: Can't create (null). I can't find any documentation about what this means....
Not getting the baud rate really isn't my problem but when I try to switch between two servo positions and then query the servo location the servo just stays in one place:
Here is the code:
My output is: Running Loop followed with 1, I never see 2
ALso I never get output that says were my servo is....
I'm really confused... I know I'm probably doing this wrong but I don't know why...
I'm starting with one servo and when I figure that one out I'll move to the others...
I've tried running the code in the manual that lets you get the Baud Rate of your PSC
' {$STAMP BS2} ' {$PBASIC 2.5} Sdat PIN 15 ' Serial Data I/O pin Baud CON 396 ' Constant for 2400 baud buff VAR Byte(3) ' temporary variable FindPSC: DEBUG "Finding PSC", CR ' number of the PSC. SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCVER?",CR] SERIN Sdat, Baud, 500, FindPSC , [noparse][[/noparse]STR buff\3] DEBUG "PSC ver: ", buff(0), buff(1), buff(2), CR GOSUB FindPSC
But when I try to compile I get: Error: Can't create (null). I can't find any documentation about what this means....
Not getting the baud rate really isn't my problem but when I try to switch between two servo positions and then query the servo location the servo just stays in one place:
Here is the code:
' {$STAMP BS2} ' {$PBASIC 2.5} ch VAR Byte pw VAR Word ra VAR Byte x VAR Byte Buff VAR Byte(3) Sdat CON 15 baud CON 396 Init: ra = 15: ch = 0 DO DEBUG "Running Loop", CR pw = 1240 DEBUG "1 " SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] FOR x = 0 TO 4 PAUSE 1000 SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR] SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3] DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR NEXT pw = 260 DEBUG "2", CR SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] FOR x = 0 TO 4 PAUSE 1000 SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR] SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3] DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR NEXT LOOP
My output is: Running Loop followed with 1, I never see 2
ALso I never get output that says were my servo is....
I'm really confused... I know I'm probably doing this wrong but I don't know why...
Comments
Program 2: looks OK. If you never get past 'debug "1"' then the program is probably timing out while waiting on the SERIN, or the program is resetting.
Try the obvious first -- do you have enough power for the servos and the stamp? Do you have the jumper on the PSC set so that it responds to channels 0-15? Connection good between your Sdat stamp pin and the PSC serial pin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Here is the output:
I'm pretty sure the PSC is connected to the Board of Education correctly b/c everytime a new "Finding PSC" shows up I get a blink from a green LED on the PSC...
Also I know that the board is powered correctly as I have a 9v battery powering the BOE. I know that the Servos have 6V as I'm using a really high end powersupply to power the servos (its way overkill to use this power supply but I won't get into why i'm using it)....
Try this and see if you get a response.
This should keep printing "finding psc" if it can't communicate with the psc, otherwise it should print the psc firmware revision number and stop.
Also try to hitting the reset button on the PSC after powerup.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
If Zoot's suggestion fails as well, try this:
Debug "Starting"
FindPSC: ' Find and get the version
DEBUG "Finding PSC", CR ' number of the PSC.
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCVER?",CR]
SERIN Sdat, Baud, 500, FindPSC, [noparse][[/noparse]STR buff\3]
DEBUG "PSC ver: ", buff(0), buff(1), buff(2), CR
goto FindPSC
If "Starting" appears more than once, something is resetting the Stamp.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
when I run the code posted by bruce, i get:
So does this mean the PSC could be bad?
Could this be a baud rate issue?
The last thing I would suspect would be a bad PSC. I don't know much about that but if they can be "strapped" for baud rate, make sure it is strapped correctly.
Next to that I'd double check the wiring. Make sure Tx goes to Rx and Rx goes to Tx.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
(Bruce --·there is only one data connection to a PSC -- serial i/o. Baud rate is changed via serial commands -- default 2400)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php