Need a lil help brat with ssc-32 bb2 atom 28 pro and ps2

sorry im such a newb
and sorry for the long post
ok i got some code to debug and program
but its not right nothing happens when i use the controler
the analog light comes on the goes back off
i can push it again and it will stay on but neither way works
i tried the ps2 controller program for the motors but i can not connect to the controller in the terminal 1 tab in the tut it wants it on com1 but my bb2 is on com6 (usb adapter) and the only com it will let me select in the tab is com3 so im not shore whats going on there ether the controller
is a sony ps2 controller and works on a ps2 console

but for my brat ps2 program i have no clue about coding so i tried my best
to copy and paste and change things and write code and finaly got it to debug without error
so here is the 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

;ps2 controler / botboard II
dat con p12
cmd con p13
sel con p14
clk con p15
SSC32 con p8

index var byte
temp var byte(19)
mode var byte
SeqIndex var word
LastServo var word
TmpServo var word
TmpValue var word
DejaVu var word

;ps2init
high clk

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 100

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,$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,$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 1

main

;-----------PS2 Mode----------
low SEL
; asking “mode” to PS2 controller
shiftout CMD,CLK,FASTLSBPRE,$1\8]
; reading “mode” from PS2 controller
; 73(hex) is dualshock1 (digital buttons)
; 79(hex) is dualshock2 (analog buttons)
shiftin DAT,CLK,FASTLSBPOST,[mode\8]
high SEL
;-----------------------------

;pause 1

;-----------PS2 Data----------
low SEL
; asking data to PS2 controller
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]
; reading data from controller
; (don’t use a “for-next” loop, it’s too slow to read PS2 data)
shiftin DAT,CLK,FASTLSBPOST,[temp(0)\8,temp(1)\8,temp(2)\8,temp(3)\8,temp(4)\8,temp(5)\8,temp(6)\8,temp(7)\8,temp(8)\8, |
temp(9)\8,temp(10)\8,temp(11)\8,temp(12)\8,temp(13)\8,temp(14)\8,temp(15)\8,temp(16)\8,temp(17)\8,temp(18)\8]
high SEL
;-----------------------------

LastServo = 99
DejaVu = 0

pause 500

If temp(1) = 247 then
seqIndex = 0 ; rest home
Gosub PlaySeq

if temp(1) = 239 then
seqIndex = 1 ; Move forward
Gosub PlaySeq

If temp(1) = 191 then
seqIndex = 2 ; Move back
Gosub PlaySeq

If temp(1) = 127 then
seqIndex = 3 ; Move left
Gosub PlaySeq

If temp(1) = 223 then
seqIndex = 4 ; Move right
Gosub PlaySeq

endif
endif
endif
endif
endif

PlaySeq
for index = 1 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]

OK im sorry i missed your last post i will try that now but i would still like to know about my last code i posted if possible. its prolly all wrong but maybe a good try for not knowing what i was doing and i thank you very much for taking the time to do all of that work for me

update i got your code working finally i had to move my ps2 adapter to the
12-15 i/o pins and connect the green wire to the vs pin
and put my jumpers back on the dt,cm,at pins

wow what a night
thanks again for that man
i love how helpful everyone here is
maybe one day i will know enough to help out like you guys :laughing: :smiley:

and im guessing my code was noware near in the ball park

EDIT>>

I missed that you got Kurte’s code to work. Good Job! Kurte has some tips regarding your code below --------V

Good to hear you got it going! :smiley: Yes there are a lot of very helpful people up here, which is why I enjoy these products and these forums.
There are many contributers up here now who started out like you!

As for your previous good try, there are a few problems, which we could work through if you would like. Things like, you need to move all of your endifs to right places. Something like:

[code]
If temp(1) = 247 then
seqIndex = 0 ; rest home
Gosub PlaySeq
endif

if temp(1) = 239 then
seqIndex = 1 ; Move forward
Gosub PlaySeq
endif
…[/code]

Suggestion: When you are posting code, use the code button (once at the start of the code and once at the end of the code). This gives a fixed point font and preserves your indentation. Also it helps to indent things like stuff within ifs or for loops, etc…

Also in your PlaySeq subroutine, you have two for loops, I don’t think you need the first one (and the next that goes with it). Also at the end of this function you have a goto main, you should instead have a return statement as this is a subroutine, and the gotos would leave the calling information on the stack which would eventually cause the program to fault.

But again these are all things that you could easily fix.

So again I am glad you are up and running.

Kurt

ok i will work on my code somemore and i will ues the code button to post it next time
so for not knowing what i was doing it was a good try?

I just wanted to add that there is a PDF document well worth reading. It is only 5 pages long, and it will teach you the basics on how to be a better programmer. Kurte has provided a few tips regarding the indentations and ENDIF placement. I guarantee you when you finish reading these 5 pages, you will be so much better with your programs, and people will have a better time interpreting your code also. It’s helped me a lot. Although it talks about the Pbasic language it still covers all the basics.

parallax.com/Portals/0/Downl … cstyle.pdf

thank you i will read it when i get a chance

Can you post pictures of your brat? How’s the project going?

yea i will def post some pics and may be a vid on youtube when i get my movements down some where in all the posting and copyin code i think my steps or word table (i think thats were the steps are in basic atom code) got messed up so iv been reworking all my moves but yea i had planed on puting up some pics or vid to show you guys how much you had helped me :stuck_out_tongue:

i have been going back and forth between two projects one my brat adventure and the other modin my lil bro’s xbox 360 thats has been a real crazy one to. Put it in a pc case to say the least. :smiling_imp:

oh yea i forgot my third project just finished buildin my self a vacume table to make some sheels for the brat/humainoid project 8)

(update i got it to work)
i moved this to the sequenser section as i figuerd its a new problum and
proly fits there better

ok i thought my word table was messed up but after checking it over and over that’s not the problem with the steps. I hooked it all back up to the sequencer software and when i run it there i get the same thing. I started looking more closely to what the brat was doing. Two servos right hip (servo 18) and right knee (servo 17) are not working.
A look in the sequencer shows they are not enabled, if enable them all is well
but to no avale when ever i load up the program they still stay disabled until i go in and enable them. Ive tried redoing the servo setup but still get the same results. so my question is how do keep these servos enabled like the rest, what might i be doing wrong?

ok guys im still not realy getting the hang of coding or understanding code. below is a snipit of the code that kurte gave me.
it is the code that is for the joysticks im wondering how i can use it to call my sequences insted of the directional buttons can anybody give me some insight on how to do that

[code]; 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) [/code]

Hi Chris,

This code just simply walks through the four values that are associated with the two analog joysticks on the PS2. The for loop simply goes through to take care of the slop in most PS2 controller.

Then the old Hex code would take the four values for its own use. Each value centers on 128. ie if the value is 128 then the joystick is sitting in the center, if it is greater than 128 you are pushing it one way and if it is lower than 128 you are pushing it the other way. The farther it is away from 128 the more it is pushed.

One way to use them is something like:

if DualShock(3) > 144 then    ; Right Stick Horizontal
   SeqIndex = 3   ; turn one direction
elseif DualShock(3) < 112 
   SeqIndex = 4   ; turn one direction
elseif DualShock(4) > 144 then   ;Right stick vertical
   SeqIndex = 1   ; turn one direction
else if DualShock(4) < 112 then
   SeqIndex = 2   ; turn one direction
else
   SeqIndex = 0 ; home
endif
gosub PlaySeq

Note I did not check which direction works right or the like or how much slop to use, but this should give you an idea. The slop I used was 16 away from center which should also take care of the deadband issue

Kurt

OK that’s kinda how i thought it worked may i ask what the dual shock(3)
and dual shock(4) are referring to and would the left stick be ds(5) and ds(6)

and is this the part that is for the slop you are talking about

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

DualShock(3) is an array reference to the 4th element of the DualShock array (arrays are 0 based). In the code that I posted earlier it included:

;-------------Variables DualShock var Byte(7) ... 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 ...
So the Array is defined as having 7 elements and these elements are read in with the shiftin command from the PS2. The format of the data is such that DS(3) and DS(4) do the right stick and yes DS(5) and DS(6) do the left stick. I think in one of your versions of code you used the array name temp instead of DualShock. If this is still the case then you would need to change this code to reflect the actual variable name

Kurt

Kurt

wow that went right over my head i think its time i sit down and read the basic atom pro book that i got with my bb2 an atom pro
i guess i got a lil of the code if i was right about the bs5 an 6
thank you again for the help

Think of an array as a container or box with several compartments inside. The main box is the array name, the small compartments inside the box are the elements. So myVariable(7) is one box with 8 compartments inside of it. We have 8 because remember we started with 0 as our first element.

An array is useful when you need to store an array of data. An example is a list of peoples names. The array could be called “names(7)” and now you have one variable that can hold 8 different names of people.

Hope this helps.

yes that helps thank you for the explanation i did not work on my brat last night so i have not tryed any on the joysticks but i will tonight
i have to have a few projects going at the same time or i will lose motavation an get burned out so last night was building a flashing led circuit (three red rings of death) :smiling_imp: look alike for the xbox 360 project

ok i tried some code and got some bugs here is the error code
Error: FILE C:\PROGRAM FILES\SEQUENCER_SSC-32\NEW MYBOT FROM KURTE.BAS(LINE 242) : [TOKEN :] : IF without ENDIF
its on the retern at the bottom
here is my code

[code]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

  	if DualShock(5) > 144 then    ; left Stick Horizontal
		SeqIndex = 3   ; turn left
	elseif DualShock(5) < 112 
		SeqIndex = 4   ; turn right
    elseif DualShock(6) > 144    ; left stick vertical
		SeqIndex = 1   ; forward
	elseif DualShock(6) < 112 
		SeqIndex = 2   ; backwords
	else
		SeqIndex = 0 ; home
	endif
  
gosub PlaySeq 

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
retern [/code]

i left out the word table and steps
any help and thanks in advance
[/code]

I don’t see an endif for the if… else :

[code] else
; maybe process the 4 analog values from two joysticks

  for Index = 3 to 6 

[/code]

It should probably be after the call to playseq.

yup you were rite thanks mybe one day i will get the hang of this without you guys having to write my code and me pasting it all together
im a basic newb ha ha
well i thought it was funny