Playstation controler and the Boe-Bot BS2 stamp
Hi,
This is my first time posting. I have a question about the code I am using to opporate my boe-bot using the PS2 controler.
I was wondering why my PulseRight command seems to effect the left wheel and the PulseLeft command seems to effect the right wheel.
A segment of my code is below.
For a full source of my code please go to http://http://www.aaronklapheck.com/thermodynamics.html.
My full http://www.aaronklapheck.com/Downloads/Electronics/RoboticHandAndMovementsUsingPs2WithPing.zip
I have also attached the code to this message.
'
[noparse][[/noparse] Program Code ]
Main:
DO
IF (psxId <> $41) THEN ' If in analog mode
GOSUB Get_PSX_Packet_Fast ' type and packet
JoyToPulseForBac = psxJoyRY + 625 ' < 750 means go forward, > 750 means go backward. Range: 625 to 875.
JoyToPulseLefRig = psxJoyRX - 127 ' < 0 means turn left, > 0 means turn right. Range: -125 to 125.
PulseRight = (1500 - (JoyToPulseForBac)) + (JoyToPulseLefRig) 'Left wheel, for some reason the wheel commands seem reversed
PulseLeft = (JoyToPulseForBac) + (JoyToPulseLefRig) 'Right wheel, for some reason the wheel commands seem reversed
' I had to reduce the range of values to which the Joystick will be sensitive to because
' otherwise the naturally occuring errors would have the boe-bot move erratically.
IF (PulseRight < 780 AND PulseRight > 720) THEN
PulseRight = 750
ENDIF ' (PulseRight < 780 AND PulseRight > 720)
IF (PulseLeft < 780 AND PulseLeft > 720) THEN
PulseLeft = 750
ENDIF ' (PulseLeft < 780 AND PulseLeft > 720)
FOR counter = 0 TO 1
PULSOUT WheelRight, PulseRight ' 850 forward
PULSOUT WheelLeft, PulseLeft ' 650 forward
PAUSE 20
NEXT ' counter = 0 TO 1
ELSE ' If in digital mode
GOSUB Get_PSX_Packet_Fast ' type and packet
' Left 4 buttom pad
' *** You may need to change the values to match your controler ***
IF psxThumbL = 127 THEN ' (L arrow)
GOSUB TurnLeft
ELSEIF psxThumbL = 191 THEN ' (down arrow)
GOSUB Backward
ELSEIF psxThumbL = 223 THEN ' (R arrow)
GOSUB TurnRight
ELSEIF psxThumbL = 239 THEN ' (up arrow)
GOSUB Forward
ENDIF
' L (1 and 2) and R (1 and 2) buttons
' *** You may need to change the values to match your controler. ***
' *** If you don't have a gripper just comment out the code below. ***
IF psxThumbR = 254 THEN ' (L 2)
GOSUB CloseHand
ELSEIF psxThumbR = 253 THEN ' (R 2)
GOSUB OpenHand
' *** If you don't have a ping rotater just comment out the code below. ***
ELSEIF psxThumbR = 251 THEN ' (L 1)
GOSUB RotatePingLeft
ELSEIF psxThumbR = 247 THEN ' (R 2)
GOSUB RotatePingRight
ENDIF
' *** You may need to change the values to match your controler. ***
' *** If you don't have a ping sensor just comment out this section. ***
IF psxThumbR = 223 THEN ' circle button
GOSUB Pinging
ENDIF ' psxThumbR = 223
ENDIF ' (psxId <> $41)
LOOP ' Main loop
END
Post Edited (Klap) : 5/7/2009 6:18:38 PM GMT
This is my first time posting. I have a question about the code I am using to opporate my boe-bot using the PS2 controler.
I was wondering why my PulseRight command seems to effect the left wheel and the PulseLeft command seems to effect the right wheel.
A segment of my code is below.
For a full source of my code please go to http://http://www.aaronklapheck.com/thermodynamics.html.
My full http://www.aaronklapheck.com/Downloads/Electronics/RoboticHandAndMovementsUsingPs2WithPing.zip
I have also attached the code to this message.
'
[noparse][[/noparse] Program Code ]
Main:
DO
IF (psxId <> $41) THEN ' If in analog mode
GOSUB Get_PSX_Packet_Fast ' type and packet
JoyToPulseForBac = psxJoyRY + 625 ' < 750 means go forward, > 750 means go backward. Range: 625 to 875.
JoyToPulseLefRig = psxJoyRX - 127 ' < 0 means turn left, > 0 means turn right. Range: -125 to 125.
PulseRight = (1500 - (JoyToPulseForBac)) + (JoyToPulseLefRig) 'Left wheel, for some reason the wheel commands seem reversed
PulseLeft = (JoyToPulseForBac) + (JoyToPulseLefRig) 'Right wheel, for some reason the wheel commands seem reversed
' I had to reduce the range of values to which the Joystick will be sensitive to because
' otherwise the naturally occuring errors would have the boe-bot move erratically.
IF (PulseRight < 780 AND PulseRight > 720) THEN
PulseRight = 750
ENDIF ' (PulseRight < 780 AND PulseRight > 720)
IF (PulseLeft < 780 AND PulseLeft > 720) THEN
PulseLeft = 750
ENDIF ' (PulseLeft < 780 AND PulseLeft > 720)
FOR counter = 0 TO 1
PULSOUT WheelRight, PulseRight ' 850 forward
PULSOUT WheelLeft, PulseLeft ' 650 forward
PAUSE 20
NEXT ' counter = 0 TO 1
ELSE ' If in digital mode
GOSUB Get_PSX_Packet_Fast ' type and packet
' Left 4 buttom pad
' *** You may need to change the values to match your controler ***
IF psxThumbL = 127 THEN ' (L arrow)
GOSUB TurnLeft
ELSEIF psxThumbL = 191 THEN ' (down arrow)
GOSUB Backward
ELSEIF psxThumbL = 223 THEN ' (R arrow)
GOSUB TurnRight
ELSEIF psxThumbL = 239 THEN ' (up arrow)
GOSUB Forward
ENDIF
' L (1 and 2) and R (1 and 2) buttons
' *** You may need to change the values to match your controler. ***
' *** If you don't have a gripper just comment out the code below. ***
IF psxThumbR = 254 THEN ' (L 2)
GOSUB CloseHand
ELSEIF psxThumbR = 253 THEN ' (R 2)
GOSUB OpenHand
' *** If you don't have a ping rotater just comment out the code below. ***
ELSEIF psxThumbR = 251 THEN ' (L 1)
GOSUB RotatePingLeft
ELSEIF psxThumbR = 247 THEN ' (R 2)
GOSUB RotatePingRight
ENDIF
' *** You may need to change the values to match your controler. ***
' *** If you don't have a ping sensor just comment out this section. ***
IF psxThumbR = 223 THEN ' circle button
GOSUB Pinging
ENDIF ' psxThumbR = 223
ENDIF ' (psxId <> $41)
LOOP ' Main loop
END
Post Edited (Klap) : 5/7/2009 6:18:38 PM GMT
Comments
My first thought is that you might have an operation sign reversed somewhere in the code like a + instead of a - or a < instead of a >
I looked over the code and noticed here:
FOR counter = 0 TO 1
····· PULSOUT WheelRight, PulseRight···· ' 850 forward
····· PULSOUT WheelLeft, PulseLeft······ ' 650 forward
····· PAUSE 20
··· NEXT ' counter = 0 TO 1
850 should be backward on the right and 650 should be backward on the left. I know that is a comment and doesn't affect the actual code but wherever thhe actual code is that has the PULSOUT values, 850 should be fullspeed forward for the left servo and 650 should be fullspeed forward for the right servo.
Main:
DO
· IF (psxId <> $41) THEN· ' If in analog mode
··· GOSUB Get_PSX_Packet_Fast··········· ' type and packet
··· JoyToPulseForBac = psxJoyRY + 625··· ' < 750 means go forward, > 750 means go backward. Range: 625 to 875.
··· JoyToPulseLefRig = psxJoyRX - 127··· ' < 0 means turn left, > 0 means turn right. Range: -125 to 125.
··· PulseRight = (1500 - (JoyToPulseForBac)) + (JoyToPulseLefRig)·· 'Left wheel, for some reason the wheel commands seem reversed (Try switching the operation sign·on this line and the one below·+ instead of -)·
··· PulseLeft = (JoyToPulseForBac) + (JoyToPulseLefRig)················ 'Right wheel, for some reason the wheel commands seem reversed
··· ' I had to reduce the range of values to which the Joystick will be sensitive to because
··· ' otherwise the naturally occuring errors would have the boe-bot move erratically.
··· IF (PulseRight < 780 AND PulseRight > 720) THEN
····· PulseRight = 750
··· ENDIF ' (PulseRight < 780 AND PulseRight > 720)
··· IF (PulseLeft < 780 AND PulseLeft > 720) THEN
····· PulseLeft = 750
··· ENDIF ' (PulseLeft < 780 AND PulseLeft > 720)
··· FOR counter = 0 TO 1
····· PULSOUT WheelRight, PulseRight···· ' 850 forward
····· PULSOUT WheelLeft, PulseLeft······ ' 650 forward
····· PAUSE 20
··· NEXT ' counter = 0 TO 1
Do you have the left servo hooked up to P13 or P12? And is the Boe-Bot in the picture here ( http://webpages.csus.edu/~aak37/thermodynamics.html) the one you used and if so are you using the·the end of the Boe-Bot with the·gripper as the "front"·or the other end because that would make a difference.
BTW I'm just a beginner at this and am still going through the Robotics with the Boe-Boe text but I hope that helps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<.-.>Braden<.-.>
But I don't think this will be the solution because my wheel commands are reversed as you suspected because I am using the "back" of the boe-bot as the "front" to maintain a better equilibrium.
The boe-bot that is being used for the code given can be seen at http://www.aaronklapheck.com/thermodynamics.html. (just go to the bottom of the page). The code used to control the boe-bot is also located on this website, located just below the pictures of the boe-bot (click on "code")
I will be including a circuit diagram in my next post (hopefully by tomarrow); where I will also be able to give feedback on whether a sign or logical opporation error occured.
Has anyone found my code useful? Please let me know how you liked it.
Post Edited (Klap) : 5/7/2009 6:19:23 PM GMT
I have corrected this error on my Boe-Bot demonstration webpage by noting that I made a mistake.
I also noticed that on my Boe-Bot demonstration webpage it shows a boe-bot that does not use a ping sesor. This is because I added on the ping sensor after the demonstration.
I have made complete corrections to my photos and code which is now published at: http://www.aaronklapheck.com/AaronsInterests.html.
For all those interested in creating a Boe-Bot that is controled by a playstation remote, my website gives detailed instruction on how to do exactly that. Just go to http://www.aaronklapheck.com/AaronsInterests.html (same as the one listed above) and scroll to the bottom of the page.
This page includes:
1. Wireing diagrams
2. Code examples (in great detail)
3. Pictures
If anyone finds this information usefull please let me know by replying to this post.
Post Edited (Klap) : 5/7/2009 6:20:24 PM GMT
Can I use a 2N3906 in place of the 2N3901 transistor hooked to the PSX Clock on the controller adapter?
If you are not familiar with transisters I would just pick up some low voltage, low current, NPN transisters (2N3904 transisters if you want to be on the safe side). I was able to pick up ten 2N3904 transisters from FHE electronics for about a $1.50.
FHE electronics: http://hfeelectronics.com
Documentation for 2N3904 transister: http://pubpages.unh.edu/~aperkins/pdf/2N-devices/2N3904_3.pdf
Documentation for 2N3906 transister: http://www.jaycar.com.au/images_uploaded/2N3906_3.PDF
Post Edited By Moderator (Chris Savage (Parallax)) : 8/26/2008 2:06:35 PM GMT
Or view it on YouTube: http://www.youtube.com/watch?v=DBmqaRMp3hQ&eurl=http://webpages.csus.edu/~aak37/AaronsInterests.html..
Post Edited (Klap) : 5/7/2009 6:21:33 PM GMT
Post Edited By Moderator (Chris Savage (Parallax)) : 8/26/2008 2:06:58 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
········ First of all thanks for all the information you have provided on your website for this project. I am in a 2 year college right now and we are studying microcontrollers. We have a project due at the end of the quarter (2 weeks) and I have decided to build the boe bot and have it iterfaced with the PS2 controller. I followed your psuedo guide from your website and that of the nuts and volts article you suggested. I'm running into some problems I think with my connections between the BS2 board and the interface wth the Lynxmotion adapter. I don't know if you still have your connections together for this project but if you were able to post a close up picture of the connections or maybe take a look at what I have done that would be very helpful. I'm suppose to present my project Monday evening at class so I want to make sure I have it ready to go before then (obviously). Also I had a question with the direct connections you made from the female adapter piece from the Lynmotion ports. What tricks do you have to keep your connections together (I'm having trouble with them disconnecting from the slightest movement). Thanks for you help and I look forward to hearing back from you at your convienience.
································ Thanks-
······································ Dan Ryan
For the first question: I think I was using my Boe-Bot backwards (with the ball in front instead of in back). If you simply interchange the joysticks then it should work. I was never able to fully understand why this portion of code worked the way it did. I just played with it until I got it to work.
For the second question: I am sorry, but I haven't built that circuit in a while. You should be able to find a nice picture on the web. The circuit diagrams I included are pretty detailed so I am not exactly sure how much it would help to include a picture. The Lynxmotion controller should give you very solid wire connections I am not sure why it wouldn't.
·