SD21 servo board - servo "stutter"

PatBig

Member
Hello, I am getting close to having a rowing sequence worked out for my project, a 1/6 scale McKenzie river drifboat. However I am dogged by a smaller problem. Though I am using identical servo, two pairs, one of each pair, the second. The other two servos go smoothly from one end to the other. in each sequence in my code, always "hesitates" about two thirds of the way on the forward move before go fully into position. I have tried varying pause and speed, does not seem to make a difference, except hat at very low speed the stoke is much reduced. Here is the code. In summary: in the Avtoute routine servo 1 works fine, servo 2 hesitates on the servo2p command but works OK on servo2n. If I also enable servo 3 and 4 servo 4 will have the exact same problem. Here is a youtube short film. Rowbot test
Here is the code, please look at avtoute and Artoute subroutines.
Thanks for your help.

Symbol servo1 = 63 'servo 1 base register, servo 1 and 3 move oars up/down
Symbol Servo1p = 84 'Servo 1 positive offset register
Symbol Servo1n = 105 'servo1 negative offset register
Symbol Servo2 = 64 'servo 2 base register, servo 2 and 4 move oars back/forth
Symbol Servo2p = 85 'Servo 2 positive offset register
Symbol Servo2n = 106 'servo2 negative offset register
symbol servo3 = 65
symbol servo3p = 86
symbol servo3n = 107
symbol servo4 = 66
symbol servo4p = 87
symbol servo4n = 108
;symbol servo5 = 67
;symbol servo5p = 88
;symbol servo5n = 109
symbol Speed = 30 ;medium slow speed
symbol base = 120
symbol Offset = 50 '+/- 50 from center position

w0 = 0
w1 = 0


ProgStart:
i2cslave $c2,i2cslow, i2cbyte 'setup i2c port for servo controller
hi2cout 126,(90) ;memorize power up position
hi2cout 0, (100) ;faster speed for up/down movement
hi2cout 3, (speed)
hi2cout 6, (100) ;faster speed for up/down movement
hi2cout 9, (speed)

MainLoop:

hi2cout servo1,(base) ;all servos center position
hi2cout servo2, (base)
hi2cout servo3, (base)
hi2cout servo4, (base)
pulsin C.6,1,w0 ;go forward
if w0 > 165 then
goto Avtoute
Endif
if w0 < 135 then ;reverse
goto Artoute
Endif
;pulsin C.7,1,w1 ;left turn
;if w1 > 165 then
;goto Virgauche
;endif
;if w1 < 135 then ;right turn
;goto Virdroite
;endif
Goto Mainloop

Avtoute: ;all servos synchronize to row forward

hi2cout servo1n,(offset)
;hi2cout servo3n,(offset)
Pause 400
hi2cout servo2p, (offset)
;hi2cout servo4p, (offset)
pause 800
hi2cout servo1p, (offset)
;hi2cout servo3p, (offset)
pause 400
hi2cout servo2n, (offset)
;hi2cout servo4n, (offset)
pause 800
Goto Mainloop

Artoute: ;all servos synchronize to row backwards

hi2cout servo1n,(offset)
;hi2cout servo3n,(offset)
Pause 400
hi2cout servo2n, (offset)
;hi2cout servo4n, (offset)
pause 800
hi2cout servo1p, (offset)
;hi2cout servo3p, (offset)
pause 400
hi2cout servo2p, (offset)
;hi2cout servo4p, (offset)
pause 800
Goto Mainloop
 

lbenson

Senior Member
Not helpful for your problem, but
1) There seems to be some editing issue with the 3rd and 4th sentences, which make it unclear what the problem is.
2) For the sake of context, it's usually better to continue your original thread rather than start a new one. If you don't mind, could you ask the moderators to move this?
3) Is your video supposed to illustrate the problem? If so, I'm not seeing it.
 

PatBig

Member
Hello, thanks for your answer, I did mix two posts sorry. The problem is hard to spot, just a very short stop when the servo on the left - servo2 - moves the oar forward, left to right. It's easier to spot looking at the oar. The same servo moves the other way smoothly. Servo1 on the right under the board works ok both ways. The code is under the Avtoute and artoute subroutines.
 

hippy

Technical Support
Staff member
Here is the code. In summary: in the Avtoute routine servo 1 works fine, servo 2 hesitates on the servo2p command but works OK on servo2n. If I also enable servo 3 and 4 servo 4 will have the exact same problem.
One route for investigating what's going on is to disconnect them from whatever they are physically controlling ( the oar or whatever ), mark them "1" and "2", double check servo 1 works fine but servo 2 hesitates. Then swap servo 1 for servo 2 by switching their control signals over.

If the fault moves with the servo, that is servo "2" still hesitates, then it would appear to be a servo issue.

If instead servo "2" works fine but servo "1" now hesitates it would seem to be an issue with the servo driver or the PICAXE software.

You can double check by driving both servos off the same control signal. If both run fine on the "1" channel both servos are both okay. If both hesitate on the "2" channel both servos are okay, and the issue is driver or software. If hesitation occurs with one but not the other it would seem to be a servo issue.
 

PatBig

Member
Thanks. I have tried 4 separate identical servos, they all work fine as servo 1 and hesitate as servo2. If if include servo3 and servo4 with the same instructions as 1 and 2 , servo4 will hesitate like servo2. So it has to be my code, or a feature of the board. I can't see what's wrong with the code though, it's quite straightforward, that's my issue. The board has some features I do not quite fathom, like if I drastically reduce the speed of a servo, to 10 for instance on a scale up to 255, the servo will actually slow down a lot but the amplitude/range of the movement will be drastically reduced.
 

hippy

Technical Support
Staff member
I can't figure out what the problem could be but it might be worth temporarily extending the PAUSE commands to 2000. If all servos then move smoothly it is presumably a timing issue or a moving servo temporarily halting when a move of the other servo is being initiated.

That second possibility can probably be tested for by having a single servo swing forward and backwards at a leisurely rate with a reasonably long time PAUSE. That should be smooth.

Then insert some rapid movements of another servo between moves. If that causes the first to hesitate it is presumably the updating causing the hesitation.
 

PatBig

Member
Thanks, I'll try that. I agree that it does seems something in the sequence makes the first servo "pollute" the second one in each pair. I'll do some more trial and error and report back if I make progress. Cheers Patrick
 

erco

Senior Member
I haven't used the SD 21 servo controller board, but in watching your video I have to wonder if you even need it. You are only driving one servo at a time, that's a cake walk for a Picaxe. I have been amazed at the Picaxe 20M2's ability and stability to move multiple servos at once. I'll bet if you ditch the SD21 and those I2C commands you'll get to a working solution faster.

For instance, here's my robot arm demo moving multiple servos simultaneously:

 
Top