November 01, 2024, 11:24:25 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Servo control Prop1 vs Prop2

Started by davisgraveyard, June 06, 2007, 03:46:42 PM

Previous topic - Next topic

davisgraveyard

I moved a Prop-1 program that controls a couple of servos in a Pan&Tilt unit over to a Prop-2 and the servos are moving in completly different ways?  Its almost like the values I used to get the movement correct on the Prop-1 are not right for the Prop-2.  Any ideas?

Here is some of the code....

lowerhead:
  Servo = Servo2
  FOR pos = 140 TO 170       'lower the head
   GOSUB slowdown
  NEXT
  RANDOM lottery
  seconds =  lottery // 3 + 1 * 60 * 500      'wait a while before doing it again
  PAUSE seconds
  GOTO Main

slowdown:
    FOR idx = 1 TO 10
      PULSOUT Servo, pos
      PAUSE 18
    NEXT

JonnyMac

June 06, 2007, 04:35:28 PM #1 Last Edit: June 06, 2007, 04:55:13 PM by JonnyMac
Internally, most Prop-2 instructions run 5x the speed of the same instruction on the Prop-1.  What this means for PULSOUT, then, is that on the Prop-2 the resolution is 2 uS instead the 10 uS used by the Prop-1.

To port your servo values from the Prop-1 to Prop-2, simply multiply them by five.  If you're using a variable to hold a servo position then you need to declare it as type Word. 

I've made a few updates to your program:

1) adjusted the timing values
2) replaced Slow_Down subroutine with Delay_And_Hold -- set "delay" (declare as a Word) before calling
3) replaced PAUSE seconds with a routine that delays in ~20 ms units while refreshing the servo
    -- if the servo is under load and doesn't get refreshed it could move

Lower_Head:
  Servo = Servo2
  FOR pos = 700 TO 850 STEP 5           ' lower the head
    delay = 10
    GOSUB Delay_And_Hold
  NEXT
  RANDOM lottery
  delay = lottery // 3 + 1 * 1000 / 50  ' convert to 20 ms units
  GOSUB Delay_And_Hold                  ' delay and refresh servo
  GOTO Main

Delay_And_Hold:
  DO WHILE (delay > 0)
    PULSOUT Servo, pos
    PAUSE 18
    delay = delay - 1
  LOOP
  RETURN
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

That makes sense.  5x the speed means 5x the resoulution.

Thanks for the program updates too.