Arm with PS2 controller drops when wrist moves

Hi Jim and others,

To try to see what is going on, I have dug out my old AL5D arm that was on my rover. It is now mounted on a block of wood with the heavy duty base rotate. I grabbed a spare SSC-32 and BB2 and I think I have it hooked up now. Some of my first tests broke the spring… (Needless to say there may be an issue or two…) Back in one piece now. May need to recharge battery again…

We now have a few options:

  1. Try to figure out this code and fix it. I always get nervous when I see things like: Work around bug in compiler (4 of them…)
  2. Start of the Rover with Arm code and strip out rover code. I also had earlier issues with some overruns in this code. My local copy had extra checks to keep from the wild swings. Things like if the IK check code says there is an error, don’t go there. Also if we are in an error location don’t keep trying to go farther in that direction…

Note: even if we go with 2) could probably build a version that works with SSC-32 as well. Most of the output is done by one HSERVO command, we do try to detect IDLE… So not a big deal…

Suggestions?

Kurt

I have not yet gone through the old Arm code to see if I can figure out where it it might be overflowing or the like, which was my option 1) in the previous post.

But I did take the Rover with Arm code and strip the rover code out of it. I then changed it to make it such that you could optionally use an SSC-32 to handle the servos… I had two options, I could either add the 2nd connection between the SSC-32 and BB2 to know when a command has completed, or I could use a timer to delay when I output the next command by that amount of time (like the phoenix code does). I choose to do the 2nd approach.

If the line:USE_SSC32 con 1 ; define this one if you wish to use an SSC-32 with this program else undefine it...
Is defined it uses the SSC-32. It assumes that any servo offsets needed are taken care of by the SSC-32. It uses the following pins:
On BB2:

[code]PS2DAT con P12 ;PS2 Controller DAT (Brown)
PS2CMD con P13 ;PS2 controller CMD (Orange)
PS2SEL con P14 ;PS2 Controller SEL (Blue)
PS2CLK con P15 ;PS2 Controller CLK (White)
PadMode con $79

; SSC32
cSSC_OUT con P11 ;Output pin for (SSC32 RX) on BotBoard (Yellow)
cSSC_IN con P10 ;Input pin for (SSC32 TX) on BotBoard (Blue)
cSSC_BAUD con i115200 ;SSC32 BAUD rate 38400 115200[/code]

Note: I use a different IO pin for SSC than the other Arm program did… (In is also not used). Also I am using the baud mode of 115200. You can easily switch these back to the other IO pin and baud rate…

On the SSC-32 I use the IO pins:

BasePin con 0 ShoulderPin con 1 ElbowPin con 2 WristPin con 3 GripperPin con 4 WristRotatepin con 5

If you are not using the SSC-32, the code (like the rover code it was taken from) has servo offset built into it, you may need to update for your own setup.

Not sure if anyone would like to try it or not, but just in case…

Kurt
arm from rover 1.2.bas (33.5 KB)

Looks like you beat me to it, Kurt! I was working on my own version of that code. I got as far as ripping out the rover bits and beginning to add SSC-32 support when I found this. Went ahead and tested it out for you. Appears to work just fine when it is away from the base, but when you get really close it starts to misbehave. If I set the Bot Board offsets to all 0 then it seems to work a little bit better, although not perfect.
I set the IKSolutionErrorBeep to true. Assuming that it works, it doesn’t detect the sporadic movements as an error.
After some serouts, I found that in normal use the speed variable would never seem to go above 150 or so. When the arm got close to the base though, sometimes it would need to jump between two far away places and that would make the speed upwards of 750. Just putting a max of 200 (to give a little leeway, in case my terminal reading speed was a little off) in the getspeed function seems to really help the arm work more reliably by not allowing it to ram into the table like it used to. :smiley:

Waaay at the bottom of the code…

[code];--------------------------------------------------------------------
;[GetSpeed] Calculate the speed for each servo
newpos1 var slong
oldpos1 var slong
longest1 var slong
maxval1 var slong
GetSpeed[newpos1,oldpos1,longest1,maxval1]

if(newpos1>oldpos1)then
return ((((newpos1-oldpos1)*maxval1)/longest1)/10 Max 200)
endif

return ((((oldpos1-newpos1)*maxval1)/longest1)/10 Max 200)
;--------------------------------------------------------------------[/code]

Angles being really tight makes me suspect Trig errors. TAN can get a little rough, for example. But it’s probably just a horse, not a zebra.

Alan KM6VV

[code];--------------------------------------------------------------------
;[GetSpeed] Calculate the speed for each servo
newpos1 var slong
oldpos1 var slong
longest1 var slong
maxval1 var slong
GetSpeed[newpos1,oldpos1,longest1,maxval1]

if(newpos1>oldpos1)then
return ((((newpos1-oldpos1)*maxval1)/longest1)/10 Max 200)
endif

return ((((oldpos1-newpos1)*maxval1)/longest1)/10 Max 200)
;--------------------------------------------------------------------[/code]

The solution is quite beautiful.

viewtopic.php?f=6&t=7923