Post by Admin on Dec 15, 2016 12:34:20 GMT
Many people using servos for different applications on their layouts especially points. Have reported a problem with the PicAxe and other controllers - that of servo jitter. Where the servo will move at a random point.
This can even happen on a point when a train is crossing and thus causes a derailment.
We have a novel approach to using servos, which not only removes the jitter problem but also increases the life of the servo motor and the point It also reduces the need to accurately calibrate the servo position to stop the annoying buzz caused by a servo trying to over move the point against it stop. In reality we are using the servo more like a accurate slow moving solenoid or point motor.
Servos are designed for remote control applications and as such the servo is active all the time. While this is essential for remote control model application it is not needed for most of model railway applications.
For example when using a servo to control points, the servo needs to provide force only when the point is being moved. For 99% of the time the point is static and being held in place by the friction in the servo and the spring on the point.
With our technique we only drive the servo for a short time just long enough to move the point. Below is the PicAxe Basic code we use. it can be either pasted into a Blockly box or if you are coding in Basic just add it to your code.
for b1 = 1 to 10 'This is a counter and will loop this code snippet 10 times. The number 10 can be changed to a larger number thus performing the pulse more times if for example you have a sticky point.
pulsout C.7,132 'This line outputs a pulse of 132uS to pin C.7
pause 20 'This provides a 20mS pause which is what is required by the servo
next b1 'This tells the counter we set up in the first line to count one more, when the count has reached 10 as we set up in the first line it will go on to the next command
'The variable b1 can be changed to a different variable if it's already being used for something else. typically you have 24 variables of most PicAxes.
This code will drive the servo to one position you would need to add an additional line as below to drive it to the other position.
for b1 = 1 to 10 'This is a counter and will loop this code snippet 10 times. The number 10 can be changed to a larger number thus performing the pulse more times if for example you have a sticky point.
pulsout C.7,83 'This line outputs a pulse of 83uS to pin C.7
pause 20 'This provides a 20mS pause which is what is required by the servo
next b1 'This tells the counter we set up in the first line to count one more, when the count has reached 10 as we set up in the first line it will go on to the next command
'The variable b1 can be changed to a different variable if it's already being used for something else. typically you have 24 variables of most PicAxes.
The servo requires a pulse between 80uS and 125uS followed by a 20mS pause. it is the length of the pulse which defines the position of the servo. If you wish you could forget about pulses and uS and just think about the servo having positions from 80 to 125 this is only an approximate number as different servos have a different amount of movement depending on their design. We recommend before you include a servo in your layout you have a play with it and work out what movement is available.
If you are using a Raspberry Pi, Arduino or some other controller you may not encounter the jitter problem However this technique is still useful as it improves the life of the servos It also reduced the need to accurately set up the servo position. I have not supplied the code for other controllers as I assume if you are using something different you will have the skills to translate the above code snippet.
We also found it useful as we could set the servo to move slightly further than the stop point. giving the point a little push to overcome friction. and improve the electrical connection of the rails.
This can even happen on a point when a train is crossing and thus causes a derailment.
We have a novel approach to using servos, which not only removes the jitter problem but also increases the life of the servo motor and the point It also reduces the need to accurately calibrate the servo position to stop the annoying buzz caused by a servo trying to over move the point against it stop. In reality we are using the servo more like a accurate slow moving solenoid or point motor.
Servos are designed for remote control applications and as such the servo is active all the time. While this is essential for remote control model application it is not needed for most of model railway applications.
For example when using a servo to control points, the servo needs to provide force only when the point is being moved. For 99% of the time the point is static and being held in place by the friction in the servo and the spring on the point.
With our technique we only drive the servo for a short time just long enough to move the point. Below is the PicAxe Basic code we use. it can be either pasted into a Blockly box or if you are coding in Basic just add it to your code.
for b1 = 1 to 10 'This is a counter and will loop this code snippet 10 times. The number 10 can be changed to a larger number thus performing the pulse more times if for example you have a sticky point.
pulsout C.7,132 'This line outputs a pulse of 132uS to pin C.7
pause 20 'This provides a 20mS pause which is what is required by the servo
next b1 'This tells the counter we set up in the first line to count one more, when the count has reached 10 as we set up in the first line it will go on to the next command
'The variable b1 can be changed to a different variable if it's already being used for something else. typically you have 24 variables of most PicAxes.
This code will drive the servo to one position you would need to add an additional line as below to drive it to the other position.
for b1 = 1 to 10 'This is a counter and will loop this code snippet 10 times. The number 10 can be changed to a larger number thus performing the pulse more times if for example you have a sticky point.
pulsout C.7,83 'This line outputs a pulse of 83uS to pin C.7
pause 20 'This provides a 20mS pause which is what is required by the servo
next b1 'This tells the counter we set up in the first line to count one more, when the count has reached 10 as we set up in the first line it will go on to the next command
'The variable b1 can be changed to a different variable if it's already being used for something else. typically you have 24 variables of most PicAxes.
The servo requires a pulse between 80uS and 125uS followed by a 20mS pause. it is the length of the pulse which defines the position of the servo. If you wish you could forget about pulses and uS and just think about the servo having positions from 80 to 125 this is only an approximate number as different servos have a different amount of movement depending on their design. We recommend before you include a servo in your layout you have a play with it and work out what movement is available.
If you are using a Raspberry Pi, Arduino or some other controller you may not encounter the jitter problem However this technique is still useful as it improves the life of the servos It also reduced the need to accurately set up the servo position. I have not supplied the code for other controllers as I assume if you are using something different you will have the skills to translate the above code snippet.
We also found it useful as we could set the servo to move slightly further than the stop point. giving the point a little push to overcome friction. and improve the electrical connection of the rails.