November 23, 2024, 07:36:58 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 help

Started by Eerie, June 08, 2009, 06:06:19 PM

Previous topic - Next topic

Eerie

  So after my discussion at the Midwest Haunters Convention and reading old post here I am a little scared of controlling servos with my Prop-1.  I am a new to programming and need to trigger an air cylinder on and then control a pair of eyes to pan left-right, up-down, with eyelids to look around, then close air cylinder.   The three servos total to run about 20 seconds.
I will play around with the programming but my question is what servo controller can be triggered with my trusty Prop-1? 
This looks interesting the Lynxmotion SSC-32  http://www.lynxmotion.com/Product.aspx?productID=395&CategoryID=52     
And also the Servo City unit looks super easy to operate    http://servocity.com/html/servo_recorder_playback_contro.html  but somewhat expensive.   
I am not sure if any of these would work.      Any ideas out there?

gadget-evilusions

Don't be scared of the prop-1. If you spell out exactly what your trying to do, Jon will help you with getting your program together. There are also a ton of programs on this forum to look at and learn from.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

We had a crazy week after MHC and I finally have some quiet time (in a hotel in Provo, Utah!) to post your program.  It turns out I did have the program I told you about -- see below.  This may be a little intimidating at first, but once you understand the process it will help you get to what you want to do (two servos and four outputs).

' =========================================================================
'
'   File...... Servo_Blender_x2.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 04 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Starts an external audio player and then controls the simultaneous
' movement of two servos and four digital output channels.  Servo movement
' and digital outputs are stored in a EEPROM table with a "repeats" value
' for timing at the positions specified in the record (last byte).  The
' timing is approximately:
'
' 20 milliseconds x (repeats + 1)
'
' Mimimum: ~0.02 seconds
' Maximum: ~5.12 seconds
'
' Note that servos are mechanical and move slowly, so very small "repeats"
' values may expire before the servos reaches their target positions.


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Audio           = 7
SYMBOL  Trigger         = PIN6
SYMBOL  Servo2          = 5
SYMBOL  Servo1          = 4
SYMBOL  DigOut4         = 3
SYMBOL  DigOut3         = 2
SYMBOL  DigOut2         = 1
SYMBOL  DigOut1         = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  RecLen          = 3                     ' record length (servos + 1)
SYMBOL  EOS             = $FF                   ' end of show


' -----[ Variables ]-------------------------------------------------------

SYMBOL  record          = B2                    ' movement record
SYMBOL  pntr            = B3                    ' table byte pointer
SYMBOL  s1Pos           = B4                    ' servo 1 position
SYMBOL  s2Pos           = B5                    ' servo 2 position
SYMBOL  repeats         = B6                    ' repeats for record data
SYMBOL  delay           = B7                    ' for loop timing


' -----[ Initialization ]--------------------------------------------------

Reset:
  DIRS = %10111111                              ' set outputs

  record = 0
  GOSUB Get_Servo_Pos                           ' get "home" positions


' -----[ Program Code ]----------------------------------------------------

Main:
  GOSUB Refresh_Servos
  IF Trigger = IsOff THEN Main                  ' wait for trigger

Start_Audio:
  PULSOUT Audio, 2500                           ' 25 ms blip on audio pin

Reset_Moves:
  record = 1                                    ' point to start of moves

Move_Engine:
  GOSUB Get_Servo_Pos                           ' get servo positions
  IF s1Pos = EOS THEN Reset                     ' abort if at end

Servo_Hold:
  GOSUB Refresh_Servos
  IF repeats = 0 THEN New_Record                ' time left at this pos?
    repeats = repeats - 1                       ' yes, decrement timing
    GOTO Servo_Hold

New_Record:
  record = record + 1
  GOTO Move_Engine


' -----[ Subroutines ]-----------------------------------------------------

' Call with "record" set to table line to read

Get_Servo_Pos:
  pntr = record * RecLen                        ' point into table
  READ pntr, s1Pos                              ' read servo 1 value
  pntr = pntr + 1                               ' point to servo 2
  READ pntr, s2Pos                              ' read servo 2 value
  pntr = pntr + 1                               ' point to digital outputs
  READ pntr, PINS                               ' set digital outputs
  pntr = pntr + 1                               ' point to repeats
  READ pntr, repeats                            ' read repeats
  RETURN

' -------------------------------------------------------------------------

' Update servos -- time consumed ~20

Refresh_Servos:
  PULSOUT Servo1, s1Pos
  PULSOUT Servo2, s2Pos
  delay = s1Pos + s2Pos + 50 / 100              ' calc pulses timing
  delay = 20 - delay                            ' subract from base
  PAUSE delay                                   ' pad for loop timing
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' Note on servo movement record timing:
'
' Time spent on each record is 20 ms x (repeats + 1) so a repeats value
' of 0 is ~20 ms and a repeats value of 255 (max) is ~5.1 sseconds at that
' position.
'
'         s1   s2    outs  rpts
'                    4321

Move_Table:
  EEPROM (150, 150, %0000, 255)                 ' home position
  EEPROM (100, 100, %0001,  50)                 ' start of movements
  EEPROM (100, 200, %0010,  50)
  EEPROM (200, 200, %0100,  50)
  EEPROM (200, 100, %1000,  50)
  EEPROM (EOS, 150, %0000, 255)                 ' end demo here

  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)
  EEPROM (150, 150, %0000, 255)                 ' last possible move
  EEPROM (EOS, EOS, %0000, 255)                 ' define end of table
Jon McPhalen
EFX-TEK Hollywood Office

Eerie

Thx for the help  :)