I am glad it is working better for you.
I have not completely studied the thread, so I may have missed a few fine points, but will try to give a few answers/suggestions. Robot Dude will hopefully correct what I missed
-
By default I think these servos are limited to about 140 degrees of rotation. You can use a servo programmer to update them to allow 180 degree rotations. I think you need something like: lynxmotion.com/p-615-hmi-ser ⦠r-kit.aspx to do this.
-
Not sure what you mean by reprogram my servos when running or how to stop. The current program simply alternates from one position to a second position. You can easily make this more complicated, like only do this N times and stop. That could be done with a simple loop counter and several different basic concepts. You can also change the angle of the sweep by simply changing the Position values (i.e. make them variable instead of a constant). Note: If you stop issuing HSERVO commands, the servo will stay at the last location you specified. It will still be powered and will hold that location. With Analog Servos you can issue an HSERVO command with a special value to completely stop and remove power from the servo, however with digital servos such as yours, I donāt know of any way of doing this.
-
In this case I am not sure what you mean by RPM as the servo only turns part of 1 revolution. But if I translate your question into: I wish for the sweep from one side to another to take 3 seconds, you can accomplish this by using the speed parameter which is how much to add to the servo value in each servo refresh period, which is every 20ms or 50 times per second. So you might try something like:
MYSERVO con P4
hsPosition var sword
Position1 con -7000 'about -45 degrees (adjust to desired angle)
Position2 con 7000 'about +45 degrees
Time1 con 2000 '2 second pause value (adjust)
Time2 con 4000 '4 second pause value
HSSpeed con ((Position1-Position2)*20)/3000 ' This calculates the speed value. 3000 is in ms adjust...
sound 9, [100\880, 100\988, 100\1046, 100\1175]
low 0
HSERVOENABLE ' I don't think this is needed any more
hservo[MYSERVO\hsPosition]
start:
toggle P12
hsPosition = Position1
hservo[MYSERVO\hsPosition\HSSpeed]
hservowait[MYSERVO]
pause Time1
toggle P13
hsPosition = Position2
hservo[MYSERVO\hsPosition\HSSpeed]
hservowait[MYSERVO]
pause Time2
toggle p14
goto start
I added a calculation for the speed parameter which hopefully is correct. Also I added the HservoWait commands, which says wait for the servo to complete itās move.
Hopefully it worksā¦
Kurt