Robotic Arm Control

I have built a robotic arm. You can see it in the robot section. It is called IPTUPED.

Now that it is built i can only prgram it to pick up something that is in the same time. I need a new control method.

Due to the fact that i am pretty new to this i need some ideas. Basically i am asking you guys if you can help me find a good method. I have seen wii and arduino, nd rc. I need a good tutorial online somewhere that can help me control it. So far i have only been able to find a method that can control 2 servos. I am using 4 and maybe 5 in the future. Thanks for any help.

 

By the way. Can you view the videos, i cant on this browser???

https://www.youtube.com/watch?v=q2YgCQIJq0Y

I would start with a for/next loop

WOW! Man, you gotta slow those guys down! First off, I would add a routine that would allow you to A) know the current servo positions and B) allow you to input some “requested” positions. The routine would then (at any speed you choose) slowly “step” the servos from position 1 to position 2.

Loop

If currentA>RequestedA then curentA=CurrentA - 1

if CurentA<RequestedA then currentA=CurrentA +1

If currentB>RequestedB…

Pause a little

If currentA==RequestedA and currentB == requestedB then exit this loop

loop

After that, you could build another identical arm, but with pots at the pivots instead of servos. You could “puppet” the “teaching arm” and the real arm would follow. Nunchuck is good too, as is a couple joysticks, some pots on a control panel, etc. etc.  --Oh, using this “teaching arm”, and a EEPROM chip, you can “record” moves as well, and “play them back” later as well.

 

Teaching arm …

I remembered running across this node:

https://www.robotshop.com/letsmakerobots/node/22346

It shows a little about a teaching ‘arm’ that was used for simultaneous control of an arm.

It might give you some ideas.

Thanks

Ok thankyou, do you know of any guides or how-to instructions where i could begin though?

@Chris the Carpenter.I

@Chris the Carpenter.

I understand what you are saying. But i dont exactly know how i could program that.

Not hard.

Say you have 3 servos: Rotate, Sholder and Elbow --Pretty much what you have not including the gripper. You are in position A and you want to goto position B… Smoothly…

You will have (2) sets of (3) variables. One set will be used for the (3) servo’s current position. We will call these variables Current1 current2 and current3. Current1 is the current servo position for rotate, current2 is the current position of the sholder and current3 is the current postion of the elbow-joint servo. We have another set of (3) variables that we will use to tell where we are going. Say you want the arm in a new position, you want to “request” a new position. Actually, you want to request a new position for all 3 servos. Thus we will call these 3 variables Requested1, Requested2 and Requested3. Again, these are just different names for b3,b4 and b5.

We start everything by centering all the servos at the beginning of the program. All the servos need to start at say, position 125. Now, “seed” all the “currents” and “requested” with 125. Current1=125, Current2=125, Requested1=125… etc. etc.

Now when we go into the main program loop, the servos are all at position 125, all the “current” variables are at 125 and “where we want to go” (requested) are all at 125 as well. We know where we are, and we want to go where we allready are.

To Make a “Move” you need a simple subroutine. Lets say we just started (so we are centered) and we want to raise the arm. Lets also say that the “raised arm” numbers are: Rotate 125, sholder 250 and elbow 250. First, we make the Requested variables reflect what we want. Requested1=125, Requested2=250 and Requested3=250. Next, you call on your “move servos” subroutine.

Moveservos:

do

If requested1>current1 then current1=current1+1

if requested1<current1 then current1=current1-1

if requested2>current2 then current2=current2+1

if requested2<current2 then current2=current2-1

if requested3>current3 then current3=current3+1

if requested3<current3 then current3=current3-1

servo pin,current1

servo pin,current2

servo pin,current3

pause a little to control overall speed

loop until current1=requested1 and current2=requested2 and current3=requested3 '<–when everything matches, we are where we want to go

return


That’s it --If what you want is different than what you have, step a little until you are there. You may need to add some min/max’s to stay on the safe side. It is a chunky way to do it, but it will work fine.

Ok

Below is what i have. Like i said i am very new to prgramming but it doesnt recognized the Current 1 as a variable? Whate should i do??

 

 

 

Servo 0, 150
Servo 1, 150
Servo 2, 150
Servo 3, 150

Current1=150
Current2=150
current3=150
requested1=150
requested2=150
requested3=150

Moveservos:

do

If requested1>current1 then current1=current1+1

if requested1<current1 then current1=current1-1

if requested2>current2 then current2=current2+1

if requested2<current2 then current2=current2-1

if requested3>current3 then current3=current3+1

if requested3<current3 then current3=current3-1

servo 0,current1

servo 1,current2

servo 2,current3

pause a little to control overall speed

loop until current1=requested1 and current2=requested2 and current3=requested3 '<–when everything matches, we are where we want to go

return

Oh, Sorry…

I didn’t know you were quite so new…

Current and Requested are not variables according to picaxe. You need to substitute say, b1,b2,b3 for current1,current2,current3 within the program or “declare” them at the start of your program. I think it is symbol Current1 = b1, Symbol Current2 = b2 etc. You will need to do this with variable you want to “name”. The rest of the code I put in the post above was not really intended to work… It sorta needs to be cleaned up a bit. For instance, “pause a little to control speed” is not really a command. In addition, it has been a while since I have programmed in picaxe so for example, the do/loop until command might be set-up wrong and need a little cleaning up.

You will also need a main routine to “call” on the moveservos subroutine. The main could be like:

main:

requested1=whatever

requested2=whatever

requested3=whatever

gosub moveservos

requested1=whatever

requested2=whatever

requested3=whatever

gosub moveservos

requested1=whatever

requested2=whatever

requested3=whatever

gosub moveservos

goto main

 

–Something like that. You do get the whole concept here, right? Can you see in the “moveservos” loop how each servo gets “stepped” (one “click” at a time) until it matches the “requested” value? Also, do you get the whole “if all the currents = all the requested” thing? Let me know where you are stuck. Remember! All the commands you need are in the manual. How routines and subroutines work, do/loop commands, etc.

 

Ok

I get the basics. So if i have…

symbolCurrent1=b1
symbolCurrent2=b2
symbolcurrent3=b3

…do i have

symbol requested1=b4
symbol requested2=b5
symbol requested3=b6

**That is correct **

Yup. That is how you should start your program.

Ok Now…

I Symbol Current1=b1
symbol Current2=b2
symbol current3=b3
symbol requested1=b4
symbol requested2=b5
symbol requested3=b6

Main:                
Requested1= 150 'i am requesting the servos all to go to the center position
Requested2= 150
Requested3= 150
Gosub Moveservos
Requested1=100
requested2=100 'i am reuesting servos to move to 100 position
requested3=100
gosub Moveservos
requested1=200
requested2=200 ’ i am reuqesting servos to move to 200  position
requested3=200
gosub Moveservos
goto Main

Moveservos:

do

If b4>b1 then b1=b1+1 'if requested posititon is greater than current position then current should move +1

if b4<b1 then b1=b1-1 'if requested posititon is less than current position then current should move -1

if b5>b2 then b2=b2+1 'if requested posititon is greater than current position then current should move +1

if b5<b2 then b2=b2-1 'if requested posititon is less than current position then current should move -1

if b6>b3 then b3=b3+1 'if requested posititon is greater than current position then current should move +1

if b6<b3 then b3=b3-1 'if requested posititon less than current position then current should move -1

servo 0,current1

servo 1,current2

servo 2,current3

wait 2

loop until b1=b4 and b2=b5 and b3=b6 'when everything matches, we are where we want to go

return

 

this is what i think i should write but it doesnt work it says…

If b4>b1 then b1=b1+1 'if requested posititon is greater than current position then current should move +1

                          ^

                          ^

            b1 should be a label not a variable

what does that mean???

Getting close.

A little more clean up and a little more explaining.

First off, all the comments (anything after a ’ ) is just a comment for yourself --not the computer so you can write anything you want. The notes you have written all seem to be correct.  Tell you what, gimme an hour and I will write the code for you. --You have put in a lot of work already, lets just get this working.

Be right back.

Done. Let me know if it works.

Alright --I need a refresher in picaxe Basic --I missed a bunch of endif’s and a bunch of let’s too. I have fixed it all now and it seems to compile. It will probably work right out of the box… I hope.

HERE is the file to download. Don’t click the big button when you get there, it is an ad. Look around and download “Servo Move Sample.bas”.

–or–

Cut and paste from here.

symbol Current1=b1
symbol Current2=b2
symbol current3=b3
symbol requested1=b4
symbol requested2=b5
symbol requested3=b6

‘‘  From now on anytime we say “current1” it is the same as saying “b1”  ****
’'
  From now on anytime we say “requested3” it is the same as saying “b6” ****
’’*****                  etc.        etc.           etc.                      

current1=150
current2=150
current3=150
requested1=150
requested2=150
requested3=150

servo 0,current1
servo 1,current2
servo 2,current3

pause 1000

’'
now all the servo numbers are centered and the servos themselves are centered  *****

Main: 
             
Requested1= 150 'i am requesting the servos all to go to the center position
Requested2= 150 ''You are correct --but they are already centered, it will basically skip this
Requested3= 150
Gosub Moveservos
Requested1=100
requested2=100 'i am reuesting servos to move to 100 position
requested3=100
gosub Moveservos
requested1=200
requested2=200 ’ i am reuqesting servos to move to 200  position
requested3=200
gosub Moveservos

goto Main


Moveservos:

Do

If Requested1>Current1 then let Current1=Current1+1
endif
if Requested1<current1 then let current1=current1-1
endif
if Requested2>current2 then let current2=current2+1
endif
if Requested2<current2 then let current2=current2-1
endif
if Requested3>current2 then let current2=current2+1
endif
if Requested3<current2 then let current2=current2-1
endif

servo 0,current1
servo 1,current2
servo 2,current3

pause 100

loop until current1=Requested1 and current2=Requested2 and current3=Requested3

return

Ok thanks
Thank you so much I really appreciate it… Btw I knew the whole comment part and I will be back in a couple minutes to let you know

Yeah…

yeah, I thought you did. :slight_smile:

–Gotta be sure so we can get the basics outta the way.

Let me know if it compiles and works --It did on my end.

Shorten the pause 100 to speed it up --lengthen to slow it down.

If you want to try to go with bigger steps (current=current+2 or +3 etc.) we gotta change some stuff --if you try this and it doesn’t work, don’t worry --I know how to fix it.

Just lemme know if you get it going.

You owe me a video when it does.

 

This is what i copied

sorry this is edited*** This is wat i downloaded but it didnt seem to work right, it kind of just shook around.

----------------------------------------------------------------------------------------------

symbol Current1=b1
symbol Current2=b2
symbol current3=b3
symbol requested1=b4
symbol requested2=b5
symbol requested3=b6

’‘  From now on anytime we say “current1” it is the same as saying “b1”  ****
’'
  From now on anytime we say “requested3” it is the same as saying “b6” ****
’’*****                  etc.        etc.           etc.                      

current1=150
current2=150
current3=150
requested1=150
requested2=150
requested3=150
servo 0,current1
servo 1,current2
servo 2,current3
pause 1000

’' now all the servo numbers are centered and the servos themselves are centered  *****

Main: 
             
Requested1= 150 'i am requesting the servos all to go to the center position
Requested2= 150 ''You are correct --but they are already centered, it will basically skip this
Requested3= 150
Gosub Moveservos
Requested1=100
requested2=100 'i am reuesting servos to move to 100 position
requested3=100
gosub Moveservos
requested1=200
requested2=200 ’ i am reuqesting servos to move to 200  position
requested3=200
gosub Moveservos

goto Main


Moveservos:

 

If Requested1>Current1 then let Current1=Current1+1
endif
if Requested1<current1 then let current1=current1-1
endif
if Requested2>current2 then let current2=current2+1
endif
if Requested2<current2 then let current2=current2-1
endif
if Requested3>current2 then let current2=current2+1
endif
if Requested3<current2 then let current2=current2-1
endif

servo 0,current1
servo 1,current2
servo 2,current3

pause 100

’loop until current1=Requested1 and current2=Requested2 and current3=Requested3

return

I gotta go for tonight

I gotta go for tonight i will see if i can fix it tomorow or saturday i will let you know.

Thanks for your help and you will get a video when it is working.

No problem

A) did it do anything at all?

B) What DID it do?

 

Yes

 I think i kinda fixed it

A) Yes

B)it just slowly moved like in slow motion. It wasnt a smoth motion it was like a clock, tic tic tic.

 

Also…

Also when the servo turned all the way to the left it like tried to continue turning and made an awckward noise.