May 08, 2024, 04:37:52 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Triggering a Cowlacious CAR/P 300 with prop 1

Started by John F., September 08, 2009, 07:07:18 PM

Previous topic - Next topic

John F.

Jon;

        Can the program you wrote below trigger a CAR/P 300 as it is written or does it need to be modified?
I am using this program to animate a servo driven 2 axis skull and it is working fine for that. Now I want to power a CAR/P 300 through the prop 1 (as a pass through so I can use the dual message) and trigger it to play the second message which, when done, will revert to the first message over and over until triggered again. A Scary Terry audio jaw driver will be paralleled with the CAR/P 300 pass through power.
Thanks for your help and this forum, without both I wouldn't even attempt these projects.


' =========================================================================
'
'   File...... Servo_Blender-MP3.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 12 APR 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Starts an external audio player and then controls the simultaneous
' movement of two (pan/tilt) servos.  Servo movement is stored in an 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                     ' audio start/stop
SYMBOL  Trigger         = PIN6                  ' trigger input

SYMBOL  Servo2          = 1
SYMBOL  Servo1          = 0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  RecLen          = 3                     ' record length (servos + 1)

SYMBOL  EOS             = 255                   ' end of show marker


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

SYMBOL  record          = B0                    ' movement record
SYMBOL  pntr            = B1                    ' table byte pointer
SYMBOL  s1Pos           = B2                    ' servo 1 position
SYMBOL  s2Pos           = B3                    ' servo 2 position
SYMBOL  repeats         = B4                    ' repeats for record data


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

Reset:
  PINS = %00000000
  DIRS = %10000011                              ' make servo pins 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:
  HIGH Audio                                    ' "press" play button
  PAUSE 2000                                    '   for 2 seconds
  LOW Audio

Reset_Moves:
  record = 1                                    ' point to start of moves

Move_Engine:
  GOSUB Get_Servo_Pos                           ' get servo positions
  IF s1Pos = EOS THEN Show_End                  ' 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

Show_End:
  HIGH Audio                                    ' "press" play button
  PAUSE 2000                                    '   for 2 seconds
  LOW Audio

  GOTO Reset                                    ' clear everything


' -----[ 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
  pntr = pntr + 1                               ' point to repeats
  READ pntr, repeats                            ' read repeats
  RETURN

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

' Update servos -- time consumed is 19 to 21 ms

Refresh_Servos:
  PULSOUT Servo1, s1Pos
  PULSOUT Servo2, s2Pos
  PAUSE 17                                      ' pad for loop timing
  RETURN


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

' Note on servo movement 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   rpts

Move_Table:
  EEPROM (150, 150, 255)                        ' home position
  EEPROM (100, 100,  50)                        ' start of movements
  EEPROM (100, 200,  50)
  EEPROM (200, 200,  50)
  EEPROM (200, 100,  50)
  EEPROM (EOS, 150, 255)                        ' end here

  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)
  EEPROM (EOS, 150, 255)                        ' last available EE space

« Last Edit: April 13, 2007, 02:55:31 PM by JonnyMac »  Report to moderator    Logged 

--------------------------------------------------------------------------------

Jon Williams
EFX-TEK

JonnyMac

I would change the PAUSE in this section

Start_Audio:
  HIGH Audio                                    ' "press" play button
  PAUSE 2000                                    '   for 2 seconds
  LOW Audio


... to 50ms.  Connect V+ and OUT7 to the V-Trig input on the board and set it for 12v.  You should be good to go.
Jon McPhalen
EFX-TEK Hollywood Office


John F.

Jon;

     Thanks for all your help. This year I want the program in this post to just repeat, without triggers. Would I just remove  SYMBOL Trigger = pin 6, IF Trigger = IsOff THEN Main and change , IF s1Pos = EOS THEN Show_End  to  IF s1Pos = EOS THEN goto main?

BigRez

Looks like you should only have to remove (or comment-out) the   IF Trigger = IsOff THEN Main   ' wait for trigger   line. The other lines can stay.

Also, all of the EOS EEPROM lines after the one that says 'end here  can be removed if you want - they don't do anything other than take up space.  (They are there just to note how many show elements you can have. But the number of them will increase/decrease as the program changes.)


JonnyMac

As Mike points out, all you have to do is remove the trigger line, and you can do that using an apostrophe (') at the front of the line -- we call this "commenting out" as comments are ignored by the compiler.
Jon McPhalen
EFX-TEK Hollywood Office