Shop OBEX P1 Docs P2 Docs Learn Events
Playstation controler and the Boe-Bot BS2 stamp — Parallax Forums

Playstation controler and the Boe-Bot BS2 stamp

KlapKlap Posts: 65
edited 2009-05-08 17:10 in Robotics
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

Comments

  • BradenBraden Posts: 5
    edited 2008-07-14 19:20
    Welcome to the Parallax forums!

    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<.-.>
  • KlapKlap Posts: 65
    edited 2008-08-05 23:10
    Thank you for your help. I will try and see if I made a sign error (I don't have a internet access at my house so I am currently at school). I will let you know if this solves the problem.

    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
  • KlapKlap Posts: 65
    edited 2008-08-06 17:13
    I just got done rechecking the wiring and code. I made one of the simplest errors. I interchanged the pin numbers between the right and left wheel, I feel so dumb right now. I labeled the wires leading to the wheel servos L, for left, and R, for right, using tape but forgot to take off the physical labels when I installed the Board of Education backwards.


    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
  • ScurgeScurge Posts: 7
    edited 2008-08-18 16:21
    Thank you very much! I have just reached the end of the of the included BOE-Bot book and was thinking about trying the playstation remote project. I have 2 wireless PS2 remotes that would be cool to use.
  • ScurgeScurge Posts: 7
    edited 2008-08-18 21:12
    One question:

    Can I use a 2N3906 in place of the 2N3901 transistor hooked to the PSX Clock on the controller adapter?
  • KlapKlap Posts: 65
    edited 2008-08-20 16:00
    The only transister hooked up to the PSX Clock it the 2N3904 transister. The exchange of transisters will matter because one is an NPN transister whereas the other is a PNP transister. Due to this difference the current flows in the opposite dirrections so be carefull how you set up the transister. Also, you would have to revers the polarities on the pin because a high signal for the 2N3906 means that the colecter-emitter current goes down not up.

    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
  • KlapKlap Posts: 65
    edited 2008-08-20 16:01
    I posted a video of the PS2 controller directing the movements of the Boe-Bot. See Aaron's Interest page: http://www.aaronklapheck.com/AaronsInterests.html (near the bottom of the page).
    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
  • KlapKlap Posts: 65
    edited 2008-08-20 16:31
    The wireless remotes I hear are a bit more tempermental than the non-wireless controllers. I think this is due partially to the fact that Sony doesn't make any wireless controlers and many of the off-brands don't have a universal transmission method. Becuase each off-brand controller uses its own information transfer protocall it leads to more difficulty when it comes to programming. I will be trying to get a number of wireless controllers and see which ones work. A friend of my works at Game Stop and said that he would give me all the "through-away" controllers next month. When that happons I will be testing each of them and post all the code information I gain. I will also tell everyone which ones work and which ones don't.

    Post Edited By Moderator (Chris Savage (Parallax)) : 8/26/2008 2:06:58 PM GMT
  • KlapKlap Posts: 65
    edited 2008-10-10 22:58
    This page has been moved to: http://www.aaronklapheck.com/AaronsInterests.html

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • wahekarwahekar Posts: 1
    edited 2008-10-14 07:23
    hi, i am completely new to this, i have a question pertaining to the ps2 controller and the bs2 with the boe. i am unable to get the robot to move forward with the right joystick. instead it moves to the right, and the left joystick, when moved to the left goes in reverseand vice versa. any help would be appreciated. thank you
  • danr238danr238 Posts: 14
    edited 2008-12-05 13:26
    Aaron
    ········ 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
  • KlapKlap Posts: 65
    edited 2009-05-07 18:12
    Sorry it has taken me so long to respond. I have been busy with a few new projects.

    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.
  • danr238danr238 Posts: 14
    edited 2009-05-07 20:32
    Thanks for the response (better late than never), I was able to have the project up and running by the due date thankfully. The problem I ran into was the color coding in the nuts and volts magazine didn't make that of the adapter. I guess I just took it for granted, but when I gave it a rest and took another look I noticed my problem. Thanks though!
    ·
  • PrettybirdPrettybird Posts: 269
    edited 2009-05-08 17:10
    I was curious on what version of the playstation hardware hook up yue used. I have seen several. Some with uull up resistord and some with an addes transistor. I knw about butchering the extention coard. I also have a ton of 2n2222 transistoers laying around. Thanks
Sign In or Register to comment.