November 22, 2024, 07:49:17 PM

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.


Question with Programing or Help with Proplem

Started by rhilyard, October 20, 2009, 02:29:25 PM

Previous topic - Next topic

rhilyard

Here is my program.  The bench test runs great.  The motion activates the controller and runs the program.  Once I install it into the prop and turn power on the controller activates as soon as power is applied.  Then never runs the program again.

-----[ Program Description ]---------------------------------------------
'


' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL  Trigger = PIN7
SYMBOL  Test    = PIN6
SYMBOL  FOG     = PIN2
SYMBOL  Motor   = PIN0
SYMBOL  Lights  = PIN1
SYMBOL  SND     = PIN3
SYMBOL  IPause  = PIN4
SYMBOL  TOut    = PIN5

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

SYMBOL Repeat       = 2      'Number of times the pattern will repeat
SYMBOL MaxFogTime   = 1000

' -----[ Variables ]-------------------------------------------------------
SYMBOL  DoFog           = B3
SYMBOL  Triggered       = B1
SYMBOL  Reps            = B2
SYMBOL  LightLoop       = B0
SYMBOL  wTime           = W2
SYMBOL  rTime           = W4
SYMBOL  pTime           = W5
SYMBOL  FogOnTime       = W3

' -----[ Initialization ]--------------------------------------------------
LOW 0       'Motor Off
LOW 1       'Lights Off
LOW 2       'Fog Off
LOW 3       'Sound Off
pTime=7864
DoFog=0     'No Fog if left at 0

' -----[ Program Code ]----------------------------------------------------
Start:
  LOW 0       'Motor Off
  LOW 1       'Lights Off
  LOW 2       'Fog Off
  LOW 3       'Sound Off
  DEBUG CLS,"Ready",CR


Main:
'  DEBUG "Ready",CR
  Triggered=0
  IF PIN7=0 AND PIN6=0 THEN Main
  Triggered=PIN7
  IF Triggered=1 THEN DoWait
  IF Triggered=0 THEN DoTesting

Run:
  FOR Reps = 1 TO Repeat
    HIGH 0      'Motor On
    HIGH 1      'Lights On
    HIGH 3      'Sound On
    DEBUG "Motor and sound on: Rep",#Reps,CR

    DoFog=1     'Set Fog to run
    GOSUB LightIt

    LOW 0       'Motor Off
    LOW 1       'Lights Off
    LOW 3       'Sound Off
    DEBUG "Motor and sound off.",CR,CR
    RANDOM rTime
    pTime = rTime // 3 +1 * 1000
    PAUSE pTime
  NEXT

  IF Triggered=0 THEN Start
  wTime=0
  POT 5, 90, wTime          ' read timeout pot level
  PAUSE 200
  wTime=wTime /4            ' 0 to 60 secs
  wTime=wTime-1

  FOR reps=wtime TO 0 STEP -1
    DEBUG CLS,"Lock out for ",#reps,"seconds"
    PAUSE 1000
  NEXT

  GOTO Start

' -----[ Subroutines ]-----------------------------------------------------
LightIt:
  IF DoFog=1 THEN DoFogOn
Continue:
  DEBUG "Lights Flashing",CR
  FOR LightLoop=1 TO 10
    HIGH 1      'Lights On
    'DEBUG "   Light on: ",#LightLoop,CR
    RANDOM rTime
    pTime = rTime // 6 +1 * 100
    FogOnTime=FogOnTime+pTime
    'DEBUG #FogOnTime
    IF FogOnTime>=MaxFogTime AND PIN2=1 THEN DoFogOff
Continue2:
    'DEBUG "   Lights On ",#pTime,CR
    PAUSE pTime
    LOW 1       'Lights Off
    'DEBUG "   Lights off",CR
    RANDOM rTime
    pTime = rTime // 5 +1 * 100
    'DEBUG "   Lights Off ",#pTime,CR
    PAUSE pTime
  NEXT
  DEBUG "Lights Done", CR
  RETURN

DoFogOn:
  FogOnTime=0
  HIGH 2      'Fog on
  DEBUG "Fog is on",CR
  GOTO Continue

DoFogOff:
  LOW 2      'Fog off
  DEBUG "Fog is off", CR
  GOTO Continue2

DoWait:
  wTime=0
  POT 4, 87, wTime          ' read intial pause pot level
  PAUSE 200
  wTime=wTime /8                 ' 0 to 30 secs
  FOR reps=wTime TO 0 STEP-1
    DEBUG CLS,"Triggered - Pause for ", #reps,"seconds",CR
    PAUSE 1000
  NEXT
  DEBUG CLS
  GOTO Run

DoTesting:
  DEBUG CLS,"  >>>> Testing <<<<",CR,CR
  GOTO Run


Here is a picture of the setup.  The two relays are used to turn on the computer power supply to run motor.  If you need anymore info about the setup let me know.  I would like to have this up a running by this weekend.  Thanks to all that can help.



Rick


JonnyMac

I don't see potentiometers connected to your Prop-1, yet the program calls for them.  Interestingly, someone else was using that program and wanted a simpler version -- see what I've posted here:

-- http://www.efx-tek.com/php/smf/index.php?topic=1284.0

Note that my version assumes you have a Prop-1 Trainer to use for the re-trigger delay setting.
Jon McPhalen
EFX-TEK Hollywood Office

rhilyard

October 20, 2009, 04:15:24 PM #2 Last Edit: October 20, 2009, 04:18:13 PM by rhilyard
I want to remove that in the program.  But I want a reset time out for only 60 seconds.  Right now I have the Prop-1 in the prop and it is working with the push button start.  I took the motion off.  Could the motion be bad?  Also I don't have Prop Trainer.  But I have EZ-3

JonnyMac

October 20, 2009, 04:43:36 PM #3 Last Edit: October 20, 2009, 06:52:04 PM by JonnyMac
I'm not sure I understand what you want, so I'm guessing based on your response.  Here's a version of that program that uses a fixed reset delay, there are not pots used by this program.  Even if you want more later, give this a try to see if your prop works as intended -- we can add features if we need.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 20 OCT 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CowAudio        = PIN3
SYMBOL  Fog             = PIN2
SYMBOL  Lights          = PIN1
SYMBOL  Motor           = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  cycles          = B2

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
 PINS = %00000000                              ' clear all
 DIRS = %00001111                              ' set output pins

 PAUSE 60000


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

Main:
 timer = 0                                     ' reset timer

Check_Trigger:
 RANDOM lottery                                ' stir random #
 PAUSE 5                                       ' loop pad
 timer = timer + 5 * Trigger                   ' update timer
 IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Do_Wait:
 delay = lottery // 3001 + 2000                ' 2 to 5 seconds
 PAUSE delay

 RANDOM lottery                                ' re-stir
 cycles = lottery // 3 + 1                     ' 1 to 3 cycles

Start_Prop:
 CowAudio = IsOn
 Motor = IsOn
 Fog = IsOn

 timer = 0                                     ' reset

Run_Show:
 Lights = 1 - Lights                           ' toggle lights
 RANDOM lottery                                ' restir
 delay = lottery // 251 + 100                  ' 100 to 350ms
 PAUSE delay
 timer = timer + delay
 CowAudio = IsOff                              ' prevent looping

Check_Fog:
 IF timer < 1500 THEN Run_Show                 ' enough fog?
   Fog = IsOff                                 ' yep, turn it off

Check_Show:
 IF timer < 10000 THEN Run_Show                ' audio done?
   cycles = cycles - 1
   IF cycles > 0 THEN Start_Prop               ' start it back up
     GOTO Reset                                ' else we're done


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

rhilyard

Thanks But In this area I'm getting a Error 174-Label is missing


Run_Show:
  Lights = 1 - Lights                           ' toggle lights
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' 100 to 350ms
  PAUSE delay
  timer = timer + delay
Error Audio = IsOff                                 ' prevent looping Error

rhilyard

Never mind I fixed it.  I'm going to program now and see if it works.

Rick

JonnyMac

October 20, 2009, 06:50:13 PM #6 Last Edit: October 20, 2009, 06:52:36 PM by JonnyMac
Sorry about that, I renamed a label in my "make it pretty" phase after testing.  I fixed my listing, above (and in the original location).
Jon McPhalen
EFX-TEK Hollywood Office

rhilyard

The program works !  But I'm having problems with the sound.  I'm using  a CowAudio sound board.  I have the power running through the the prop-1 with pos to pos and neg on sound to pin3  It worked with the old program.  Is there a better way to set this up and if so could you explain? Plus could I still have a push trigger in the program also.  Thanks for all your help JonnyMac.

Rick

JonnyMac

I think it's a bad idea to power the audio board from the Prop-1 -- it will work with some boards, cause major problems with others, so we try to create solutions that are portable.

You can power the board from the V+ and GND terminals on the Prop-1 (assuming power from the Prop-1, usually 12 volts, is okay with the audio board).  You can then take the V+ and OUT3 connections to the V-Trig input of the Cowlacious board.  I'm assuming you have one of Carl's new boards; if not tell me what you have.

Here's a version of the program that allows a second (active-high) sensor on PIN7.  You could connect a N.O. button between P7.W and P7.R to manually trigger the prop.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 20 OCT 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger2        = PIN7                  ' SETUP = DN
SYMBOL  Trigger1        = PIN6                  ' SETUP = DN

SYMBOL  CowAudio        = PIN3
SYMBOL  Fog             = PIN2
SYMBOL  Lights          = PIN1
SYMBOL  Motor           = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  sensors         = B0
SYMBOL   PIR            =  BIT6
SYMBOL   Manual         =  BIT7

SYMBOL  idx             = B2
SYMBOL  cycles          = B3

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' set output pins

  PAUSE 60000


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

Main:
  sensors = %11000000                           ' preset triggers
  FOR idx = 1 TO 20                             ' 20 x 5ms = 100ms
    RANDOM lottery                              ' stir random #
    PAUSE 5
    sensors = sensors & PINS                    ' scan trigger inputs
  NEXT
  IF sensors = %00000000 THEN Main              ' either active?

Do_Wait:
  delay = lottery // 3001 + 2000                ' 2 to 5 seconds
  PAUSE delay

  RANDOM lottery                                ' re-stir
  cycles = lottery // 3 + 1                     ' 1 to 3 cycles

Start_Prop:
  CowAudio = IsOn
  Motor = IsOn
  Fog = IsOn

  timer = 0                                     ' reset

Run_Show:
  Lights = 1 - Lights                           ' toggle lights
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' 100 to 350ms
  PAUSE delay
  timer = timer + delay
  CowAudio = IsOff                              ' prevent looping

Check_Fog:
  IF timer < 1500 THEN Run_Show                 ' enough fog?
    Fog = IsOff                                 ' yep, turn it off

Check_Show:
  IF timer < 10000 THEN Run_Show                ' audio done?
    cycles = cycles - 1
    IF cycles > 0 THEN Start_Prop               ' start it back up
      GOTO Reset                                ' else we're done


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

rhilyard

Thank you JonnyMac  the program works great.  Just in time for my Halloween party.


Rick

JonnyMac

Excellent!  We hope the prop and the party are massively successful.
Jon McPhalen
EFX-TEK Hollywood Office

rhilyard

I spoke a little to soon. Now that I've wired  up the sound board to start using the v+ connector the sound comes on but doesn't turn off until the audio is done.  Is there a way to get the program to turn off the sound when the program is done.

Thanks

Rick

JonnyMac

No -- that board only has a start command, not ability to programmatically stop.  If you have to use power to control it then insert a relay between the Prop-1 and the sound board.  Switch power via the relay's N.O. contacts to the audio board.

For this kind of prop one would usually record the sound first and then write the code to match it.  That might in fact be easier than rigging the relay.
Jon McPhalen
EFX-TEK Hollywood Office