Not sure if this goes in this section, the arm section, or the servo section, but this one seems to be the best choice.
I’ll post multiple bits of code, full code is really long. I’ll add notes along the way.
This bit works and moves all 3 servos, keeping the servo connected to drive6 level.
Code1
elseif (cbot = 1001 and drive2 < 15500 and drive4 < 12250 and drive6 > -15000 and change = 0 and switcher = 1) ;Extend Arm
drive2 = drive2 + 250
drive4 = drive4 + 250
drive6 = drive6 - 50
change = 1
goto pantilt
elseif (cbot = 1002 and drive2 > -10000 and drive4 > -14250 and drive6 < 12000 and change = 0 and switcher = 1) ;Retract arm
drive2 = drive2 - 250
drive4 = drive4 - 250
drive6 = drive6 + 50
change = 1
goto pantilt
This bit of code only moves the servo connected to drive4, and though the number changes on drive6, the servo connected to drive6 doesn’t move.
Code2
elseif (cbot = 1007 and drive4 < 12250 and drive6 > -15000 and change = 0 and switcher = 1) ;Second arm down
drive4 = drive4 + 250
drive6 = drive6 - 50
change = 1
goto pantilt
elseif (cbot = 1008 and drive4 > -14250 and drive6 < 12000 and change = 0 and switcher = 1) ;second arm up
drive4 = drive4 - 250
drive6 = drive6 + 50
change = 1
goto pantilt
Heres my servo driver code.
pantilt
if change = 1 then
hservo [p0\drive6\150,p1\drive3\150,p2\drive5\200,p3\drive4\150,p5\drive1\150,p6\drive2\150]
hservowait [p0,p1,p2,p3,p5,p6]
change = 0
goto main
endif
goto main
Now then it doesn’t make sense, the second bit of code is almost identicle to the first bit, except it doesn’t effect drive2.
Unless i’m not seeing something.
one the second bit of code, both the drive4 and drive6 values change, but only the servo connected to drive4 moves.
Edit: This problem is so weird. When the drive6 value changes in the second code bit, and the servo doesn’t move, the drive6 value does infact change.
HOWEVER, when i use a code that DOES move servo(drive6) it doesn’t jump to the new value. It pretends the the code never changed.
So if i use code2, to move the second arm up and drive6 doesn’t move, but it’s code changes, when i use the first code(that moves all 3 servos) servo-drive6 doesn’t jump, and instead pretends the new value from code2 is the original code.
Example
If drive2,4 and 6 = 0, and i use code2 10 times,
drive2 = 0 (unchanged)
drive4 = 2500
drive6 = -500.
So servo-drive6 should be at the position of 500, but is still at position 0, even though value-drive6 = 500.
Then if i use code1 10 times
drive2 = -2500
drive4 = 0
drive6 = 0
But drive6 will actually be at position 500, even though the value says 0.
It’s like code2 is resetting drive6’s “position 0”.
I’ve attached my entire code.
Edit2:
I’ve seem to have a bit of progress by changing code2’s drive6 alternation values from 50’s to 265’s.
New Code2
elseif (cbot = 1007 and drive4 < 12250 and drive6 > -15000 and change = 0 and switcher = 1) ;Second arm down
drive4 = drive4 + 250
drive6 = drive6 - 265
change = 1
goto pantilt
elseif (cbot = 1008 and drive4 > -14250 and drive6 < 12000 and change = 0 and switcher = 1) ;second arm up
drive4 = drive4 - 250
drive6 = drive6 + 265
change = 1
goto pantilt
I don’t know why this is going on though. With +/-50 it didn’t move at all. zip-nada. But at 265 it keeps level.
I don’t understand this, oh well, as long as it’s kinda working now, maybe you guys have some answers. I’ve never had an arm with 6 points of movement before.
Base rotate
pan/tilt arm 1
elbow arm 2
wrist up/down
wrist rotate.
grabber
temp3.bas (6.4 KB)