Putting robotics at your service™

Free shipping on orders over $200

PS2 analog sticks - Normalization of readings

Print view Share :
Previous topicNext topic

Page 3 of 3 [ 33 posts ]

1, 2, 3
User avatar
Guru ( offline )
Posts: 4903
Posted: 2010-06-13 11:59 
So for the fun of it, I edited the simple PS2 test program with a few different #ifdefs. One to define it for the standard pins or for having it on pins 0-3. Another to decide if you want all 18 bytes/vibration or if you simply want the standard 6 bytes all of our programs typically use, and last and hopefully not least, will use the code I mentioned in the previous post:
Code:
      IF ABS(Dualshock(5) - 128) > DeadZone THEN ;Left Stick L/R
         LStickY = (Dualshock(5) - 128) ;Wheels
      ELSE
         LStickY=0       
      ENDIF
 

To map the joystick values from the center point and print them. Have fun!

Kurt

Edit: as an added bonus, I put in some simple pan/tilt code on the left joystick that you can ifdef in or out. You will have to change the IO pins that they are on. The tilt works fine, but I am having problems with my Pan servo in a base rotate unit that I need to replace...


Attachment:
File comment: More test stuff!
test.bas [5.67 KiB]
Downloaded 84 times
User avatar
Guru ( offline )
Posts: 2956
Posted: 2010-06-15 19:02 
kurte wrote:
Edit: as an added bonus, I put in some simple pan/tilt code on the left joystick that you can ifdef in or out. You will have to change the IO pins that they are on. The tilt works fine, but I am having problems with my Pan servo in a base rotate unit that I need to replace...

I just tried your new code. It does work for positioning the Pan servo. I have to install a servo for the Tilt, so have not checked that yet. Is there any way to get the sticks to auto center when they are not being operated? That does not seem to be happening now.

8-Dale

_________________
I can usually handle complexity. It's the [b][i]simple[/i][/b] things that always confound me..
Check out my [url=http://www.hybotics.me]blog[/url] now!
Open your mind, Read, Learn, Think, Apply..


User avatar
Guru ( offline )
Posts: 4903
Posted: 2010-06-18 15:57 
linuxguy wrote:
I just tried your new code. It does work for positioning the Pan servo. I have to install a servo for the Tilt, so have not checked that yet. Is there any way to get the sticks to auto center when they are not being operated? That does not seem to be happening now.

If what you desire is for the pan and tilt to mimic the position of the joystick, then you can simplify the code. That is instead of looking at the current position, you simply scale the Joystick return values. That is you could do something like:
Code:
IF (ABS(DualShock(3)-128) > TravelDeadZone) THEN
    hservo [Turret\(Dualshock(3) - 128)*4) \100]
ELSE
    hservo [Turret\0 \100]
ENDIF

Personally I don't think this will work very well, as the joystick return values are not fluid.

Other options:
1) TImeout - if the joystick has been at the center position for a certain amount of time, set it to zero point.

2) use a button like: clicking the joystick to say Move me back to the idle position.

Kurt


1, 2, 3

All times are UTC - 5 hours [ DST ]. It is currently 2014-08-30 08:29
Feedback Form
Feedback Form