Putting robotics at your service™

Free shipping on orders over $200

Programming assistance for my new Mech please (PS2)

Print view Share :
Previous topicNext topic

Page 3 of 5 [ 62 posts ]

1, 2, 3, 4, 5
Novice ( offline )
Posts: 72
Posted: 2010-03-31 21:50 
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?


Novice ( offline )
Posts: 72
Posted: 2010-04-01 01:12 
So I managed to control one of my servos using the right joystick with this piece of Phoenix code

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


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-01 17:01 
try something like this.
you ready... Gulp!!

add this to the start with the other variables
Code:
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.
Code:
servo1_MAX con 20
servo1_MIN con -20


Add this to the Variables too.
Code:
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.
Code:
serout SSC_OUT, SSC_BAUD,[servo1\(servo1Angle + 0)\0]


then add this in [main] next to the GOSUB ServoUpdate sub.
Code:
  GOSUB CheckAngles



Then add this part to your Controller section. its for X-axis Right stick horizontal movement.
Code:
       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.
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


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. :wink:

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.

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


Novice ( offline )
Posts: 72
Posted: 2010-04-01 17:49 
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.


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-01 18:20 
Vsions wrote:
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. :wink:
let me know how you get on.

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


Novice ( offline )
Posts: 72
Posted: 2010-04-02 09:33 
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.


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-02 09:39 
this will be great. then we can start getting the code together. looking forward to seeing the gripper. 8)

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-05 06:52 
any progress? :|
one small error with:
Code:
 serout SSC_OUT, SSC_BAUD,[servo1\(servo1Angle + 0)\0]


ill update the code and post it here once done.

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-05 07:20 
innerbreed wrote:
any progress? :|
one small error with:
Code:
 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" :wink:

let me know how it works out.


Attachment:
ps2_ssc_test3.bas [8.33 KiB]
Downloaded 61 times

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.
Novice ( offline )
Posts: 72
Posted: 2010-04-05 09:18 
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


User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-05 09:46 
Vsions wrote:
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



LOL, im with you on the "funding". i brought my wife a laptop and signed her up to clothing catalogs so that keeps her happy. :wink:
anyway..
the code i last posted has had the previous parts added (up to date) and should work as explained. dont quote me on that, i would need feedback on that to alter it if there is a problem.

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


Novice ( offline )
Posts: 72
Posted: 2010-04-06 00:24 
Alright, I tried what you posted and Im not getting any response from the servo. Then I tried incorporating it into the code that I was using to drive the other servos. The other servos do work but the latest additions are non responsive. I did not get to test the actual drive system since I temporarily unmounted the electronis from the robot and detached it from the motor controller so I can program it more easily. I did however reattach all the servos on the proper pins. Attached is what I cobbled together.

Any thoughts? I tired to go through it to see if I could see anything wrong with it but I could not see anything that was off, But I know very little so check it out let me know what you think.


Attachment:
ps2_ssc_testdennis3.bas [8.81 KiB]
Downloaded 56 times
User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-07 15:47 
i did notice that
Servo3 var word
was commented out.
try un-commenting... does it work now. if not then i will look closer at the commands i added.

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


Novice ( offline )
Posts: 72
Posted: 2010-04-08 01:46 
I uncommented that but still didnt get any response. I did however change something in the code that got the servo to respond in each direction but not in realtime . It only goes completely to one direction or another and does not return to center when I let go of the stick. I have attached what I have changed. Let me know what you think, Thanks!


Attachment:
ps2_ssc_testdennis4.bas [9.35 KiB]
Downloaded 59 times
User avatar
Guru ( offline )
Posts: 3300
Posted: 2010-04-08 04:24 
ok its progress. i will run some more ideas this evening and try and give you what is needed. :wink:

_________________
Jonny Poole,
Freelance Concept Art & Animatronics, 3D Art and 3D Modelling, as well as Physical Modelling, Mechanical design, and illustration.
http://www.innerbreed.co.uk
Create, Innovate, Inspire.


1, 2, 3, 4, 5

All times are UTC - 5 hours [ DST ]. It is currently 2014-11-28 05:35
Feedback Form
Feedback Form