servo control --stamp selection
Hello,
·I'm new to microcontrollers. I am building a·controller to control 5 servos for an apparatus··using two joysticks (2Xpotentiometers per joystick). I'm using a switch to toggle one of the joysticks between servo·motors (i.e joy1 controls either servo #1 or #2&3, Joy2 always controlls Servos 4&5). I am sending serial outputs to a 16 channel Parallax servo controller.
I have 3 devices with 5 servos each, and I will be switching the controller between each device (total of 15 servos). Currently, using a BS2, I have one·joystick controlling·two servos using RCtime and it seems to work well.
·My problem is that I don't have enough variables left to do what I want. Would it be better to utilize two BS2s or move to a different microcontroller such as a Javelin--I have a little bit of Java experience, but I'm not a programer.
·Thanks,
·Brent
·I'm new to microcontrollers. I am building a·controller to control 5 servos for an apparatus··using two joysticks (2Xpotentiometers per joystick). I'm using a switch to toggle one of the joysticks between servo·motors (i.e joy1 controls either servo #1 or #2&3, Joy2 always controlls Servos 4&5). I am sending serial outputs to a 16 channel Parallax servo controller.
I have 3 devices with 5 servos each, and I will be switching the controller between each device (total of 15 servos). Currently, using a BS2, I have one·joystick controlling·two servos using RCtime and it seems to work well.
·My problem is that I don't have enough variables left to do what I want. Would it be better to utilize two BS2s or move to a different microcontroller such as a Javelin--I have a little bit of Java experience, but I'm not a programer.
·Thanks,
·Brent
Comments
-Phil
thanks for the help
'
[noparse][[/noparse]I/O Definitions]
PotCw·· PIN· 0·· 'cw clock input
PotCCW· PIN 1·· 'ccw pot input
PotCw2· PIN· 2·· 'cw clock input
PotCCW2 PIN 3·· 'ccw pot input
PotCw3· PIN· 4·· 'cw clock input
PotCCW3 PIN 5·· 'ccw pot input
PotCw4· PIN· 6·· 'cw clock input
PotCCW4 PIN 7·· 'ccw pot input
'
[noparse][[/noparse]Constants]
Scale· CON $0068 ' to scale rc time value
'
[noparse][[/noparse]Variables]
'
Joy1-POT1
rcRt· VAR Word·· 'rc reading right
rcLf· VAR Word·· 'rc reading left
sPos· VAR Word·· 'servo position
pw··· VAR Word·· 'serial out servo position
ch··· VAR Byte·· 'servo channel on servo controller --serial out
ra··· VAR Byte·· 'servo rapping speed --serial out
·'
POT2
rcRt2· VAR Word·· 'rc reading right
rcLf2· VAR Word·· 'rc reading left
sPos2· VAR Word·· 'servo position
pw2··· VAR Word·· 'serial out servo position
ch2··· VAR Byte·· 'servo channel on servo controller --serial out
ra2··· VAR Byte·· 'servo rapping speed --serial out
'
JOY2--POT3
rcRt3· VAR Word·· 'rc reading right
rcLf3· VAR Word·· 'rc reading left
sPos3· VAR Word·· 'servo position
pw3··· VAR Word·· 'serial out servo position
ch3··· VAR Byte·· 'servo channel on servo controller --serial out
ra3··· VAR Byte·· 'servo rapping speed --serial out
'
POT4
rcRt4· VAR Word·· 'rc reading right
rcLf4· VAR Word·· 'rc reading left
sPos4· VAR Word·· 'servo position
pw4··· VAR Word·· 'serial out servo position
ch4··· VAR Byte·· 'servo channel on servo controller --serial out
ra4··· VAR Byte·· 'servo rapping speed --serial out
Ch_INI VAR Byte
'
[noparse][[/noparse]CONSTANTS]
sDat· CON 15·· 'output pin for serial out
baud· CON 396
'
[noparse][[/noparse]Initialization]
initialize:··········· 'send stop pulse all 16 servo channels to prevent wandering
ra = 0
pw = 744
FOR Ch_INI = 0 TO 15
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", Ch_INI, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
NEXT
GOTO Main
END
'
[noparse][[/noparse]Program Code]
·Main:
·ra = 0
·ra2 = 0········· 'set servo rampping rate
·ch = 0········· 'set servo channel on servo control board
·ch2 = 1
·ra3 = 0
·ra4 = 0········· 'set servo rampping rate
·ch3 = 0········· 'set servo channel on servo control board
·ch4 = 1
· HIGH PotCW
· PAUSE 1
· RCTIME PotCW, 1, rcRt
· HIGH PotCCW
· PAUSE 1
· RCTIME PotCCW, 1, rcLf
· HIGH PotCW2
· PAUSE 1
· RCTIME PotCW2, 1, rcRt2
· HIGH PotCCW2
· PAUSE 1
· RCTIME PotCCW2, 1, rcLf2
· HIGH PotCW3
· PAUSE 1
· RCTIME PotCW3, 1, rcRt3
· HIGH PotCCW4
· PAUSE 1
· RCTIME PotCCW4, 1, rcLf4
· rcRt = (rcRt */Scale)· MAX 700
· rcLf = (rcLf */ Scale)· MAX 700
· sPOS = RCLf - rcRt
· rcRt2 = (rcRt2 */Scale)· MAX 700
· rcLf2 = (rcLf2 */ Scale)· MAX 700
· sPOS2 = RCLf2 - rcRt2
· rcRt3 = (rcRt3 */Scale)· MAX 700
· rcLf3 = (rcLf3 */ Scale)· MAX 700
· sPOS3 = RCLf3 - rcRt3
· rcRt4 = (rcRt4 */Scale)· MAX 700
· rcLf4 = (rcLf4 */ Scale)· MAX 700
· sPOS4 = RCLf4 - rcRt4
· pw = 777 + spos
· pw2 = 747 + spos2
· pw3 = 777 + spos3
· pw4 = 747 + spos4
· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
· PAUSE·· 20
· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch2, ra2, pw2.LOWBYTE, pw2.HIGHBYTE, CR]
· PAUSE·· 20
· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch3, ra3, pw3.LOWBYTE, pw3.HIGHBYTE, CR]
· PAUSE·· 20
· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch4, ra4, pw4.LOWBYTE, pw4· .HIGHBYTE, CR]
· PAUSE·· 20
· GOTO Main
to store variables. You then use GET/PUT to retrieve/store values from/to the scratchpad.
The BS2SX, like the BS2, only has 26 bytes of named variables.
The javelin has a total ram of 32 kilobyte, that is for code + variables.
You say you have a little java experience. Javelin java is much simpler
than PC java so you should be able to program the javelin in no time.
regards peter