ok, did some more testing on it and found out another interesting piece: when the att line goes high then low (only if I hit connect the 1st time) the led on the reciever goes solid(connected) until the 7th bit of the 2nd command is sent, then it goes back to flashing(searching to connect), Which is the same spot where it would allow me to start it the first time; another interesting piece about this is that it will show connected on the led even if there is a battery out of the controller(obviously not connected) PLZ help me if u can
Post Edited (raresttyle) : 9/16/2006 8:52:55 PM GMT
I'm sorry it's taken me so long to respond·I haven't been online for awhile.
Looking over your code I can't help but wonder - when are you moving the data from B0 to a buffer?
Is there more to the code are there more bytes used as·temporary storage? see note below:
FOR B3 = 0 TO 5
FOR B4=0 TO 7
Bit0=Pin3 'get bit from controller on dat pin
PULSOUT 0,2 'send clk pulse
B0=B0*2 'Shift Bits to the left <
where is this byte used before it's overwritten by the next loop?
NEXT B4
NEXT B3
at this point in the programs development it would indeed be overwritten, but all I wanted to happen is for the controller to signal it was connected properly, but at this point I have figured out the problem, the pulsout command in picbasic is 10microseconds long!, I have experimented with speeding it up by changing the crystal, but at this point I have decided I need to cough up the money and get an oscilloscope to get it for sure; by the way, do u know if the usb oscilloscope sold by parallax would be fast enough to read the ps2 data; it has 1million sampling rate with one channel and half that with 2, thanks for your help
try using toggle on the clock with no delay this will give you the shortest possible clock pulse on you processor.
looks like this
FOR B3 = 0 TO 5
FOR B4=0 TO 7
Bit0=Pin3 'get bit from controller on dat pin
toggle 0 'send 1/2 clk pulse
toggle 0 'send 1/2 clk pulse
B0=B0*2 'Shift Bits to the left
NEXT B4
NEXT B3
Never used the oscilloscope, sorry -but you are correct that anything over 8 microeconds will fail - madcatz is even shorter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/21/2006 10:49:14 AM GMT
I have tried doing that before and tried it again; I also tried using a faster clock but it still doesnt work; it does do this interesting thing where when I push a button on the controller the reciever's led will blink really quickly as long as the button is pressed, I have decided that if I want to do this the right way I will need an oscilloscope. The question I was asking about the oscilloscope earlier was if I could read the ps2 with that sampling rate or if it needed to be faster, thank you so much for all your help
The receiver will blink when you press a button as long as the + and - are connected correctly.
Communication between the receiver is not dependent on the pic chips communication with the reciever. The receiver acts like a birectional shift register sending and recieving simultaneously as you toggle the clock pin. The button information is buffered until retrieve it. The important part is the protocol and the timing.
The only indication that you are communicating is examining the subsequent byte after you send the $01 - the first byte should be a $41 or a $73 depending on whether the controller in analog or digital mode. Since PicBasic doesn't support the Debug command I suggest lighting an LED if either of those bytes are received.
For example:
If B0 = $41 then
High LEDOut
Else
Low LEDOut
Endif
Sure -here's the code to a robot I built using 2 -18V in series motors 3 - 7.2V 3300mah batteries -(1 used for overcoming stall torque on starts and turns).· It has a R134A refrigerant cannon made out of a rainbird 3/4" irrigation valve with the cannon on a 2 servo gimble (it's very destructive at approx. 90psi). All relays are connected vai 4N35 optocouplers and 2N3904 pairs and a flyback diode. I use a Y-Bridge (modified H-Bridge) with a .1 snubber capacitor instead of diodes. All servos are controlled through the Parallax PSC.·· All wheels are rollerblade wheels attched via·rollerblade bearings to reduce stall torque and just to look cool.
Due to it's speed· - I use digital mode on the Psx controller (Pelican).
All in all it's way too fast to run indoors - I keep hitting the furniture and my wife gets upset.
Here's the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
'EL Diablo Robot - designed by Sean·& Rob
'2-axis Turret Gimble
'134A - Refrigerant Cannon fired via Rainbird 3/4" valve.
'2-direct drive wheels w/ 1-wheeled steering column.
'H-Bridge motor control drive.
'i/o config · SERVO PIN 15· 'Servo Interface · BAUD· CON $818C 'initial baud · HiBAUD CON 6 · 'manual memory assignment for equates · PW· VAR W0 'Servo Command · TURN· VAR B2 'Steering Column Position · FWD·· VAR B3 'Direct Motor Speed · buff VAR B4· 'Psx Communication · LHand VAR B7 · Rhand VAR B8 · PsxRLR VAR B9 · PsxRUD VAR B10 · PsxLLR VAR B11 · PsxLUD VAR B12 · 'Use B13 for flags · SwingFlg VAR B13.BIT0 · Boost VAR B13.BIT1 · TILT··· VAR B14 · SWING VAR B15 · TrigDly VAR B16.NIB1 · TrigBit VAR B16.BIT4 · StrtDly VAR B16.NIB0 · StrtBit VAR B16.BIT0
'equates for ps2 wireless control
'
'· |·· +3···· |LEFT|DOWN|RGHT| UP | STA| JL | JR | SEL|
'· +
+----+----+----+----+----+----+----+----+
'· |·· +4···· | [noparse]/noparse | X· | O· | /\ | R1 | L1 | R2 | L2 | · FireCmd PIN 0 · FwdCmd PIN 1 · RvsCmd PIN 2 · SftCmd PIN 3 · PsxAtt PIN 9 ' PSX joystick interface · PsxClk PIN 8 · PsxCmd PIN 10 · PsxDat PIN 11 ·'--equates--- · 'scratch pad variables · tmpout VAR pw.LOWBYTE · idx·· VAR pw.NIB2 · idy·· VAR pw.NIB3 · 'ps2 controller equates · PsxBox VAR RHand.BIT7 · PsxXXX VAR RHand.BIT6 · PsxCir VAR RHand.BIT5 · PsxTri VAR RHand.BIT4 · PsxR1 VAR RHand.BIT3 · PsxL1 VAR RHand.BIT2 · PsxR2 VAR RHand.BIT1 · PsxL2 VAR RHand.BIT0 · PsxLf VAR LHand.BIT7 · PsxDn VAR LHand.BIT6 · PsxRt VAR LHand.BIT5 · PsxUp VAR LHand.BIT4 · PsxStr VAR LHand.BIT3 · PsxJyR VAR LHand.BIT2 · PsxJyL VAR LHand.BIT1 · PsxSel VAR LHand.BIT0
· 'inits
· 'reset trigger · LOW FireCmd · 'reset H-bridge motor control · LOW FwdCmd · LOW RvsCmd · 'debounce flag · TrigDly=0 · StrtDly=0
· GOSUB ServoInit 'Set Up Servo Controller · GOSUB PS2Init·· 'Set up Playstation for analog
· 'program
· MAIN: · DO ··· GOSUB Get_PSX_Buttons ··· 'Trigger Debounce ··· TrigDly=TrigDly<<1 ··· TrigBit=~PsxR2 ··· IF TrigDly=1 THEN ····· HIGH FireCmd ····· PAUSE 500 ····· LOW FireCmd ··· ELSE ····· LOW FireCmd ··· ENDIF
Do not use a Madcatz· - BS2·can't switch the pins fast enough.
Make sure you haven't·reversed the pins the diagram (as stated)·is for the female part of the connector
Pins as view from the front of the playstation.
pin··· 9· 8· 7· 6· 5· 4· 3· 2· 1
·Pin signal· dir active description ·· 1. dat····· in·· pos· data from pad · 2. cmd····· out· pos· command data to pad·· 4. gnd····· --·· -- · 5. +3V····· --·· --·· +3.6V power source for system · 6. sel····· out· neg· select pad or memory-card · 7. clk····· out· --·· data shift clock · 9. ack····· in·· neg· acknowladge signal from pad ·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/23/2006 4:22:30 PM GMT
Is it wireless? If so it will probably work.
Otherwise if it's not a wireless controller then·use this instead: http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf
It will read it quicker.· This article uses shiftin and shiftout which does not work with a wireless controller.
After using Photoshop on the image this is what I can see
Psx Pin 1 is going to BS2 pin 11 - correct
Psx Pin 2 is going to BS2 pin 10 - correct
Psx Pin 3 no connect - correct
Psx Pin 4 is going to BS2 Vss - correct
Psx Pin 5 is going to BS2 Vin - Should be Vdd
Psx Pin 6 is going to BS2 pin 8 - should be pin 9
Psx Pin 7 is going to BS2 pin 9 - should be pin 8 and it should have a 220ohm resistor
Psx Pin 8 no connect - correct
Psx Pin 9 no connect - correct
Use the code below for testing and remember to press the analog button on your gamepad
' {$STAMP BS2}
' {$PBASIC 2.5}
'i/o config
· PsxAtt PIN 9 ' PSX joystick interface · PsxClk PIN 8 · PsxCmd PIN 10 · PsxDat PIN 11 ·'--equates--- · buff VAR B0 · tmpout VAR B9 · idx·· VAR B10.LOWNIB · idy·· VAR B10.HIGHNIB · 'inits
· PAUSE 500 'give controller time to initialize · OUTPUT PsxClk · OUTPUT PsxAtt · OUTPUT PsxCmd · INPUT PsxDat · HIGH PsxAtt · HIGH PsxClk
· 'program
· MAIN: · DO ··· GOSUB Get_PSX_Buttons ··· DEBUG HOME,HEX2 buff(1),HEX2 buff(2),CR ··· DEBUG BIN8 buff(3)," ",BIN8 buff(4) ,CR ··· DEBUG DEC3 buff(5)," ",DEC3 buff(6) ,CR ··· DEBUG DEC3 buff(7)," ",DEC3 buff(8) ,CR ··· PAUSE 16 ··· 'END · LOOP
'
[noparse][[/noparse] Subroutines ]
· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from ··· OUTPUT PsxCmd ··· INPUT PsxDat ··· HIGH PsxClk ··· LOW PsxAtt ··· FOR idy = 0 TO 8 ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00,$00,$00,$00,$00,$00,$00],tmpout ····· GOSUB BitSend ····· buff(idy)=tmpout ··· NEXT ··· HIGH PsxAtt ··· HIGH PsxCmd · RETURN · BitSend: ··· FOR idx=0 TO 7 ··· LOW PsxAtt ······ TOGGLE PsxClk ······ PsxCmd=tmpout.LOWBIT(idx) ······ tmpout.LOWBIT(idx)=PsxDat ······ TOGGLE PsxClk ······ 'PULSOUT PsxClk,1 ··· NEXT ·
Psx Pin 1 pull up resistor shoul be connected to Vdd not Vin
one thing that does seem odd is that you hot glued your pins on the PS2 controller. How do you know you have continuity? The most popularway is to buy an gamepad extension cable and do all your there. that way you can ensure that you have continuity.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/24/2006 9:15:54 PM GMT
one note - remember to reset your power after every upload .
as for the forwards and backwards-
yes if you look at the code that I for my robot you can see the pin assignments for the pad and the logic
heres an example.
In the code below PsxL1 will equal zero if the L1 button is pressed
If your in analog mode (red light on) PsxRLR (playstation Right joystick Left/Right Axis) will vary from 0 to 255 where zero is left and 255 is right.
PsxRUD (playstation Right joystick Up/Down Axis) will vary from 0 to 255 where zero is up and 255 is down.
adjust you servo or Relay accordingly
Code Sample: · buff VAR B4· 'Psx Communication · LHand VAR B7 · Rhand VAR B8 · PsxRLR VAR B9 · PsxRUD VAR B10 · PsxLLR VAR B11 · PsxLUD VAR B12
'equates for ps2 wireless control
'
'· |·· +3···· |LEFT|DOWN|RGHT| UP | STA| JL | JR | SEL|
'· +
+----+----+----+----+----+----+----+----+
'· |·· +4···· | [noparse]/noparse | X· | O· | /\ | R1 | L1 | R2 | L2 | · FireCmd PIN 0 · FwdCmd PIN 1 · RvsCmd PIN 2 · SftCmd PIN 3 · PsxAtt PIN 9 ' PSX joystick interface · PsxClk PIN 8 · PsxCmd PIN 10 · PsxDat PIN 11 ·'--equates--- · 'scratch pad variables · tmpout VAR pw.LOWBYTE · idx·· VAR pw.NIB2 · idy·· VAR pw.NIB3 · 'ps2 controller equates · PsxBox VAR RHand.BIT7 · PsxXXX VAR RHand.BIT6 · PsxCir VAR RHand.BIT5 · PsxTri VAR RHand.BIT4 · PsxR1 VAR RHand.BIT3 · PsxL1 VAR RHand.BIT2 · PsxR2 VAR RHand.BIT1 · PsxL2 VAR RHand.BIT0 · PsxLf VAR LHand.BIT7 · PsxDn VAR LHand.BIT6 · PsxRt VAR LHand.BIT5 · PsxUp VAR LHand.BIT4 · PsxStr VAR LHand.BIT3 · PsxJyR VAR LHand.BIT2 · PsxJyL VAR LHand.BIT1 · PsxSel VAR LHand.BIT0
If you look at my code - I use the gamepad in digital mode due to the speed of the robot - when I built one using a continuous servo it ran slow so the analog mode was fine. In digital mode the joysticks act like your pushing buttons.
I·dont have a BoeBot so I'm assuming the servo pins are correct - this was tried and tested on a BS2 with Parallax continous servos.
One important note : use a seperate 6V supply (4 AA in series) to power the servos - the BS2 will not have enough current to power 2 servos an one joystick. Simply connect the positive to the red of the servos and the negative to the stamps Vss.
Here's the code adjust for center and left right. Note I'm using 637 but each servo it could be lower or higher to stop rotation. Make sure you put the joystick in analog mode. Left joystick up/down is left wheel and right joystick is right wheel. Switch as necessary.
' {$STAMP BS2}
' {$PBASIC 2.5}
'i/o config
· PsxAtt PIN 9 ' PSX joystick interface · PsxClk PIN 8 · PsxCmd PIN 10 · PsxDat PIN 11 · ServoLeft PIN 12 'switch as necessary · ServoRight PIN 13 ·'--equates--- · buff VAR Byte(9) · tmpout VAR Byte · idx·· VAR Byte · idy·· VAR Byte · PWL VAR Word · PWR VAR Word · 'inits
· PAUSE 500 'give controller time to initialize · OUTPUT PsxClk · OUTPUT PsxAtt · OUTPUT PsxCmd · INPUT PsxDat · HIGH PsxAtt · HIGH PsxClk
· MAIN:
· DO ··· PWL=(buff(8) & 240) + 637 'adjust for center ··· PWR=(255-buff(6)& 240) + 637 'adjust for center ··· GOSUB Get_PSX_Buttons · LOOP
'
[noparse][[/noparse] Subroutines ]
· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from ··· OUTPUT PsxCmd ··· INPUT PsxDat
··· HIGH PsxClk ··· LOW PsxAtt ··· FOR idy = 0 TO 8 ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00,$00,$00,$00,$00,$00,$00],tmpout ····· GOSUB BitSend ····· buff(idy)=tmpout
Comments
Post Edited (raresttyle) : 9/16/2006 8:52:55 PM GMT
thanks
Looking over your code I can't help but wonder - when are you moving the data from B0 to a buffer?
Is there more to the code are there more bytes used as·temporary storage? see note below:
FOR B3 = 0 TO 5
FOR B4=0 TO 7
Bit0=Pin3 'get bit from controller on dat pin
PULSOUT 0,2 'send clk pulse
B0=B0*2 'Shift Bits to the left <
where is this byte used before it's overwritten by the next loop?
NEXT B4
NEXT B3
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
looks like this
FOR B3 = 0 TO 5
FOR B4=0 TO 7
Bit0=Pin3 'get bit from controller on dat pin
toggle 0 'send 1/2 clk pulse
toggle 0 'send 1/2 clk pulse
B0=B0*2 'Shift Bits to the left
NEXT B4
NEXT B3
Never used the oscilloscope, sorry -but you are correct that anything over 8 microeconds will fail - madcatz is even shorter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/21/2006 10:49:14 AM GMT
Communication between the receiver is not dependent on the pic chips communication with the reciever. The receiver acts like a birectional shift register sending and recieving simultaneously as you toggle the clock pin. The button information is buffered until retrieve it. The important part is the protocol and the timing.
The only indication that you are communicating is examining the subsequent byte after you send the $01 - the first byte should be a $41 or a $73 depending on whether the controller in analog or digital mode. Since PicBasic doesn't support the Debug command I suggest lighting an LED if either of those bytes are received.
For example:
If B0 = $41 then
High LEDOut
Else
Low LEDOut
Endif
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
i have a conecter and the wires for the controler
now i need to know how to hook the controler up to the boe bot
please
·
You can ignore the 9V Gray connection I use these pins:
· PsxAtt PIN 9
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/23/2006 4:09:23 PM GMT
i spend like 5 hours using codes you guys made
but none of it worked
when the controler is plugged it i can turn the light on and off on the controler
and says
11111111 11111111
255 255
255 255
in the box
did you ever figure out the whole working code??
Due to it's speed· - I use digital mode on the Psx controller (Pelican).
All in all it's way too fast to run indoors - I keep hitting the furniture and my wife gets upset.
Here's the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
'EL Diablo Robot - designed by Sean·& Rob
'2-axis Turret Gimble
'134A - Refrigerant Cannon fired via Rainbird 3/4" valve.
'2-direct drive wheels w/ 1-wheeled steering column.
'H-Bridge motor control drive.
'i/o config
· SERVO PIN 15· 'Servo Interface
· BAUD· CON $818C 'initial baud
· HiBAUD CON 6
· 'manual memory assignment for equates
· PW· VAR W0 'Servo Command
· TURN· VAR B2 'Steering Column Position
· FWD·· VAR B3 'Direct Motor Speed
· buff VAR B4· 'Psx Communication
· LHand VAR B7
· Rhand VAR B8
· PsxRLR VAR B9
· PsxRUD VAR B10
· PsxLLR VAR B11
· PsxLUD VAR B12
· 'Use B13 for flags
· SwingFlg VAR B13.BIT0
· Boost VAR B13.BIT1
· TILT··· VAR B14
· SWING VAR B15
· TrigDly VAR B16.NIB1
· TrigBit VAR B16.BIT4
· StrtDly VAR B16.NIB0
· StrtBit VAR B16.BIT0
'equates for ps2 wireless control
'
'· |·· +3···· |LEFT|DOWN|RGHT| UP | STA| JL | JR | SEL|
'· +
+----+----+----+----+----+----+----+----+
'· |·· +4···· | [noparse]/noparse | X· | O· | /\ | R1 | L1 | R2 | L2 |
· FireCmd PIN 0
· FwdCmd PIN 1
· RvsCmd PIN 2
· SftCmd PIN 3
· PsxAtt PIN 9 ' PSX joystick interface
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11
·'--equates---
· 'scratch pad variables
· tmpout VAR pw.LOWBYTE
· idx·· VAR pw.NIB2
· idy·· VAR pw.NIB3
· 'ps2 controller equates
· PsxBox VAR RHand.BIT7
· PsxXXX VAR RHand.BIT6
· PsxCir VAR RHand.BIT5
· PsxTri VAR RHand.BIT4
· PsxR1 VAR RHand.BIT3
· PsxL1 VAR RHand.BIT2
· PsxR2 VAR RHand.BIT1
· PsxL2 VAR RHand.BIT0
· PsxLf VAR LHand.BIT7
· PsxDn VAR LHand.BIT6
· PsxRt VAR LHand.BIT5
· PsxUp VAR LHand.BIT4
· PsxStr VAR LHand.BIT3
· PsxJyR VAR LHand.BIT2
· PsxJyL VAR LHand.BIT1
· PsxSel VAR LHand.BIT0
· 'inits
· 'reset trigger
· LOW FireCmd
· 'reset H-bridge motor control
· LOW FwdCmd
· LOW RvsCmd
· 'debounce flag
· TrigDly=0
· StrtDly=0
· GOSUB ServoInit 'Set Up Servo Controller
· GOSUB PS2Init·· 'Set up Playstation for analog
· 'program
· MAIN:
· DO
··· GOSUB Get_PSX_Buttons
··· 'Trigger Debounce
··· TrigDly=TrigDly<<1
··· TrigBit=~PsxR2
··· IF TrigDly=1 THEN
····· HIGH FireCmd
····· PAUSE 500
····· LOW FireCmd
··· ELSE
····· LOW FireCmd
··· ENDIF
··· 'Y-Bridge Drive - turn on relays
··· RvsCmd=~PsxXXX
··· FwdCmd=~PsxTri
··· 'Boost debounce
··· StrtDly=StrtDly<<1
··· StrtBit= RvsCmd|FwdCmd
··· IF StrtDly=1 THEN
······· Boost=1
··· ELSE
······· Boost=0
··· ENDIF
··· 'Steering
··· IF PsxBox=0 THEN
····· SftCmd=1
····· pw=625
··· ELSEIF PsxCir=0 THEN
····· SftCmd=1
····· pw=875
··· ELSE
····· PW=750
····· SftCmd=~PsxL1 | Boost
··· ENDIF
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",0,7,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· 'joystick button
··· SWING=~PsxL2 * 27 + 1
··· 'turret x
··· IF PsxUp=0 THEN
····· pw=700
··· ELSEIF PsxDn=0 THEN
····· pw=300
··· ELSE 'STOP turret
····· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SCRSP",4,CR]'get current position
····· SERIN SERVO,HiBAUD,[noparse][[/noparse]STR buff\3]
····· pw.LOWBYTE=buff(2)
····· pw.HIGHBYTE=buff(1)
··· ENDIF
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",4,SWING,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· 'turret y
··· IF PsxLf=0 THEN
····· pw=1150
··· ELSEIF PsxRt=0 THEN
····· pw=500
··· ELSE 'stop turret
····· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SCRSP",2,CR]
····· SERIN SERVO,HiBAUD,[noparse][[/noparse]STR buff\3]
····· pw.LOWBYTE=buff(2)
····· PW.HIGHBYTE=buff(1)
··· ENDIF
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",2,SWING,pw.LOWBYTE,pw.HIGHBYTE,CR]
· LOOP
'
[noparse][[/noparse] Subroutines ]
· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from
··· OUTPUT PsxCmd
··· INPUT PsxDat
··· HIGH PsxClk
··· LOW PsxAtt
··· FOR idy = 0 TO 4
····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00,$00,$00,$00,$00,$00,$00],tmpout
····· GOSUB BitSend
····· buff(idy)=tmpout
··· NEXT
··· HIGH PsxAtt
· RETURN
· BitSend:
··· FOR idx=0 TO 7
······ PsxCmd=tmpout.LOWBIT(idx)
······ tmpout.LOWBIT(idx)=PsxDat
······ PULSOUT PsxClk,1
··· NEXT
· RETURN
· ServoInit:
··· SEROUT SERVO, HiBAUD,[noparse][[/noparse]"!SCSBR",0,CR]'Slow PSC down if reset occurs
··· PAUSE 100
··· SEROUT SERVO, BAUD,[noparse][[/noparse]"!SCSBR",0,CR]'Send at low baud also - just my paranoia
··· PAUSE 100
··· SEROUT SERVO, BAUD,[noparse][[/noparse]"!SCSBR",1,CR]'set high baud
··· 'center steering column
··· pw=750
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",0,0,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· 'reset turret gimble x axis
··· PW=700
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",4,10,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· 'reset turret gimble y axis
··· pw=825
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",2,10,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· 'set drive left and right servos to stop
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",12,0,pw.LOWBYTE,pw.HIGHBYTE,CR]
··· SEROUT SERVO,HiBAUD,[noparse][[/noparse]"!SC",14,0,pw.LOWBYTE,pw.HIGHBYTE,CR]
· RETURN
· PS2Init:
· '[noparse][[/noparse]$01,$43,$00,$01,$00,$00,$00,$00,$00]'config mode enter
· '[noparse][[/noparse]$01,$44,$00,$01,$03,$00,$00,$00,$00]'set analog
· '[noparse][[/noparse]$01,$44,$00,$00,$03,$00,$00,$00,$00]'set digital mode
· '[noparse][[/noparse]$01,$4D,$00,$00,$01,$ff,$ff,$ff,$ff]'Vibration Enable
· '[noparse][[/noparse]$01,$4F,$00,$FF,$FF,$03,$00,$00,$00]'Set Native Mode
· '[noparse][[/noparse]$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A]'EXIT DS2 NATIVE
· '[noparse][[/noparse]$01,$43,$00,$00,$00,$00,$00,$00,$00],'config mode exit
· PAUSE 250 'give controller time to initialize
· OUTPUT PsxCmd
· INPUT PsxDat
· HIGH PsxClk
· LOW PsxAtt
· FOR idy = 0 TO 8
··· LOOKUP idy,[noparse][[/noparse]$01,$43,$00,$01,$00,$00,$00,$00,$00],tmpout
··· GOSUB BitSend
· NEXT
· HIGH PsxAtt
· PAUSE 1
· LOW PsxAtt
· FOR idy = 0 TO 8
··· LOOKUP idy,[noparse][[/noparse]$01,$44,$00,$00,$03,$00,$00,$00,$00],tmpout
··· GOSUB BitSend
· NEXT
· HIGH PsxAtt
· PAUSE 1
· LOW PsxAtt
· FOR idy = 0 TO 8
··· LOOKUP idy,[noparse][[/noparse]$01,$4F,$00,$FF,$FF,$03,$00,$00,$00],tmpout
··· GOSUB BitSend
· NEXT
· HIGH PsxAtt
· PAUSE 1
· LOW PsxAtt
· FOR idy = 0 TO 8
··· LOOKUP idy,[noparse][[/noparse]$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A],tmpout
··· GOSUB BitSend
· NEXT
· HIGH PsxAtt
· PAUSE 1
· LOW PsxAtt
· FOR idy = 0 TO 8
··· LOOKUP idy,[noparse][[/noparse]$01,$43,$00,$00,$00,$00,$00,$00,$00],tmpout
··· GOSUB BitSend
· NEXT
· HIGH PsxAtt
· PAUSE 1
· RETURN
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
I'm Sorry I uploaded the wrong image
Transistor is need for the nv101 code not mine.
Use the attach code for testing -
Do not use a Madcatz· - BS2·can't switch the pins fast enough.
Make sure you haven't·reversed the pins the diagram (as stated)·is for the female part of the connector
Pins as view from the front of the playstation.
pin··· 9· 8· 7· 6· 5· 4· 3· 2· 1
·Pin signal· dir active description
·
· 1. dat····· in·· pos· data from pad
· 2. cmd····· out· pos· command data to pad·· 4. gnd····· --·· --
· 5. +3V····· --·· --·· +3.6V power source for system
· 6. sel····· out· neg· select pad or memory-card
· 7. clk····· out· --·· data shift clock
· 9. ack····· in·· neg· acknowladge signal from pad
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/23/2006 4:22:30 PM GMT
will that code work with mine?
my pictures are kinda blurry but try to see what i can do
Otherwise if it's not a wireless controller then·use this instead:
http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf
It will read it quicker.· This article uses shiftin and shiftout which does not work with a wireless controller.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
can you make a shematic that i will understand
like what resistors and stuff
maybe this picture will help
Psx Pin 1 is going to BS2 pin 11 - correct
Psx Pin 2 is going to BS2 pin 10 - correct
Psx Pin 3 no connect - correct
Psx Pin 4 is going to BS2 Vss - correct
Psx Pin 5 is going to BS2 Vin - Should be Vdd
Psx Pin 6 is going to BS2 pin 8 - should be pin 9
Psx Pin 7 is going to BS2 pin 9 - should be pin 8 and it should have a 220ohm resistor
Psx Pin 8 no connect - correct
Psx Pin 9 no connect - correct
Use the code below for testing and remember to press the analog button on your gamepad
' {$STAMP BS2}
' {$PBASIC 2.5}
'i/o config
· PsxAtt PIN 9 ' PSX joystick interface
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11
·'--equates---
· buff VAR B0
· tmpout VAR B9
· idx·· VAR B10.LOWNIB
· idy·· VAR B10.HIGHNIB
· 'inits
· PAUSE 500 'give controller time to initialize
· OUTPUT PsxClk
· OUTPUT PsxAtt
· OUTPUT PsxCmd
· INPUT PsxDat
· HIGH PsxAtt
· HIGH PsxClk
· 'program
· MAIN:
· DO
··· GOSUB Get_PSX_Buttons
··· DEBUG HOME,HEX2 buff(1),HEX2 buff(2),CR
··· DEBUG BIN8 buff(3)," ",BIN8 buff(4) ,CR
··· DEBUG DEC3 buff(5)," ",DEC3 buff(6) ,CR
··· DEBUG DEC3 buff(7)," ",DEC3 buff(8) ,CR
··· PAUSE 16
··· 'END
· LOOP
'
[noparse][[/noparse] Subroutines ]
· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from
··· OUTPUT PsxCmd
··· INPUT PsxDat
··· HIGH PsxClk
··· LOW PsxAtt
··· FOR idy = 0 TO 8
····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00,$00,$00,$00,$00,$00,$00],tmpout
····· GOSUB BitSend
····· buff(idy)=tmpout
··· NEXT
··· HIGH PsxAtt
··· HIGH PsxCmd
· RETURN
· BitSend:
··· FOR idx=0 TO 7
··· LOW PsxAtt
······ TOGGLE PsxClk
······ PsxCmd=tmpout.LOWBIT(idx)
······ tmpout.LOWBIT(idx)=PsxDat
······ TOGGLE PsxClk
······ 'PULSOUT PsxClk,1
··· NEXT
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
and im going to clean up the wires and make it easier to read
see if im still wrong
that code didnt do any thing besides turn on the light
heres a couple pictures of the new wires
hopefully one of the pictures you can tell where the wires are in place
but can you make me a code that make the boe-bot go forward backward left right and stuff?
one thing that does seem odd is that you hot glued your pins on the PS2 controller. How do you know you have continuity? The most popularway is to buy an gamepad extension cable and do all your there. that way you can ensure that you have continuity.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 9/24/2006 9:15:54 PM GMT
to make it go foward backward and stuff
i got the conector from a dvd remote for my playstation
as for the forwards and backwards-
yes if you look at the code that I for my robot you can see the pin assignments for the pad and the logic
heres an example.
In the code below PsxL1 will equal zero if the L1 button is pressed
If your in analog mode (red light on) PsxRLR (playstation Right joystick Left/Right Axis) will vary from 0 to 255 where zero is left and 255 is right.
PsxRUD (playstation Right joystick Up/Down Axis) will vary from 0 to 255 where zero is up and 255 is down.
adjust you servo or Relay accordingly
Code Sample:
· buff VAR B4· 'Psx Communication
· LHand VAR B7
· Rhand VAR B8
· PsxRLR VAR B9
· PsxRUD VAR B10
· PsxLLR VAR B11
· PsxLUD VAR B12
'equates for ps2 wireless control
'
'· |·· +3···· |LEFT|DOWN|RGHT| UP | STA| JL | JR | SEL|
'· +
+----+----+----+----+----+----+----+----+
'· |·· +4···· | [noparse]/noparse | X· | O· | /\ | R1 | L1 | R2 | L2 |
· FireCmd PIN 0
· FwdCmd PIN 1
· RvsCmd PIN 2
· SftCmd PIN 3
· PsxAtt PIN 9 ' PSX joystick interface
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11
·'--equates---
· 'scratch pad variables
· tmpout VAR pw.LOWBYTE
· idx·· VAR pw.NIB2
· idy·· VAR pw.NIB3
· 'ps2 controller equates
· PsxBox VAR RHand.BIT7
· PsxXXX VAR RHand.BIT6
· PsxCir VAR RHand.BIT5
· PsxTri VAR RHand.BIT4
· PsxR1 VAR RHand.BIT3
· PsxL1 VAR RHand.BIT2
· PsxR2 VAR RHand.BIT1
· PsxL2 VAR RHand.BIT0
· PsxLf VAR LHand.BIT7
· PsxDn VAR LHand.BIT6
· PsxRt VAR LHand.BIT5
· PsxUp VAR LHand.BIT4
· PsxStr VAR LHand.BIT3
· PsxJyR VAR LHand.BIT2
· PsxJyL VAR LHand.BIT1
· PsxSel VAR LHand.BIT0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
If you look at my code - I use the gamepad in digital mode due to the speed of the robot - when I built one using a continuous servo it ran slow so the analog mode was fine. In digital mode the joysticks act like your pushing buttons.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
cant you just give me a sample code for one button (like X makes it go forward)
then i just figure out everything else
that would be easiest for me
thank you,
Weston
I·dont have a BoeBot so I'm assuming the servo pins are correct - this was tried and tested on a BS2 with Parallax continous servos.
One important note : use a seperate 6V supply (4 AA in series) to power the servos - the BS2 will not have enough current to power 2 servos an one joystick. Simply connect the positive to the red of the servos and the negative to the stamps Vss.
Here's the code adjust for center and left right. Note I'm using 637 but each servo it could be lower or higher to stop rotation. Make sure you put the joystick in analog mode. Left joystick up/down is left wheel and right joystick is right wheel. Switch as necessary.
' {$STAMP BS2}
' {$PBASIC 2.5}
'i/o config
· PsxAtt PIN 9 ' PSX joystick interface
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11
· ServoLeft PIN 12 'switch as necessary
· ServoRight PIN 13
·'--equates---
· buff VAR Byte(9)
· tmpout VAR Byte
· idx·· VAR Byte
· idy·· VAR Byte
· PWL VAR Word
· PWR VAR Word
· 'inits
· PAUSE 500 'give controller time to initialize
· OUTPUT PsxClk
· OUTPUT PsxAtt
· OUTPUT PsxCmd
· INPUT PsxDat
· HIGH PsxAtt
· HIGH PsxClk
· MAIN:
· DO
··· PWL=(buff(8) & 240) + 637 'adjust for center
··· PWR=(255-buff(6)& 240) + 637 'adjust for center
··· GOSUB Get_PSX_Buttons
· LOOP
'
[noparse][[/noparse] Subroutines ]
· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from
··· OUTPUT PsxCmd
··· INPUT PsxDat
··· HIGH PsxClk
··· LOW PsxAtt
··· FOR idy = 0 TO 8
····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00,$00,$00,$00,$00,$00,$00],tmpout
····· GOSUB BitSend
····· buff(idy)=tmpout
····· PULSOUT ServoLeft,PWL
····· PULSOUT ServoRight,PWR
··· NEXT
··· HIGH PsxAtt
··· HIGH PsxCmd
· RETURN
· BitSend:
··· FOR idx=0 TO 7
······ TOGGLE PsxClk
······ PsxCmd=tmpout.LOWBIT(idx)
······ tmpout.LOWBIT(idx)=PsxDat
······ TOGGLE PsxClk
······ 'PULSOUT PsxClk,1
··· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
i can make the sevos move with the joystick
but i need to spend time and center it
but
DO
PWL=(buff(8) & 240) + 637 ' what does 240 mean???
PWR=(255-buff(6)& 240) + 637 ' what does 240 mean??? and 255
GOSUB Get_PSX_Buttons
LOOP
and
thank you
it works pretty good
what is the code for the X, circle, square, and triangle
like i want it to have four LED's and when you press X, circle, square, and triangle they will light up