Boredom Killer - Arduino Robot Arm Project

A place For General Chit Chat Etc
Post Reply
User avatar
Jayme
Posts: 2585
Joined: Sun Mar 01, 2009 8:59 am
Location: North Coast, NSW

Boredom Killer - Arduino Robot Arm Project

Post by Jayme »

So,
I got bored and wanted to find something interesting to do with my spare arduino.. after some research, I found that you can buy a usb host shield for the arduino, and plug in a microsoft xbox controller usb receiver into it, then code it up to control anything... ideas galore arrived.. including my mate begging me to make his ride on mower radio controlled :roll:

so I started looking into how to make an easy robot arm. after a while I stumbled across an R/C servo driven robot arm kit! cheap enough that I figured bugger making one... ill just build the kit! Link

so while it was in the post, Holden202 gave me some spare servos to play with :punk: and I began coding up the controls. I took the xbox controller library, and the r/c servo library and basically loaded them both into my project and started mapping controls to servo position. its tricker than you think, because an r/c servo wants to be given an absolute position, so if you map it directly it acts like a steering servo, let go of stick and it drives back to the center position. NOT what we want for a robot arm, so I coded up a few loops to slowly tick the servo position value back and forward, to make the controls more like an excavator. it even has speed, the further you push the stick, the shorter the loop and the quicker the servo ticks forward.

anyways, here is the result after I built the robot arm and hooked it all up! I needed some 5v power for the high torque servos, so I ran some speaker wire out of a hard drive connector 5v line in my pc lol...
The kids love it, a big toy.

[youtube]https://www.youtube.com/watch?v=sjsuNJmUKfo[/youtube]
20170406_200146.jpg
Dylan
Posts: 3356
Joined: Mon Aug 02, 2010 6:35 pm
cars: VR Commodore V8

Re: Boredom Killer - Arduino Robot Arm Project

Post by Dylan »

That's cool as well done
User avatar
antus
Site Admin
Posts: 8250
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Boredom Killer - Arduino Robot Arm Project

Post by antus »

Real nice work getting the controller to work so smoothly!
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Jayme
Posts: 2585
Joined: Sun Mar 01, 2009 8:59 am
Location: North Coast, NSW

Re: Boredom Killer - Arduino Robot Arm Project

Post by Jayme »

I remembered seeing a neat idea somewhere for the speed code, where instead of locking up the code with a wait command, you just take a timestamp, then save the current system clock in a variable eg: 'timer' and the speed variable is a millisecond value. so you just have an IF system clock > timer1 + speed value then re enter the code to increment servo position. the speed variable is then mapped to the analog stick axis value. it worked really well, but having to reverse the axis values from the xbox controller (speed value is smaller = faster, but controller is a larger value the further the stick moves) so it took me a little while of brain pain in excel to get the speed formulas right. We used to tell the maths teacher at school, we would never ever use this shit. well the teacher was proven correct tonight.

Code: Select all

if  ((Xbox.getAnalogHat(LeftHatX, i) < -7500)&& servo1pos < 180) {
            servo1speed = (32768+Xbox.getAnalogHat(LeftHatX, i))/400+5 ;
        
        if (millis()>=(servo1timer+servo1speed)){
            servo1pos=servo1pos+1;
            myservo1.write(servo1pos);
            servo1timer = millis();
            Serial.print("Servo1 Position:"); 
            Serial.println(servo1pos);
        }

          }
on a side note... the arduino does struggle a bit, trying to keep up with the PWM control of 6 servos at once. when its still, you can see it twitching a bit lol.
User avatar
antus
Site Admin
Posts: 8250
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Boredom Killer - Arduino Robot Arm Project

Post by antus »

Hardware or software pwm generation?
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Jayme
Posts: 2585
Joined: Sun Mar 01, 2009 8:59 am
Location: North Coast, NSW

Re: Boredom Killer - Arduino Robot Arm Project

Post by Jayme »

its all software PWM... it can use any digital pin, not just the PWM ones (there wouldnt be enough for 6 servos anyway), so its not unexpected for the PWM signal to be a bit less than perfect.

you can buy a servo control sheild that will give accurate control... maybe ill look into that later on.
User avatar
Holden202T
Posts: 10311
Joined: Sat Feb 28, 2009 9:05 pm
Location: Tenambit, NSW
Contact:

Re: Boredom Killer - Arduino Robot Arm Project

Post by Holden202T »

Definitely a good project! :thumbup:

reminds me of that movie Malcolm :D
User avatar
VL400
Posts: 4991
Joined: Sun Mar 01, 2009 2:54 pm
cars: VL Calais and Toyota Landcruiser. Plus some toys :)
Location: Perth, WA
Contact:

Re: Boredom Killer - Arduino Robot Arm Project

Post by VL400 »

Very cool indeed. Teach it to write your forum posts? :think:
Jayme wrote:when its still, you can see it twitching a bit lol.
Its not just arduinos that do that :lol: Too many shed fumes.
User avatar
Holden202T
Posts: 10311
Joined: Sat Feb 28, 2009 9:05 pm
Location: Tenambit, NSW
Contact:

Re: Boredom Killer - Arduino Robot Arm Project

Post by Holden202T »

lol :)
User avatar
The1
Posts: 4694
Joined: Mon Jan 04, 2010 10:23 am

Re: Boredom Killer - Arduino Robot Arm Project

Post by The1 »

I wish I had a bordom problem instead of lack of time problem. Lol feel free to code enhanced lol, well done on the project, were doing this with highschool kids now where they have to design a arm, 3d print it then assemble and code it to solve a problem, tea dunker it is lol
Post Reply