ok im new to this. so this is what i want 2 do. i want to controle the brat with the ps2 ex. forward moves forward back moves back x getup from back and so on. i got the brat ssc-32 and bb2 with atom pro 28 i have got all that working and can get it to walk with the programs form the sequencer exported to basic. now i would like to take all my sequence and combind them in one program and call the movements by the ps2 how would i go about doing that
thanks for any help
It might help, if we saw what you had so far. It might be real easy to add in the additional code for the PS2 if you already have the code that actually does the walking…
Alternatively: another approach might be starting with the TV Brat code that is in a couple of sticky posts under biped. It was originally written by Nathan(Acidtech) of Basic Micro. The cod in here relies on using an IRPD to read in commands from a TV remote instead of a PS2. It also does not require an SSC-32. I would delete the TV remote code and extract the PS2 code from another program such as the code used in Xans Phoenix code and then change the if then else checks to check for the different buttons being pressed. Not sure if this makes sense?
Kurt
all of that makes sence thats kinda what i was looking for just didnt know where to look i have all my code that makes the bot walk get up from laying down ect. but i do not have them in one program so guess i need to take a step back and put them in a basic atom program first then move on to the ps2 part thanks and ill be back when i have got that done
any advice on how to put all my exports from the sequencer in one basic atom code/program
The TV remote BRAT code already has all of the basic moves in it.
Here is the code he needs to “CALL” the various sequences. I have not ever used the PS2 controller, but what ever the controller ouputs when the stick is moved, the sequence player can play the appropriate index number.
[code]
;--------------------------------------------------------------------------
If temp(1) = 191 then
seqIndex = 2 ; Move right
Gosub PlaySeq
;--------------------------------------------------------------------------
PlaySeq
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout p15,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout p15,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
return [/code]
think i found a way to use the steps of a exsisting project in a new project
ok i have started my “mybot” project and i have found a way to import steps to a new sequence from one i already made this is how
open sequencer
select mybot prject from list in lower left corner
select sequence number i want for new sequence
ex. sequence 2 step 1
then
open the project i want to move to the new project from the list in the lower left
ex. walk 4ward
select step 1
press “goto” button
servo positons change
then go to the project my bot from menu in lower left
select sequence 2 step 1
then press the =“overwrite button”
and step one from walk 4ward is now step one of mybot sequence 2 step 1
then repet same steps for the rest of the steps
hope you can understand my crazy talk
ok here is my code for all my moves in one program
[code] ; ------------------------------------------------------
; Lynxmotion Visual Sequencer SSC-32 ‘Export’ Program
; Sequencer SSC-32 project : mybot
; Date : 5/19/2009 8:34:01 PM
; ------------------------------------------------------
; Format : Basic Atom 24/28 IDE <= V02.2.1.1 or Pro IDE + SSC-32
; Original filename : mybot.bas
; Communication with SSC-32 : BotBoard V2 => Pin 08
; ------------------------------------------------------
Steps Wordtable $03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03C0, $0CC6, $1392, $838D, $8CB0, $881F, $881F, |
$044D, $8424, $801F, $801F, |
$0425, $0B0A, $1228, $841C, $8B1D, $881F, $881F, |
$0395, $8353, $801F, $801F, |
$0472, $0B0A, $1227, $845A, $8B1D, $881F, $881F, |
$03FA, $0CC6, $1392, $83ED, $8CB0, $881F, $881F, |
$0378, $8343, $801F, $801F, |
$0395, $0B0A, $1228, $8353, $8B1D, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$0433, $0CF4, $1382, $83DE, $801F, $801F, |
$04E0, $0BA2, $842B, $801F, $801F, |
$8498, $801F, $801F, |
$0D48, $84A7, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DA, $12B2, $83AE, $8AF3, $881F, $881F, |
$0396, $8353, $8C27, $881F, $881F, |
$033F, $001F, $001F, |
$0329, $8AA6, $881F, $881F, |
$03DC, $1392, $83DC, $8BE8, $881F, $881F, |
$02EB, $0BDD, $1366, $827A, $8BA8, $881F, $881F, |
$0322, $001F, $001F, |
$02EB, $001F, $001F, |
$02EB, $0001, $001F, |
$81EF, $8A23, $881F, $881F, |
$827A, $8BA8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $0871, $10DD, $82E6, $8856, $881F, $881F, |
$0E7E, $081F, $081F, |
$03CF, $0F27, $1360, $83A0, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $09A7, $1535, $83DE, $8EA0, $881F, $881F, |
$0BE8, $8BE8, $881F, $881F, |
$03DC, $1392, $83DC, $801F, $801F, |
$83DC, $8001, $801F
SeqPos Wordtable $0000, |
$0007, |
$001D, |
$0036, |
$0055, |
$0074, |
$0093, |
$00B1, |
$00CB
SSC32 con p8
SeqIndex var Word
Index var Word
LastServo var Byte
TmpServo var Byte
TmpValue var Word
DejaVu var bit
LastServo = 99
DejaVu = 0
pause 500
Main
For SeqIndex = 0 to 7
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout SSC32,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout SSC32,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
next
goto Main[/code]
Here is a tutorial for programming the BAP to use the PS2 controller.
lynxmotion.com/images/html/build034.htm
Using the tutorial, I would try running the program and see how things work when you press the buttons. You will need to convert the values of temp(19) in to index numbers to call your various sequence moves. for example, looking at the table 2-1, Right Dpad pressed = 191 so you will need to convert 191 to = seqIndex #2 where #2 is the turn right sequence, then, you can run the seqPlayer routine to play seqIndex #2. See the code example a few posts up. I made some changes to it to show you what I am taking about. Hope this helps.
ok i think i understand so this part is what i need to call my sequences with
the ps2
If temp(1) = 191 then
seqIndex = 2 ; Move right
Gosub PlaySeq
and make one to match each of my buttons and seqindex’s
and i would put them in my code like this
[code]
If temp(1) = 191 then
seqIndex = 2 ; Move right
Gosub PlaySeq
PlaySeq
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout SSC32,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout SSC32,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
next
goto Main [/code]
am i correct
and thanks again for the help
Yes that is correct.
ok cool i will try my hand at it tonight wish me luck
ok i forgot to ask this
do i need any statments or santax inbetween these
just an ex. [code]
If temp(1) = 235 then
seqIndex = 0 ; Move left
Gosub PlaySeq
If temp(1) = 191 then
seqIndex = 1 ; Move right
Gosub PlaySeq [/code]
or do i need an else statment or somthing in there
What you have will work except you need an endif before the second if, or you might try:
if temp(1) = 235 then
seqIndex=0; Move Left
Gosub PlaySeq
elseif temp(1) = 191
SeqIndex=1
...
endif
or better yet, you could add a parameter to your call to PlaySeq and then the code could look something like:
SEQLeft con 0
SEQRight con 1
...
if temp(1) = 235 then
gosub PlaySeq[SEQLeft]
elseif temp(1) = 191
gosub playSeq[SEQRight]
...
endif
...
PlaySeq[seqIndex]
(the current subrouting)
Have fun!!!
Kurt
ok so elseif is what i need for all of the indexes im calling minus the first
and at the end i need a endif
Thats right. You could use a lookup table but for starters stick with this.
ok thanks for all the help i will try it out tonight and let you all know how it gose
next on my list is to get more servos and brakets and make a robo one style humanoid
ok i gott home and did what i thought was what i needed to do but got
an error when debuggin
Error: FILE C:\PROGRAM FILES\SEQUENCER_SSC-32\MYBOT.BAS(LINE 74) : [TOKEN (] : Unexpected token type
here is my code
[code]
; ------------------------------------------------------
; Lynxmotion Visual Sequencer SSC-32 ‘Export’ Program
; Sequencer SSC-32 project : mybot
; Date : 5/19/2009 8:34:01 PM
; ------------------------------------------------------
; Format : Basic Atom 24/28 IDE <= V02.2.1.1 or Pro IDE + SSC-32
; Original filename : mybot.bas
; Communication with SSC-32 : BotBoard V2 => Pin 08
; ------------------------------------------------------
Steps Wordtable $03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03C0, $0CC6, $1392, $838D, $8CB0, $881F, $881F, |
$044D, $8424, $801F, $801F, |
$0425, $0B0A, $1228, $841C, $8B1D, $881F, $881F, |
$0395, $8353, $801F, $801F, |
$0472, $0B0A, $1227, $845A, $8B1D, $881F, $881F, |
$03FA, $0CC6, $1392, $83ED, $8CB0, $881F, $881F, |
$0378, $8343, $801F, $801F, |
$0395, $0B0A, $1228, $8353, $8B1D, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$0433, $0CF4, $1382, $83DE, $801F, $801F, |
$04E0, $0BA2, $842B, $801F, $801F, |
$8498, $801F, $801F, |
$0D48, $84A7, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DA, $12B2, $83AE, $8AF3, $881F, $881F, |
$0396, $8353, $8C27, $881F, $881F, |
$033F, $001F, $001F, |
$0329, $8AA6, $881F, $881F, |
$03DC, $1392, $83DC, $8BE8, $881F, $881F, |
$02EB, $0BDD, $1366, $827A, $8BA8, $881F, $881F, |
$0322, $001F, $001F, |
$02EB, $001F, $001F, |
$02EB, $0001, $001F, |
$81EF, $8A23, $881F, $881F, |
$827A, $8BA8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $0871, $10DD, $82E6, $8856, $881F, $881F, |
$0E7E, $081F, $081F, |
$03CF, $0F27, $1360, $83A0, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $09A7, $1535, $83DE, $8EA0, $881F, $881F, |
$0BE8, $8BE8, $881F, $881F, |
$03DC, $1392, $83DC, $801F, $801F, |
$83DC, $8001, $801F
SeqPos Wordtable $0000, |
$0007, |
$001D, |
$0036, |
$0055, |
$0074, |
$0093, |
$00B1, |
$00CB
SSC32 con p8
SeqIndex var Word
Index var Word
LastServo var Byte
TmpServo var Byte
TmpValue var Word
DejaVu var bit
LastServo = 99
DejaVu = 0
pause 500
If temp(1) = 247 then
seqIndex = 0 ; rest home
Gosub PlaySeq
elseIf temp(1) = 239 then
seqIndex = 1 ; Move forward
Gosub PlaySeq
elseIf temp(1) = 191 then
seqIndex = 2 ; Move back
Gosub PlaySeq
elseIf temp(1) = 127 then
seqIndex = 3 ; Move left
Gosub PlaySeq
elseIf temp(1) = 223 then
seqIndex = 4 ; Move right
Gosub PlaySeq
endif
PlaySeq
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout SSC32,i38400,"T", DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout SSC32,i38400,"#", DEC TmpServo, "P", DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
next
goto Main [/code]
what am i missing or did i do wrong
thanks again for the help
As far as I can tell the variable temp is not defined. If you double click on the error message it will take you to the error line.
My assumption was that this is some array. Also I assume this is a code fragment as I don’t see anything actually setting this value.
Kurt
when i double click it it takes me here
If temp(1) = 247 then
seqIndex = 0 ; rest home
Gosub PlaySeq
how do define it or what code am i missing
how do i set the value
im sorry im a newb to basic code
Hi, I did a quick and dirty of merging in some PS2 code that was in the powerpod. I extracted all of the hex code out of it. I left a bunch of ifs or elseifs that are not needed, but it more or less defines all of the PS2 buttons. You should comment out all of the ones you don’t use. (put a ; at the start of the lines).
I arbitrarily added calls to your sequences on some of the buttons, which obviously you can/should change. Also you may wish to use some of the joystick inputs on the PS2 to do the walking. I left in some of the lines of code associated with this. For example I left in some code that did some slop for the center of the joysticks. I also left in commented lines showing how the analog value can be used.
The code compiled, but I did not try running as I don’t have the hardware setup in this configuration…
Kurt
[code]; ------------------------------------------------------
; Lynxmotion Visual Sequencer SSC-32 ‘Export’ Program
; Sequencer SSC-32 project : mybot
; Date : 5/19/2009 8:34:01 PM
; ------------------------------------------------------
; Format : Basic Atom 24/28 IDE <= V02.2.1.1 or Pro IDE + SSC-32
; Original filename : mybot.bas
; Communication with SSC-32 : BotBoard V2 => Pin 08
; ------------------------------------------------------
Steps Wordtable $03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03C0, $0CC6, $1392, $838D, $8CB0, $881F, $881F, |
$044D, $8424, $801F, $801F, |
$0425, $0B0A, $1228, $841C, $8B1D, $881F, $881F, |
$0395, $8353, $801F, $801F, |
$0472, $0B0A, $1227, $845A, $8B1D, $881F, $881F, |
$03FA, $0CC6, $1392, $83ED, $8CB0, $881F, $881F, |
$0378, $8343, $801F, $801F, |
$0395, $0B0A, $1228, $8353, $8B1D, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$0433, $0CF4, $1382, $83DE, $801F, $801F, |
$04E0, $0BA2, $842B, $801F, $801F, |
$8498, $801F, $801F, |
$0D48, $84A7, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DA, $12B2, $83AE, $8AF3, $881F, $881F, |
$0396, $8353, $8C27, $881F, $881F, |
$033F, $001F, $001F, |
$0329, $8AA6, $881F, $881F, |
$03DC, $1392, $83DC, $8BE8, $881F, $881F, |
$02EB, $0BDD, $1366, $827A, $8BA8, $881F, $881F, |
$0322, $001F, $001F, |
$02EB, $001F, $001F, |
$02EB, $0001, $001F, |
$81EF, $8A23, $881F, $881F, |
$827A, $8BA8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $0871, $10DD, $82E6, $8856, $881F, $881F, |
$0E7E, $081F, $081F, |
$03CF, $0F27, $1360, $83A0, $801F, $801F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DC, $0BE8, $1392, $83DC, $8BE8, $881F, $881F, |
$03DE, $09A7, $1535, $83DE, $8EA0, $881F, $881F, |
$0BE8, $8BE8, $881F, $881F, |
$03DC, $1392, $83DC, $801F, $801F, |
$83DC, $8001, $801F
SeqPos Wordtable $0000, |
$0007, |
$001D, |
$0036, |
$0055, |
$0074, |
$0093, |
$00B1, |
$00CB
SSC32 con p8
;PS2 Controller / BotBoard II (PS2 controller => pin 12, 13, 14, 15)
DAT con P12
CMD con P13
SEL con P14
CLK con P15
DeadZone con 28
PadMode con $79
;-------------Variables
DualShock var Byte(7)
DS2Mode var Byte
LastButton var Byte(2)
SeqIndex var Word
Index var Word
LastServo var Byte
TmpServo var Byte
TmpValue var Word
DejaVu var bit
LastServo = 99
DejaVu = 0
;-------------------------------------------------------------------------------------
; Main Loop
Main:
;-------------------------------------------------------------------------------------
; Query the current state of the PS2 buttons.
;Ps2Query
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8]
shiftin DAT,CLK,FASTLSBPOST,[DS2Mode\8]
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]
shiftin DAT,CLK,FASTLSBPOST,[DualShock(0)\8, DualShock(1)\8, DualShock(2)\8, DualShock(3)\8, |
DualShock(4)\8, DualShock(5)\8, DualShock(6)\8]
high SEL
pause 1
if DS2Mode <> PadMode then
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTER
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET_MODE_AND_LOCK
high SEL
pause 1
;low SEL
;shiftout CMD,CLK,FASTLSBPRE,$01\8,$4D\8,$00\8,$00\8,$01\8,$FF\8,$FF\8,$FF\8,$FF\8] ;VIBRATION_ENABLE
;high SEL
;pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODE
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVE
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG_MODE_EXIT
high SEL
pause 288
goto main
endif
;------------------------------------------------------------------------------------------------------------
; Now process the new PS2 input.
if (DualShock(2).bit3 = 0) and LastButton(1).bit3 then ;R1 Button test
;
elseif (DualShock(2).bit2 = 0) and LastButton(1).bit2 ;L1 Button test
;
elseif (DualShock(2).bit1 = 0) and LastButton(1).bit1 ;R2 Button test
;
elseif (DualShock(2).bit0 = 0) and LastButton(1).bit0 ;L2 Button test
elseif (DualShock(2).bit4 = 0) and LastButton(1).bit4 ;Triangle Button test
elseif (DualShock(2).bit6 = 0) and LastButton(1).bit6 ;Cross Button test
elseif (DualShock(2).bit7 = 0) and LastButton(1).bit7 ;Square Button test
elseif (DualShock(1).bit0 = 0) and LastButton(0).bit0 ;Select Button test
elseif (DualShock(1).bit3 = 0) and LastButton(0).bit3 ;Start Button test
seqIndex = 0 ; rest home
Gosub PlaySeq
elseif (DualShock(1).bit1 = 0) and LastButton(0).bit1 ;L3 Button test
elseif (DualShock(1).bit2 = 0) and LastButton(0).bit2 ;R3 Button test (Horn)
elseif (DualShock(1).bit4 = 0) and LastButton(0).bit4 ;Up Button test
seqIndex = 1 ; Move forward
Gosub PlaySeq
elseif (DualShock(1).bit6 = 0) and LastButton(0).bit6 ;Down Button test
seqIndex = 2 ; Move back
Gosub PlaySeq
elseif (DualShock(1).bit5 = 0) and LastButton(0).bit5 ;Right Button test
seqIndex = 4 ; Move right
Gosub PlaySeq
elseif (DualShock(1).bit7 = 0) and LastButton(0).bit7 ;Left Button test
seqIndex = 3 ; Move left
Gosub PlaySeq
else
; maybe process the 4 analog values from two joysticks
for Index = 3 to 6
if DualShock(Index) > (128 + DeadZone) then
DualShock(Index) = DualShock(Index) - DeadZone/2
elseif DualShock(Index) < (128 - DeadZone)
DualShock(Index) = DualShock(Index) + DeadZone/2
else
DualShock(Index) = 128
endif
next
;YSpeed = DualShock(3) - 128 ; Right Stick Horizontal
;XSpeed = DualShock(4) - 128 ; Right Stick Vertical
;Steering = DualShock(5) - 128 ; Left Stick Horizontal
;Height = LastHeight + (((DualShock(6) - 128) / 5) - LastHeight) / StepFlag; Left Stick Vertical
endif
LastButton(0) = DualShock(1)
LastButton(1) = DualShock(2)
goto main
PlaySeq:
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout SSC32,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout SSC32,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
return
[/code]