Adjusting code to slow down the speed of a servo movement

69-cat

Member
I am working on my Halloween project with a 12 foot skeleton that I have modified with a 3 axis talking mechanism that was 3D printed and works great. The 3 axis and jaw controller that I am using was built and sold by Steve Koci who passed away 2 years ago and designed by Steve Blork. I have made many attempts to contact Steve Bjork but hit dead ends on each emails and face book contacts but the code for the boards were provided by them. My issue is the skull so big and the movements are too fast and wanted to know if the speed can be adjusted so I added a little clip of the code ( I am sure I need to show more) but this section does mention the speed for the servos. Is it as simple as changing the 256 values to a lower number to change the speed? His code also states that you can make changes...

'The bottom line, the license lets you reprogramming, tweak, and build upon this work for non-commercial use
'as long as you give credit and license your new creations under the identical terms. Go have fun with it.


;The Head Movement variable (working from the end of Variables)
;Since Head turn will always be a whole number, we will just use 8 Bit for the position and speed.

symbol TurnPos_Word = w13 ;Head Turning position *256
symbol TurnPos_LSB = b26 ;Head Turning position fraction (byte)
symbol TurnPos_MSB = b27 ;Head Turning position whole number (byte)

symbol TurnSpeed_Word = w12 ;Head Turning Speed *256
symbol TurnSpeed_LSB = b24 ;Head Turning Speed fraction (byte)
symbol TurnSpeed_MSB = b25 ;Head Turning Speed whole number (byte)

symbol NodPos_Word = w11 ;Head Nodding position *256
symbol NodPos_LSB = b22 ;Head Nodding position fraction (byte)
symbol NodPos_MSB = b23 ;Head Nodding position whole number (byte)

symbol NodSpeed_Word = w10 ;Head Nodding Speed *256
symbol NodSpeed_LSB = b20 ;Head Nodding Speed fraction (byte)
symbol NodSpeed_MSB = b21 ;Head Nodding Speed whole number (byte)

symbol TiltPos_Word = w9 ;Head Tilting position *256
symbol TiltPos_LSB = b18 ;Head Tilting position fraction (byte)
symbol TiltPos_MSB = b19 ;Head Tilting position whole number (byte)

symbol TiltSpeed_Word = w8 ;Head Tilting Speed *256
symbol TiltSpeed_LSB = b16 ;Head Tilting Speed fraction (byte)
symbol TiltSpeed_MSB = b17 ;Head Tilting Speed whole number (byte)


Thank
Dave
 

papaof2

Senior Member
Servos are pretty consistent in the time it takes to move from X degrees to Z degrees so perhaps break up the total servo movement into several short movements and do those movements in a loop with a bit of delay in it so the total movement takes longer? Not sure whether you can do that without adding some "jerkiness" to the motion. Probably been too long since I did anything with servos so maybe someone with more recent experience has a better idea...
The other bit of the process is how much weight is the servo moving? Servos come in all sizes (at least up to 20kg - about 44lbs - so are you using the correct size servo for the piece being moved?
 

hippy

Technical Support
Staff member
Is it as simple as changing the 256 values to a lower number to change the speed?
I would have thought so. I would anticipate the movement code would be something like ...
Code:
Do While currentPosition < wantedPosition
  currentPosition = currentPosition + stepAmount
  Servo SERVO_PIN, currentPosition.msb
Loop
Everything word variables but just the 8-bit MSB's used to position the servo. That allows the 8-bit LSB to be 'after the decimal point'.

If you can post a link to the library code, or the code itself, that may help identify exactly what it's doing. That wouldn't normally be a beach of copyright or licence agreement.
 

69-cat

Member
Thank you Hippy.....Yes just adjusting the "256" to a lower number worked fine. I knew somewhere I would be able to adjust the "Pulse signal" to slow down the travel speed. None of the limits were effected and it nod has a more realistic look and movement. The lines that were changed were deep in to the code, between 950 and 1000.
Dave
 
Top