Rover 1 w/ scoop

You won’t be able to just wire it differently, but this shouldn’t be too hard to code. What sort of controller is onboard?

its an Atom bot board with a Basic Atom, too bad i cant program, thats also one of my investments

If you post the existing code, I think we can help you out with the modification to make it work :slight_smile:

[code]'Program name: PS2ROV2.BAS
'Author: Jim Frye / Nathan Scherdin (PS2 stuff)

’ This program allows the remote control of a differentially steered robot
’ from the Sony Play Station 2 game controller.

’ The Scorpion has two modes of operation. The default is the mixer mode. This
’ is where you have a Throttle for forward and reverse speed control, and a
’ Steering control for turning. In this mode the left input is throttle and
’ the right input is steering. The other mode is a differential style control.
’ This is where the left and right channels are controled indepentantly to
’ steer like a tank. This program uses the mixing mode. It also requires the
’ BEC (battery eliminator circuit to be dissabled. See the Scorpion manual.

'Connections
'Pin 0 Left Scorpion channel.
'Pin 1 Right Scorpion channel.
'Pin 2 Pan servo.
'Pin 3 Tilt servo.
'Pin 4 PS2 Data
'Pin 5 PS2 Command
'Pin 6 PS2 Select
'Pin 7 PS2 Clock
'Pin 8 NA
'Pin 9 Speaker
'Pin 10 1/0 Controlled from Triangel Button
'Pin 11 1/0 Controlled from “X” button
'Pin 12 Gripper up/down servo.
'Pin 13 Gripper rotate servo.
'Pin 14 Gripper open/close servo.
'Pin 15 NA

DAT con P4 ’ Play Station game controller connections.
CMD con P5
SEL con P6
CLK con P7

temp var byte ’ Variable definetions.
button1 var byte
button2 var byte

bpress1 var bit
bpress2 var bit

rhori var word
rvert var word
lhori var word
lvert var word

ldrive var word
rdrive var word
servo0 var word
servo1 var word

servo2 var word
servo3 var word
servo4 var word
servo5 var word

servo0 = 1500 ’ Start the servos at mid position.
servo1 = 1500
servo2 = 1500
servo3 = 1500
servo4 = 1500

low p0 ’ Ensure pulsout commands are positive going.
low p1
low p2
low p3
low p12
low p13
low p14

low P10 ’ Ensure device connected to pin 10 and 11 is off on startup
low P11

high CLK ’ Ensure CLK is negative going.

sound 9, [100\880, 100\988, 100\1046, 100\1175] 'four quick ascending notes.

pause 1000

setup ’ This section sets the PSX Controller to Analog Mode. (red LED should light)
’ This will work with Sony and Madcatz wired, but not with Medcatz wireless.
’ You must press the analog button on the controller to set to analog mode.
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$01\8,$00\8] ;Config Mode Enable
high SEL

pause 100

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 to Analog and Lock 
high SEL

pause 100

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 Exit
high SEL

main
gosub get_PSX_data
’ lvert=255-lvert ’ Changes vertical up from 0 to 255 and vertical down from 255 to 0.
lhori=255-lhori
ldrive=((lvert3)+1116) ’ Converts a 0-128-255 value to a 1116-1500-1881 value.
rdrive=((lhori
3)+1116)
’ ldrive=((lvert4)+1000) ’ Converts a 0-128-255 value to a 1000-1512-2020 value.
’ rdrive=((lhori
4)+1000)
'serout S_OUT,i57600,[dec3 lvert\3," “,dec3 lhori\3,” “]
'serout S_OUT,i57600,[dec5 ldrive\5,” “,dec5 rdrive\5,” ",13]
’ servo0=((rhori4)+1000)
’ servo1=((rvert
4)+1000)

if rhori > 208 then			' Pan servo routine.
	servo0 = servo0 + 25
elseif rhori > 148 
	servo0 = servo0 + 5
endif	
if servo0 < 750 then
	servo0 = 750
endif
if rhori < 48 then
	servo0 = servo0 - 25
elseif rhori < 108 
	servo0 = servo0 - 5
endif
if servo0 > 2250 then
	servo0 = 2250
endif

if rvert > 208 then			' Tilt servo routine.
	servo1 = servo1 + 25
elseif rvert > 148 
	servo1 = servo1 + 5
endif	
if servo1 < 750 then
	servo1 = 750
endif
if rvert < 48 then
	servo1 = servo1 - 25
elseif rvert < 108 
	servo1 = servo1 - 5
endif
if servo1 > 2250 then
	servo1 = 2250
endif

’ Gripper open/close
temp=button2 & 2 ’ Filter out all but bit 2, R2.
if temp=0 then ’ If button is pressed then do the following.
servo4 = servo4 - 25 ’ Open the gripper.
if servo4 < 750 then ’ Hold the value to 750 minimum.
servo4 = 750
endif
endif
temp=button2 & 8 ’ Filter out all but bit 8, R1.
if temp=0 then ’ If button is pressed then do the following.
servo4 = servo4 + 25 ’ Close the gripper.
if servo4 > 2250 then ’ Hold the value to 2250 maximum.
servo4 = 2250
endif
endif
’ Gripper up/down
temp=button1 & 16 ’ Filter out all but bit 16, D-pad up arrow.
if temp=0 then ’ If button is pressed then do the following.
servo2 = servo2 - 25 ’ Lift gripper.
if servo2 < 750 then ’ Hold the value to 750 minimum.
servo2 = 750
endif
endif
temp=button1 & 64 ’ Filter out all but bit 64, D-pad down arrow.
if temp=0 then ’ If button is pressed then do the following.
servo2 = servo2 + 25 ’ Lower gripper.
if servo2 > 2250 then ’ Hold the value to 2250 maximum.
servo2 = 2250
endif
endif
’ Gripper Rotate
temp=button1 & 32 ’ Filter out all but bit 32, D-pad right arrow.
if temp=0 then ’ If button is pressed then do the following.
servo3 = servo3 - 25 ’ Gripper rotate right.
if servo3 < 750 then ’ Hold the value to 750 minimum.
servo3 = 750
endif
endif
temp=button1 & 128 ’ Filter out all but bit 128, D-pad left arrow.
if temp=0 then ’ If button is pressed then do the following.
servo3 = servo3 + 25 ’ Gripper rotate left.
if servo3 > 2250 then ’ Hold the value to 2250 maximum.
servo3 = 2250
endif
endif
’ I/O on/off
temp=button2 & 16 ’ Filter out all but bit 16, Triangle button.
if temp=0 and bpress1=0 then ’ This makes a latching output pin that responds to button presses.
bpress1=1
toggle p10
endif
if temp<>0 and bpress1=1 then
bpress1=0
endif
temp=button2 & 64 ’ Filter out all but bit 64, X button.
if temp=0 and bpress2=0 then ’ This makes a latching output pin that responds to button presses.
bpress2=1
toggle p11
endif
if temp<>0 and bpress2=1 then
bpress2=0
endif

’ Send out the servo pulses
pulsout 0,ldrive ’ Left Scorpion channel.
pulsout 1,rdrive ’ Right Scorpion channel.
pulsout 2,servo0 ’ Pan servo.
pulsout 3,servo1 ’ Tilt servo.
pulsout 12,servo2 ’ Gripper up/down servo.
pulsout 13,servo3 ’ Gripper rotate servo.
pulsout 14,servo4 ’ Gripper open/close servo.
’ pulsout 15,servo5
pause 20
goto main

get_PSX_data ’ This section gets the data from the PSX controller.
’ The first shiftin gets the mode. (73)
’ The next 2 shiftins gets the pushbutton data.
’ The next 4 shiftins gets the analog joystick data.
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8] ’ Initiate request for data from PSX controller.
shiftin DAT,CLK,FASTLSBPOST,[temp\8] ’ This is the Mode value, it will be dumped.
shiftin DAT,CLK,FASTLSBPOST,[button1\8,button2\8] ’ This puts the button data into two byte variables.
shiftin DAT,CLK,FASTLSBPOST,[temp\8] ’ This retrieves the RH byte variable.
rhori=temp ’ This plugs the value into a word variable.
shiftin DAT,CLK,FASTLSBPOST,[temp\8] ’ Note: This is necessary because the shiftin command
rvert=temp ’ can’t use a word variable with a byte wide shift.
shiftin DAT,CLK,FASTLSBPOST,[temp\8]
lhori=temp
shiftin DAT,CLK,FASTLSBPOST,[temp\8]
lvert=temp
high SEL
’ remove the rems (’) to see the joystick values in terminal 1.
’ serout S_OUT,i57600,[bin button1\8," “,bin button2\8,” “]
’ serout S_OUT,i57600,[dec3 rhori\3,” “,dec3 rvert\3,” “,dec3 lhori\3,” “,dec3 lvert\3,” "]
’ serout S_OUT,i57600,[13]
return

[/code]

there it is

hopefully someone with some ATOM experience will come along and clear up whatever misinformation I’m about to give you :slight_smile:

What controller button are you using to control the lifting mechanism now? Which channel would you like to put the second servo on?

im using the R1 to lift the bucket, and the R2 to lower it

i think itd b easiest to use the L1 to lift and L2 to lower the bucket

im sure i could also learn a bit by comparing the 2 codes too

o yea, if it really matters, i think it would make everything easier if the pin that the new servo code would b Pin 15, if you can do that

I don’t see any button mapping to the labels (such as R1 or L2) so I can’t help you with the remapping (someone else surely can), but here’s what I think will enable the inverted pulse on pin 15

uncomment

'   pulsout 15,servo5 

by removing the apostrophe.

just before that line add:

servo5 = 2250 - servo4

I’m making it up as I go here, so use the above code at your own risk. It will burn your house down and kill your pets.

signing out for tonight, but I’ll check back here tomorrow.

'Scoop up/down temp=button ' Filter out all but bit , L1 if temp=0 then ' If button is pressed then do the following. servo5 = servo5 - 25 ' Lift scoop if servo5 < 750 then ' Hold value to a 750 minimum servo5 = 750 endif endif temp=button ' Filter out all but bit , L2 if temp=0 then ' If button is pressed then do the following servo5 = servo5 + 25 ' Lower scoop if servo5 > 2250 then ' Hold value to a 2250 maximum servo5 = 2250 endif endif

This is what i slapped togther last night, id b happy if you could check it over, and if anybody knows wat bit L1 and L2 are, could you please tell me?

also i made sure i added the Pin and servo to the code too like this

pulsout 15,servo5   ' Scoop L. up/down

i hope i did ok for 20 min of studying the code for 10 mintues and coyping things, please tell me in the morning, im out

-Jared

It can probably be done mechanically, as well:

Physically reversing servos is possible, but may be difficult, depending on the physical construction of your particular servo. Ideally, your motor would be a simple desolder-and-rewire job, swapping the leads to reverse polarity and thus rotation. Don’t(!) try to run it this way though, as it will try to “correct” in the wrong direction, and run into and/or past the endpoint. You’ll also need to reverse the wiring of the feedback pot so that the signal tracks in the right direction with relation to the output shaft.

Though I didn’t actually perform these modifications on it just now, I just cracked the case of a fairly recent (less than a year old) Hitec HS-422 servo, and it looks like it would be easily modified in this way - neither the motor nor the pot are hard-mounted to the board, and a few wire swaps are all that would be needed.

This is probably more work than just modifying the control code, and it’s certainly harder to undo the changes - the result being a servo that operates mirror-image to what you’d expect - but it’s another option.
(I should also point out that you’d be modifying the electrics of your servo, and all the caveats that go along with poking around inside a well-balanced electronic system)

We used to do this all the time back before the earth had cooled, vast herds of RC-10s roamed the radio-control racetracks, and servo reversing wasn’t always an available option on the low-budget transmitters.

yea, idk if thatd be the best idea with me, 1. it would probably blow up in my face for some crazy reason and 2. even if i did it perfectly right, it wouldn’t work anyway, thats how my luck is :laughing:

The code you posted seems pretty much along the right lines assuming you get those mask values.

The suggestion I made above of adding “servo5 = 2250 - servo4” will make calculate a value for servo5 that is the inverted value of servo4.

Take things one step at a time. Until someone points you towards the correct mask bits to change the controls, stick with the current controls and try to get the extra channel going. Once that’s working and you find the mask bits for the other button, then switch them both over.

ok, i found some mapping for the PS2 button, however, its not right, and also tinkered around with the bit # in the program, and ran it, i got L1 functioning but, its not cooperating, and the servo turn straight to fialsafe point, i think, all the same it doesn’t work

where exactly do i add that andy?

Here is a pretty concise tutorial on that.
lynxmotion.com/images/html/build034.htm
:smiley:

you can add

servo5 = 2250 - servo4

any place before

pulsout 15,servo5

yea jim, i found that, but it still doesn’t work, and the mask bits u have in the program im using contradict that tutorial :confused:

ok, it works, i just put one of the servos on a channel that was already programmed in, dont know y i didn’t just do that when andy told me to :blush:

all the same hoever, id like to get the shoulder buttons to work the scoop instead of R1, R2 and left and right on the D-pad :laughing:

well the scoop works good, ill need to put some counter weight in the back though, i tried to lift a shoe, got it up and went over a little bump and…it pulled an endo or backwards wheelie, also the test servos i was using, the little holes on them, they snapped, so my scoop is out of commission until i order the new servos and brackets off the main site

o yea, i thought of a new idea so i can dump :smiling_imp:
have like a servo or small acuactor on the side of the scoop with a rubber pad in the end of a rod, and when i want to dump, i just push the rubber pad into the ground and presto, the bucket stops and the rover gets lifted up and it dumps :open_mouth: , quite crude, i no, but it will definatley be safer than my other crazy silly idea

-Jared

Chunga, got any pics or videos of your project now that you have it working? huh huh huh? :laughing:

yea mike, ill see if i can some how strap the servo on, gimme like, 5 min, and ill have some for all u little kiddies

img485.imageshack.us/img485/9008/picture0066sk.th.jpg

img485.imageshack.us/img485/8117/picture0072ai.th.jpg

img361.imageshack.us/img361/3308/picture0082lu.th.jpg

Video: media.putfile.com/Scoop-in-action

there ya go guys, my finished but not finished rover