cool, its definitely getting closer, bothe sides are now controled by L1 and L2
ok so I found the value that was off. Originally it was like this
ServoUpdate:
serout SSC_OUT, SSC_BAUD,"#15P", DEC ldrive, "#14P", DEC Ldrive, 13]
seems like both were set to left side so I just changed the latter drive to Rdrive and it worked. Im pretty excited this is really cool stuff
oh well done. my mistake.
i will try and throw some codes to you this week, im a bit busy here at present but if i get a change ill post some code sections to you.
have you learned much from the current code i wrote?
to add servos to this you would need to define them like this.
Add the variable at the start of the code.
Servo1 var word
you would need to update the servo driver.
first define the pin number (replacing the ?) servo name (servo) or what ever you wish to call it.
we use 13] at the end as a Return or Closing character.
[code]ServoUpdate:
serout SSC_OUT, SSC_BAUD,"#15P", DEC ldrive, “#14P”, DEC ldrive, “#?P”, DEC Servo1, 13]
return [/code]
if you feel you wish to get it moving you can use simple servo commands by setting up a button for the command. here i have used X
we start by saying IF the button is pushed THEN
then followed by the servo positions. Do you know how servos work?
1500 is center. if you went to 1900 the servo would move clockwise about 45º and if you used 1100 it would be about -45º
also we need to add the ServoUpdate Subroutine before the end. this updates the servo pins.
At the end you need to close the IF command by using ENDIF
[code] IF (DualShock(2).bit6 = 0) THEN ;Cross Button test
servo1=1500: servo2=1500: servo3=1500:
gosub ServoUpdate
ENDIF[/code]
this code would center the selected servos.
the servos will move very quickly to a given position as we haven given a time command, i will go though this asap. gotta pop out for a second.
Good Luck.
Yes, Ive actually been really trying to dissect your code and feel like Im understanding how things function a little better. I made a copy of your code and tried to mess around with it a bit. I tried to make it go in reverse, but ended up crashing the processor But gotta learn one way or another. I will get the hang of it though, in the meantime reading through what you have done has been immensly helpful. Im gonna mess around with the servo stuf you just posted and see what happens. Hopefull I dont explode
alrighty, good news bad news scenario. The good news is I got it to work exactly as you described, the bad news is I blew out the wast servo But its a 422 and I have a ton of those. So now I would like to try to make it so that the servo only responds while the button is pressed down. I would also like to ease into the command, not sure if that makes sense. Im gonna have to upgrade to better servo for the waist though because the upper body is heavy and has alot of momentum. Otherwise though, it was really cool
Ok so I was experimenting and I used the following line to do what I mentioned before in regards to only moving the servo while the button is held down
[code]
Servo1 = (Servo1 - DualShock(1).bit525 + DualShock(1).bit725) MAX 2250 MIN 750 'Rotate Waist.
[/code]
Im pretty happy it worked. I have been anaylizing your code and the ps2a4wd1.bas to get these results.
Im starting to understand defining variables and what not in the beggining of the code. Pretty cool stuff. I would eventually also like to get the triggers to throttle up od down in both forward and reverse but based on button pressure to determine speed. Its exciting stuff
Just to make a useless comment, I’ve been following this thread and I would like to say that I’ve been learning stuff too since I don’t errrrrrr didn’t know how to program a robot to go using the PS2 controller. So you’re a really good teacher, innerbreed.
That is excellent robo1340, the more people that benefit from this the better. Innerbreed has been immensly helpful and Im hoping this thread helps alot of people program their machines using the ps2 because honestly I couldnt find anything very comprehensive for begginers.
Guess I should make this a sticky then.
Oops, its good to see you making progress.
yes the 422’s just wouldn’t do for this.
i would say you might get a better chance at replacing it with 2x HS645MG servos together with the ASB13.
in the same way we do for the robotic arms.
good work. you look as though you might be getting the hang of this. we can work on expanding this code more the further we get on.
thanks for your kind words, im always happy to help, but i must say all the experience i have comes from here at Lynxmotion. everyone here has helped me so my knowledge is only the knowledge of others. there are some brilliant people here, who know far far more than i do. like i say just happy to help.
this would be a nice idea jim, you could setup a Beginners section?
Yeah I definitely think I need to go with those 645 mg servos. Cool idea to sticky this thread, I think it could help alot of people I plan on posting videos and more pics soon to demonstrate our results.
On another note, Innerbreed, do you or any one know how I could make the joysticks on the controller send out signals to servos. ultimately I would like to make the servo resposition itslef based on the position of the joystick. Any ideas?
So I managed to control one of my servos using the right joystick with this piece of Phoenix code
Servo3 = (Dualshock(5) - 128)/2
Now I would like it to behave interactively so the servos position is determined by the position of the joystick. I will keep experimenting and studying to see if I can achieve it, if you have any ideas how to achieve that innerbreed, I would love to hear them.
Thanks
D
try something like this.
you ready… Gulp!!
add this to the start with the other variables
servo1 var word
also add this to the constants. you can edit the min/max number of º it can move here. iv used 20º to be safe.
servo1_MAX con 20
servo1_MIN con -20
Add this to the Variables too.
servo1Angle var sword ;Actual Angle of servo1
ok just before [main] add this. this will return the servo to center when you let go of the stick.
serout SSC_OUT, SSC_BAUD,[servo1\(servo1Angle + 0)\0]
then add this in [main] next to the GOSUB ServoUpdate sub.
GOSUB CheckAngles
Then add this part to your Controller section. its for X-axis Right stick horizontal movement.
IF (ABS(DualShock(3)-128) > DeadBand) THEN ;X-axis Right stick horz
servo1Angle = servo1Angle + ((Dualshock(3) - 128)*4)
IF servo1Angle > 1200 THEN
servo1Angle = 1200
ELSEIF servo1Angle < -1200
servo1Angle = -1200
ENDIF
;serout s_out,i14400,[sdec servo1Angle, 13]
serout SSC_OUT, SSC_BAUD,[servo1\(servo1Angle + 0)\0]
ENDIF
Also, add this part to the very bottom of the code.
CheckAngles:
servo1Angle = (servo1Angle min servo1_MIN) max servo1_MAX
return
Also remember to update your servo driver with servo1,
here i have used pin 13. you can change this to what ever pin you have it connected to. also you can change the name of the servo.
[code]ServoUpdate:
serout SSC_OUT, SSC_BAUD,"#15P", DEC ldrive, “#14P”, DEC ldrive, “#13P”, DEC servo1, 13]
return[/code]
a nice quick way to change the name of a word though out the whole code is to press
Ctrl+H
type in the word you wish to change and also the new word. then click on “Whole file”
click ok.
then it should scramble thought the code and change that selected word.
good luck.
most of the code i have added here will also be used for the rest of the code when we add it so dont just think this is all just to get one servo working this way.
it might be a good idea to just connect up a single servo thats not built into your robot when testing this… well any code i post really. lol.
Nice, I will be trying it tonight. I finally got some more parts I needed and Im waiting now for the airsoft gun and some braided cable sheaths to clean up and protect the cables. I will be posting more closeup images in the next day or two and probably a video or something if I get some cool functionality going.
this would be great and very helpful.
let me know how you get on.
Update on my progress:
Didnt get to do any coding last night. I got some parts to completete my mech, but didnt get to finish that either. I did however finish the gripper claw assembly and it is now fully functional with the servo. Hopefully tonight I will have the SCC32 mounted onto the bot and can start having everything more neat. Then Im gonna try some more coding. I will be posting pics tonight or tommorow.
this will be great. then we can start getting the code together. looking forward to seeing the gripper. 8)
any progress?
one small error with:
serout SSC_OUT, SSC_BAUD,[servo1\(servo1Angle + 0)\0]
ill update the code and post it here once done.
i hope i have fixed the problem. also i am hoping that now when pressing L2 and R2 it will bring the forward speed down as well as “Reverse”
let me know how it works out.
ps2_ssc_test3.bas (8.33 KB)
Hi Innerbreed, Unfortunately this weekend was crazy for me due to Easter. I did however get to clean up and modify some aspects of my robot. I think I still want to optimize some parts of the arm though. But tonight when I get home Im definitiely gonna be applying your suggestions to the code and seeing how it works. I wanted to purchase some more parts to modify the machine even more, but the funding I requested was denied (Wife shut me down till the summer) so I had budget cuts to the robotics department I need a stimulus package there. So for now Im going to be focusing on the programming aspect for a while because I have everything I need to get it fully functional although not to the specs I had in mind. So long story short, tonight definitely programing