Robot hand suddenly has the jitters

IronJungle

Senior Member
I posted up my completed Robot Hand project here a few months ago. Source code and all is at:
http://www.picaxeforum.co.uk/showthread.php?19242-All-about-my-18M2-Robot-Hand

This weekend I am showing a buddy of the coolness of the PICAXE vs his Arduino using my robot hand.

I loaded up my original (and final) version source code into the editor. We looked at the code some and I hit download to PICAXE. Immediately after d/l the servos on the Robot Hand started to jitter slightly when they used to be silent and still. I do recall having the jitter issue before and corrected it with the "servopos 0, off" command. When I re-downloaded this weekend something sure changed and I would like to guidance on what it may be.

Below I have posted a 'shortened' version on the code to make it easier to sort through. The jitter happens even if I put a "STOP" command right before the "do until pinC.1 = 1" loop.

Thanks!

Code:
' PICAXE 18M2 for Hand Gesture Robot JULY 2011
' www.ironjungle.com
' Other than the minium PICAXE 18M2 'keep alive' 22K R & 10K R
' no other R, C, L, etc need for the project.
' Everything powered by 4.5VDC
' The PICAXE drives the servos straight from the chip.  
' See pinouts in comments

' 0 is Thumb (PICAXE pin 6)
' 1 is Pointer (PICAXE pin 7)
' 2 is Middle (PICAXE pin 8)
' 3 is Ring (PICAXE pin 9)
' 4 is Pink (PICAXE pin 10)
' Normally Open Button Switch is PICAXE pin 18 (pulled HIGH with 10K)

'Define Servo values to fully EXtend/Open finger
Symbol Ex_Thumb = 60
Symbol Ex_Pointer = 60
Symbol Ex_Middle = 245
Symbol Ex_Ring = 60
Symbol Ex_Pink = 60

'Define Servo values to fully CLose finger
Symbol CL_Thumb = 225
Symbol CL_Pointer = 240
Symbol CL_Middle = 50
Symbol CL_Ring = 240
Symbol CL_Pink = 240

'Init the servos
servo 0, Ex_Thumb
servo 1, Ex_Pointer
servo 2, Ex_Middle
servo 3, Ex_Ring
servo 4, Ex_Pink

pause 400

servopos 0, off
servopos 1, off
servopos 2, off
servopos 3, off
servopos 4, off

do until pinC.1 = 1 'wait for RED button press (PICAXE pin18)	
	RANDOM w12	' w13 will be use to in Case Statement
	w13 = w12 // 11 + 1 '"//" is modulus divide (returns remainder)	
loop
 

IronJungle

Senior Member
Ha!!! The Robot Hand is on a strict de-caff diet.

It was very strange, because the hand has worked in a perfectly silent non-jittering mode for months. Immediately after the d/l the jitter started. So, I am absolutely 100% know there was no change in hardware. I am 99.99999% I pushed the latest rev of the code into the PICAXE (basically rewrote the identical program into the PICAXE).

As mentioned, I had this issue during the development and upon discovering the "servopos off" command all things were wonderful. Just for kicks, I just tried changing the "servopos off" commands to "low 0", "low 1", "low 2", etc. Same results. The Robot Hand still behaves like it had too much coffee.

Too much coffee???? :)
Sorry, couldn't resist.

Any decoupling capacitors removed/changed?
 

srnet

Senior Member
' Other than the minium PICAXE 18M2 'keep alive' 22K R & 10K R
' no other R, C, L, etc need for the project.

No supply decoupling capacitors ?
 

erco

Senior Member
Why are you using the SERVOPOS off command at all? I think that's causing your jitter. You want a constant stream of pulses and that shuts them off. Try deleting all of those commands at the start of your main: loop.
 

geoff07

Senior Member
Go back to the last version that worked correctly, and do a line by line comparison with the jittery version. There will be the reason.
 

Paix

Senior Member
Well, that sort of blows away my theory.
I have been playing with a servo and as it is designed to operate but twice a day, I power off the servo, which is powered currently (there's a pun in there somewhere) by 4 x AA cells = 6V. In testing it was obviously getting a fair bit of use and I noticed a minor kick upon powering up the servo.

As I investigated a few different options, the problem didn't seem to be improving but in fact it was getting significantly worse and latterly had some exceptionally wild excursions before settling down.

I concluded, but haven't yet proven it, that the voltage had sagged somewhat and that the minor kick that I had been experiencing with a fresh 6V set of batteries could be rectified by a combination of greater battery current capacity and an electrolytic reservoir capacitor to support the volage at the point of servo switch on when the current demand is greatest.

More to the point from a confidence point of view, what version of PE did you use successfully and what version are you using now?

I asked some time ago and got an answer, but it wasn't quite the answer that I was looking for. My question at that time was, where can I find a list of all the changes made to PE. Not the little blurb that tells me about what is in the new version, but the CHANGELOG details, so that the educated reader can review it and ascertain where there may have been changes that might have a bearing or not.

In a previous life I used to learn most of what programs actually did or were supposed to do at the front line by reading the changelog details in the source code. And yes, it frightened me a bit too. Compiled code of course! :)
 
Last edited:

Technical

Technical Support
Staff member
'servopos pin,off' is the same as 'low pin', ie turn the servo command off

If you want servo pulses to keep going but be of value 0 you should be using

'servopos pin,0'
 

erco

Senior Member
'servopos pin,off' is the same as 'low pin', ie turn the servo command off

If you want servo pulses to keep going but be of value 0 you should be using

'servopos pin,0'
What does that do, send a series of zero pulsewidth pulses, pretty much a ground signal?

Servos need a steady diet of pulses within their operating range, even to stand still. They will always twitch on powerup, and after you restart sending pulses after stopping. No word from the OP yet, but I still suspect his 'servopos off' commands are causing the problem.
 

Technical

Technical Support
Staff member
yes, both will cause glitches.

A 'servopos ,off' or 'low' command stop pulses on that pin and stops the 20ms pulse framework immediately. So you may get a spurious shortened pulse as the whole servo framework switches off at that moment in time. This will cause a 'powered' twitch.

A 'servopos, 0' stops pulses, but keeps the framework going, so the last pulse is not corrupted. The servo will still go floppy and so may move, but won't get an illegal pulse as it can with off or low.
 

erco

Senior Member
That "floppy" servo could be handy for puppeteering and such. Pose the servo where you want, then read & store the pot position with an ADC for playback.
 

IronJungle

Senior Member
More to the point from a confidence point of view, what version of PE did you use successfully and what version are you using now?
Now this is an interesting point!!! (BTW, I tried servopos pin, OFF and the servos still jittered).

However, I am on PE ver 5.4.3 and when the robot hand did not jitter I was on PE 5.3.6
Maybe we are on t something here....

Is there a way to re-install PE to see if that makes a difference? Honestly, that is the only change that I can see that changed from the jitter not being there to the jitter occurring. It happened right after the download of the same source code that used to be have the servos silent. I would like to try another download with PE 5.3.6 and see if it makes a difference.
 

IronJungle

Senior Member
Yes, that is expected - as that command is the same as 'low' as explained earlier. Did you try 'servopos pin,0'
Yes. servopos pin, 0 had an effect of moving the servos to a '0' position. In the case of my Robot Hand that meant an offensive gesture. On the plus side, it did correct the jitter but the servo were obviously under load and not just 'idle'.

I also moved the "servopos pin, OFF"; "servopos pin, 0"; and "low pin" into the "wait for button press loop" as an experiment. The jitter was much much worse and repetitive.

See post #16. Is there a way to retest with 5.3.6? I looked on the interwebs for older versions, but no luck.
 
Last edited:

Technical

Technical Support
Staff member
It is compiler version, not PE version, that is important here, and we don't see any point in using an old version.

The only commands that have ever been available to you are:

servo pin,0
servopos pin,0
low pin (aka servo pin, off aka servopos pin,off)

Some of the older compilers did actually output 'servo pin,0' instead of 'low 0' for 'servopos pin,off' but they were changed to be consistent across the whole PICAXE range.

However this is not the main issue here, the issue is actually why you expect to get jitter free operation after switching the pulses off. This is simply never going to work reliably, it may appear to work some times but will never be reliable - the servo will always move slightly and hence 'twitch' as soon as it no longer receives active pulses. To maintain a servo position it must always retain pulses every 20ms or so. As soon as you introduce any command that disables servo pulses, whatever that command may be, you will introduce the potential of jitter.
 

IronJungle

Senior Member
Technical:

Sorry for my misuse of PE version and compiler version.

I accept your explanation on the jitter as fact and do not question your analysis.

Can you provide any logic chain as to why the "servopos pin, OFF" corrected the issue in the summer? I recall my euphoria when I added the "servopos pin, OFF" command and the jittering stopped.

Also, the robot hand has been sitting very quite and jitter free on my desk for months and happily performs a gesture at button press; then return to it's quite jitter free self. After the re-download of the same code the jitter was back.

Just looking for some guess on to what an explanation may be.

As always; respect and thanks!

It is compiler version, not PE version, that is important here, and we don't see any point in using an old version.

The only commands that have ever been available to you are:

servo pin,0
servopos pin,0
low pin (aka servo pin, off aka servopos pin,off)

Some of the older compilers did actually output 'servo pin,0' instead of 'low 0' for 'servopos pin,off' but they were changed to be consistent across the whole PICAXE range.

However this is not the main issue here, the issue is actually why you expect to get jitter free operation after switching the pulses off. This is simply never going to work reliably, it may appear to work some times but will never be reliable - the servo will always move slightly and hence 'twitch' as soon as it no longer receives active pulses. To maintain a servo position it must always retain pulses every 20ms or so. As soon as you introduce any command that disables servo pulses, whatever that command may be, you will introduce the potential of jitter.
 

Technical

Technical Support
Staff member
The old compiler version was outputing for 'servopos pin, off' the command 'servo pin,0' instead of the 'low 0' as it does now. This would give very slightly different behaviour, but you can resurrect the old behaviour by simply typing 'servo pin,0' directly instead.

However neither are going to help reliability in this case - in the ideal world you want to keep the servo pulses going all the time.
 

IronJungle

Senior Member
However neither are going to help reliability in this case - in the ideal world you want to keep the servo pulses going all the time.
Thanks. I want to test something on a breadboard based on your comment, but you already know the answer I'm sure.

After a servo initialization, if I build a small loop such as below would the servos jitter or would they silently stay in position 100? I'm thinking jitter...
Code:
main:
servopos 0, 100
servopos 1, 100
servopos 2, 100
servopos 3, 100
servopos 4, 100
goto main
 

IronJungle

Senior Member
I'm thinking jitter...
Just answered my own question. It does.

However, I added a 'pause' in the loop that waits for a button press to perform another gesture. Naturally, the jitter was in this loop because the hand is just sitting there waiting to do something.

With the "pause" statement in the loop the hand is almost silent. Almost... I get a jitter sound about every ten minutes or so. I wish I knew why I used to never get a jitter noise.

Code:
servopos 0, off
servopos 1, off
servopos 2, off
servopos 3, off
servopos 4, off

do until pinC.1 = 1 'wait for RED button press (PICAXE pin18)	
	pause 150 ' a pause here seems to help with the servo jitter *a lot*
	RANDOM w12	' w13 will be use to in Case Statement and select a Gesture
	w13 = w12 // 11 + 1 '"//" is modulus divide (returns remainder)	
loop
 
Last edited:

premelec

Senior Member
Parkinson's?! - or more likely servo pot noise if you've had it on a very long time - they do wear... Check the signal from the servo pot for noise if you can...
 

erco

Senior Member
Good call, premelec. Pot wear and/or general internal servo wear could cause oscillation.
 

srnet

Senior Member
In some positions servos can jitter a bit, this can be normal behaviour.

Its not unusual when setting up a plane to find that at rest (only slight control surface load) a servo can be quiet in one position but jitter slightly if you move its position just a little. Servos dont have infinite resolution so there will be situations when its oscillating slightly between two locations.

Thus whilst at one point in time a servo is perfectly quiet, its possible that at some later point due to slight differences in the pulse wiidth (RC temperature variations) it jitters a bit. This would not be considered a fault as such.
 

MPep

Senior Member
Thus whilst at one point in time a servo is perfectly quiet, its possible that at some later point due to slight differences in the pulse width (RC temperature variations) it jitters a bit. This would not be considered a fault as such.
Not necessairly temperature. What Erco is getting at is that the track of the feedback pot 'wears' at the neutral point where the wiper sits at 'rest'. With constant voltage applied, slight electrolysis wears down this portion of the track faster than the rest of the track.

This is one reason why audio designers use a series capacitor to the top of the volume pot, AND a series pot from the wiper to the input of the amplifier. To avoid DC through the volume control at all costs! The worn area causes noise.
 

srnet

Senior Member
What Erco is getting at is that the track of the feedback pot 'wears' at the neutral point where the wiper sits at 'rest'. With constant voltage applied, slight electrolysis wears down this portion of the track faster than the rest of the track
Indeed, that is one of several possible reasons.
 

Technical

Technical Support
Staff member
These are all valid servo comments, however in the post 23 example the servos are actually not receiving any pulses and so are not 'actively driven'.
 

IronJungle

Senior Member
Thanks all for the help with my jitter issue. I got it fixed (actually, it was never "broken").

To recap, the Robot Hand servo started to jitter immediately after I did a download of the same code to the PICAXE.

Then these helpful exchanges.

Paix wrote:>>>>
Post #10: "More to the point from a confidence point of view, what version of PE did you use successfully and what version are you using now?"

IronJungle (that's me) wrote:>>>>
Post #16: "However, I am on PE ver 5.4.3 and when the robot hand did not jitter I was on PE 5.3.6"
"Maybe we are on t something here...."

Technical wrote:>>>>>
Post #20: "It is compiler version, not PE version, that is important here, and we don't see any point in using an old version."

Well, the issue was with the revision 5.4.3.
If I download the code to the Robot Hand under 5.4.3 the servos jitter like crazy every second or so.
I take the exact same code and download to the exact same hardware under 5.3.6 and NO JITTER. No jitter ever. None. YES!!!!
I'll post my code below for reference.

Many thanks to all for your suggestions. Special thank to "Paix" for helping to hook me up with the older 5.3.6 install file that enabled the experiment.

I am not sure of the details on what is happening, but I would be interested in ideas. What I will confidently say is there is absolutely something different in the two versions that cause the servos to act differently with the same code and HW setup.

Thanks again everyone. This forum is a wonderful resource.

Code:
' PICAXE 18M2 for Hand Gesture Robot JULY 2011
' www.ironjungle.com
' Other than the minium PICAXE 18M2 'keep alive' 22K R & 10K R
' no other R, C, L, etc need for the project.
' Everything powered by 4.5VDC
' The PICAXE drives the servos straight from the chip.  
' See pinouts in comments

' 0 is Thumb (PICAXE pin 6)
' 1 is Pointer (PICAXE pin 7)
' 2 is Middle (PICAXE pin 8)
' 3 is Ring (PICAXE pin 9)
' 4 is Pink (PICAXE pin 10)
' Normally Open Button Switch is PICAXE pin 18 (pulled HIGH with 10K)

'Define Servo values to fully EXtend/Open finger
Symbol Ex_Thumb = 60
Symbol Ex_Pointer = 60
Symbol Ex_Middle = 245
Symbol Ex_Ring = 60
Symbol Ex_Pink = 60

'Define Servo values to fully CLose finger
Symbol CL_Thumb = 225
Symbol CL_Pointer = 240
Symbol CL_Middle = 50
Symbol CL_Ring = 240
Symbol CL_Pink = 240

'Init the servos
servo 0, Ex_Thumb
servo 1, Ex_Pointer
servo 2, Ex_Middle
servo 3, Ex_Ring
servo 4, Ex_Pink

pause 400

'Gesture Subroutines are:
'  One
'  Two
'  Three
'  Four
'  Open_Hand
'  Hook_em
'  Gig_em
'  Hang_Loose
'  Fist
'  F_You
'  Walk

main:

'Insure Open_Hand position and
'Turn the servos off so they don't jitter
gosub Open_Hand
pause 400

servopos 0, off
servopos 1, off
servopos 2, off
servopos 3, off
servopos 4, off

do until pinC.1 = 1 'wait for RED button press (PICAXE pin18)    
    RANDOM w12    ' w13 will be use to in Case Statement
    w13 = w12 // 11 + 1 '"//" is modulus divide (returns remainder)    
loop 

'Turn the servos on. We turned them off so they didn't jitter
'Hand is already in the Open_Hand position
servo 0, Ex_Thumb
servo 1, Ex_Pointer
servo 2, Ex_Middle
servo 3, Ex_Ring
servo 4, Ex_Pink

Select Case w13
    Case 1
        gosub One
    Case 2
        gosub Two
    Case 3
        gosub Three
    Case 4
        gosub Four
    Case 5
        gosub Hook_em
    Case 6
        gosub Gig_em
    Case 7
        gosub Hang_Loose
    Case 8
        gosub Fist
    Case 9
        gosub F_You
    Case 10,11    'add cases so this will come up more often
        gosub Walk
endselect

pause 3000 ' hold the selected gesture

goto main   'return and wait for button press


' Gesture Subroutines below:
Open_Hand:
servopos 0, Ex_Thumb
servopos 1, Ex_Pointer
servopos 2, Ex_Middle
servopos 3, Ex_Ring
servopos 4, Ex_Pink
return ' Open_Hand

Gig_em:
servopos 0, Ex_Thumb
servopos 1, CL_Pointer
servopos 2, CL_Middle
servopos 3, CL_Ring
servopos 4, CL_Pink
return 'Gig_em

Hook_em:
servopos 0, CL_Thumb
servopos 1, Ex_Pointer
servopos 2, CL_Middle
servopos 3, CL_Ring
servopos 4, Ex_Pink
return 'Hook_em

F_you:
servopos 0, CL_Thumb
servopos 1, CL_Pointer
servopos 2, Ex_Middle
servopos 3, CL_Ring
servopos 4, CL_Pink
return 'F_you

One: 
servopos 0, CL_Thumb
servopos 1, Ex_Pointer
servopos 2, CL_Middle
servopos 3, CL_Ring
servopos 4, CL_Pink
return 'One

Two: 
servopos 0, CL_Thumb
servopos 1, Ex_Pointer
servopos 2, Ex_Middle
servopos 3, CL_Ring
servopos 4, CL_Pink
return 'Two

Three:
servopos 0, CL_Thumb
servopos 1, Ex_Pointer
servopos 2, Ex_Middle
servopos 3, Ex_Ring
servopos 4, CL_Pink
return 'Three

Four:
servopos 0, CL_Thumb
servopos 1, Ex_Pointer
servopos 2, Ex_Middle
servopos 3, Ex_Ring
servopos 4, Ex_Pink
return 'Four

Fist:
servopos 0, CL_Thumb
servopos 1, CL_Pointer
servopos 2, CL_Middle
servopos 3, CL_Ring
servopos 4, CL_Pink
return 'Fist

Hang_Loose:
servopos 0, Ex_Thumb
servopos 1, CL_Pointer
servopos 2, CL_Middle
servopos 3, CL_Ring
servopos 4, Ex_Pink
return 'Hang_Loose

Walk:  'waves the fingers
servopos 0, CL_Thumb
pause 70
servopos 1, CL_Pointer
pause 70
servopos 2, CL_Middle
pause 70
servopos 3, CL_Ring
pause 70
servopos 4, CL_Pink
pause 70

servopos 0, Ex_Thumb
pause 70
servopos 1, Ex_Pointer
pause 70
servopos 2, Ex_Middle
pause 70
servopos 3, Ex_Ring
pause 70
servopos 4, Ex_Pink
return 'Walk
 

Technical

Technical Support
Staff member
Post #21 already tells you the difference between the two versions, with reference to 'servopos pin, off' in your program.
 

IronJungle

Senior Member
Post #21 already tells you the difference between the two versions, with reference to 'servopos pin, off' in your program.
I tried the suggestion of "but you can resurrect the old behaviour by simply typing 'servo pin,0' directly instead." from post #21 using 5.4.3 and the servos still jittered the same.

FWIW, I installed MacAXEPad 1.3.2 this morning and downloaded my Robot Hand PIXAXE 5.3.6 control code in post #34. The servos immediately started to jitter again. Then I went back to the Windows machine using 5.3.6 and re-downloaded the code to the PICAXE; no jitter.

So in summary. Using MacAXEPad 1.3.2 = servo jitter. Using Windows w/ 5.4.3 = servo jitter. Using Windows w/ 5.3.6 = no servo jitter.

My code may be clunky and part of the problem, but it just can't be denied that 5.3.6 does "something" different.

BTW, the MacAXEPad is a really slick looking tool and has given me yet another reason to not to boot my PC. The Rev-Ed products amaze me!!!
 

Paix

Senior Member
Having looked at the code and given that the jitter occurs around once per second (on the later version of the PE only), it occurs to me that the servos are effectively off at this point; i.e. the pulse train should be finished and the pins at a stable low level. At this time the code should be whizzing round the do loop generating a succession of random numbers and nothing else until the button is pressed.

@IronJungle, do you have any gear to be able to ascertain that there is no noise or signal on the pins driving the servos at this time, when we expect there to be no servo movement?

Do the fingers jitter at: together, randomly or sequentially in a predictable order?

Is the observed static 'Servo off' state of the servo pins the same under code generated by both PEs?

Is there any observable activity on the servo pins (select one and observe with great rigour) by way of glitches or extraneous pulses. Something triggerable might be good to observe any artefacts there.

When programmed by both PEs, is the hand operating stand alone, disconnected from the programming cable and in the same location not next to a mobile phone on the other side of your desk/bench/room? I'm sure that you have ruled out any environmental problems already, but I have to ask.

Questions, questions, always questions . . . sorry! Persistance is such a PITA eh?
 

Technical

Technical Support
Staff member
We have an idea that this may be due to interaction between the compiler and the older 18M2 firmware version. It is an older (i.e. not a 2.D) 18M2 firmware version?
 

IronJungle

Senior Member
@IronJungle, do you have any gear to be able to ascertain that there is no noise or signal on the pins driving the servos at this time, when we expect there to be no servo movement?

Do the fingers jitter at: together, randomly or sequentially in a predictable order?

Is the observed static 'Servo off' state of the servo pins the same under code generated by both PEs?

Is there any observable activity on the servo pins (select one and observe with great rigour) by way of glitches or extraneous pulses. Something triggerable might be good to observe any artefacts there.

When programmed by both PEs, is the hand operating stand alone, disconnected from the programming cable and in the same location not next to a mobile phone on the other side of your desk/bench/room? I'm sure that you have ruled out any environmental problems already, but I have to ask.
Paix:

The issue is with the PE rev. Plain and simple. There is just no other way possible as the 5.3.6 rev leaves the servos jitter free (*FOREVER*) but the newer Windows version and the MacAXEPad version cause them to jitter right after the code download.

But, in the interest of science and to help document the event, the to answer your questions:

- the servos jitter on all the fingers is random. Putting a pause in the 'wait for button press' loop calmed them some.
- servo jitter is different with PE revs. Calm with 5.3.6 (see above comments).
- I have not scoped the servo output pins at idle.
- the programming cable is disconnected and does not influence the results. I have "EMI a plenty" around the house, but I don't think a cell phone, etc is the root cause.

Thanks again for the help!
 

IronJungle

Senior Member
We have an idea that this may be due to interaction between the compiler and the older 18M2 firmware version. It is an older (i.e. not a 2.D) 18M2 firmware version?
Technical:

From MacAXEPad I did a "View/Options/Firmware" and got a message of "Found PICAXE-18M2 Firmware Version 2.B" from the PICAXE driving to Robot Hand.
Does that help? Can I provide more information?
 
Top