November 22, 2024, 09:59:51 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


A simple action that I am stumped on

Started by m_evans, September 19, 2008, 12:11:30 AM

Previous topic - Next topic

m_evans

I have played with the programming and I am lost...

I am making a tunnel of air as I call it...

1. I have the PIR that will activate
2. a airhorn will go off (3 blast) 1-2 sec total time
3. 4 cylinders trigger at random and random duration for 8 sec
4. another airhorn

???

JonnyMac

Other than the PIR, there's not enough in your post for me to write a program for you.

Q: Is each blast 1 to 2 seconds, or do all three blasts (start to finish last 1 to 2 seconds)
Q: How much time between blasts?
Q: Do the cylinders trigger after the blasts or during?
Q: How long is each cylinder activated?
Q: Is there any delay between the cylinders? -- or would each cylinder activate twice during that 8 seconds?
Q: Is "another air horn" another blast, or do you have a different horn?
Jon McPhalen
EFX-TEK Hollywood Office

m_evans

Sorry was a bit late and mind was disconnected from fingers...thought it did not type it clearly


Q: Is each blast 1 to 2 seconds, or do all three blasts (start to finish last 1 to 2 seconds) Total of all three blast
Q: How much time between blasts? half sec
Q: Do the cylinders trigger after the blasts or during? after blast 1 sec pause from horn to cylinders
Q: How long is each cylinder activated? 1 sec
Q: Is there any delay between the cylinders? -- or would each cylinder activate twice during that 8 seconds? all fire firing at random for 8 sec...it will be blasting air from several holes in the wall throughout a hallway.
Q: Is "another air horn" another blast, or do you have a different horn? differant horn

JonnyMac

Sorry, as I was writing the program I realized I may assumed something....

Do you want just one cylinder at a time, or random activity on all for eight seconds?  For some reason I got the idea that they would act like "goofy gofers," with only one active at a time.
Jon McPhalen
EFX-TEK Hollywood Office

m_evans

random activity.... is what i had in my mind

JonnyMac

Here's a starter -- though I must confess I don't know what your prop is so I am just writing code based on the mechanics of your description.  If yo have a Prop-1 Trainer you can see how it behaves without connecting to anything else.

' =========================================================================
'
'   File...... Horns.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 19 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Horn2           = PIN5
SYMBOL  Horn1           = PIN4
SYMBOL  Blast4          = PIN3
SYMBOL  Blast3          = PIN2
SYMBOL  Blast2          = PIN1
SYMBOL  Blask1          = PIN0


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  idx             = B2
SYMBOL  blasters        = B3

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


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs


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

Main:
  timer = 0                                     ' reset timer

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

Blast_Horn1:
  FOR idx = 1 TO 3
    Horn1 = IsOn
    PAUSE 150
    Horn1 = IsOff
    PAUSE 500
  NEXT
  PAUSE 1000

  timer = 0

Blast_Em:
  RANDOM lottery
  blasters = lottery & %00001111
  PINS = PINS & $F0 | blasters                  ' randomize blasters
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 0.1 to 0.25 seconds
  PAUSE delay
  timer = timer + delay
  PINS = PINS & $F0                             ' blasters off
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 0.1 to 0.25 seconds
  PAUSE delay
  timer = timer + delay
  IF timer < 8000 THEN Blast_Em
    PINS = PINS & $F0                           ' blasters off
    PAUSE 1000

Blast_Horn2:
  Horn2 = IsOn
  PAUSE 2000
  Horn2 = IsOff

  GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------


Jon McPhalen
EFX-TEK Hollywood Office

m_evans

Thank you this will allow me to tweak to my needs...