Time based smooth sweep


I am trying to sweep a sail winch servo from x to x.
Start at 6200 and sweep through the full rotation to 10975 in approximately 1 hour.

There has to be a way to do this in a lot fewer lines than 190 which jumps the servo by 25… but I am stuck, I can not get the syntax correct. I think that it could be done with the stack and plus.

Any help?


Jerry Allen

A “begin while repeat” loop will work. See examples, such as “Moves servo in a sine wave between 1 and 2 ms.” pololu.com/docs/0J40/6.c

Hello, Jerry. I too recommend using a loop. I think that each iteration of the loop should read the current position of the servo, add a small number to it, and then write it back to the servo. Then it should delay for some time. By adjusting the delay time and the amount you are adding to the position, you should be able to achieve some very slow and smooth servo speeds.


Learned a bit (in my sleep some way Saturday night) :slight_smile: Now to tie in the other 2 servos and make the delays and the move amounts programable via button presses.

6150 0 servo		#servo 0 past home
3000 delay		#wait for the servo to go home
0 1 acceleration	#accel slower
0 1 speed		#speed slower
9 6191		
800 delay
plus			#add the stack
dup			#duplicate the result
0 servo		#move the servo
9			#seed the stack
800 delay		#delay 800ms
0 get_position	#get servo 0 position
10575 greater_than	
2000 delay			#if it is greater than 10575 (full rev)
goto reset		# go home and start over
repeat			#move servos(s) again