November 17, 2024, 11:41:31 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.


Using multiple sensors

Started by goober, June 16, 2008, 01:10:34 PM

Previous topic - Next topic

goober

Hi Jon,
Could you use two PIR sensors on a prop-1 to run two different relays?

I'd like the first sensor to start a fogger. Then when the mark gets to the prop the second sensor with turn on the a sopt light & air cannon. I'd like two sensors so I don't have to guess when to trip the prop. I don't want it to go off too soon or after it's been passed up.

I spent 4 hours with Vixen getting the prop-1 sequence and sequence generator add-ins installed. Now I'm getting a "template file is missing" error. I'm stuck so  I'm back to the old way.
If two sensors could be used how I write them in the prograam? Here is the short program I'v come up with:

' =========================================================================
'   File...... Air Cannon
'   Purpose... Prop control (prop-1)
'   Author.... Goober
'   E-mail.... nfli_today@earthlink.net
'   Started...6-15-08
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
' =========================================================================

' -----[ Program Description ]---------------------------------------------
'
'starts fogger the triggers lights and air cannon with 60sec reset time
'
' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL trigger    = PIN7            ' PIR sensor

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

SYMBOL Yes             =     1
SYMBOL No              =     0

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

  Reset:

  SYMBOL fogger = 6       ' make P6 an output
  SYMBOL lightcannon = 7      ' make P7 an output


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

Main:

  IF Trigger = No THEN Main        ' wait for "victim"

HIGH fogger                     ' activates out6
    PAUSE 9000                    '3.5sec hesitation after triggers tripped
HIGH lightcannon                     ' activates out7
    PAUSE 250
LOW lightcannon                         'deactivates out7
    PAUSE 30000
LOW fogger                        'deactivates out6
  PAUSE 60000                       ' program recovers
  GOTO Main                        ' back to Main

JonnyMac

I don't mean to seem harsh, but I'm having touble convincing you that to use our forum guidelines: one topic per thread, please....

Yes, you can use multiple PIRs.  I'm a few minutes from boarding a plane.  When I get home tonight I'll whip up a little demo.  Please post your Vixen questions in the Vixen section of the forums.
Jon McPhalen
EFX-TEK Hollywood Office

goober

Hi Jon,
Do you have a sample or could show me how to use two PIR sensors on a prop-1 to run two different relays?

I'd like the first sensor to start a fogger. Then when someone gets to the prop the second sensor will turn on a sopt light & air cannon.

JonnyMac

Here's a framework that you can tweak.

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


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


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


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

SYMBOL  PIR1            = PIN7                  ' SETUP = DN
SYMBOL  PIR2            = PIN6
SYMBOL  Cannon          = PIN2
SYMBOL  Light           = PIN1
SYMBOL  Fogger          = PIN0


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000111                              ' make P0-P2 outputs


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

Main:
  timer = 0                                     ' reset timer

Check_PIR1:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR1                      ' update timer
  IF timer < 200 THEN Check_PIR1                ' wait for 0.2 sec input

  Fogger = IsOn
  PAUSE 2000
  Fogger = IsOff

  timer = 0                                     ' reset timer!

Check_PIR2:
  PAUSE 5
  timer = timer + 5 * PIR2
  IF timer < 200 THEN Check_PIR2

  Light = IsOn
  Cannon = IsOn
  PAUSE 500
  Light = IsOff
  Cannon = IsOff

  GOTO Reset


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


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


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


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


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


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


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

goober

Jon
Is there a way to float the pir2 sequence in the program? I would like the pir1 to trip & run for 45sec and any time during the program the pir2 could be triggered once. With this program the pir1 will run forever until the pir2 is tripped then the pir1 45sec timer starts.
Also is there a way the program will reset after 60sec even if the pir2 hasn't been tripped, or does the program need to complete every step before it can be reset? or should I be using two prop-1s to run this prop?         

JonnyMac

June 22, 2008, 01:09:45 PM #5 Last Edit: June 22, 2008, 01:23:13 PM by JonnyMac
Forgive me, Goober, I'm under the weather a bit today and having trouble understanding the description.  Please restate it, step-by-step, one step per line, please.  This exercise will help me, and will help you; once you see your steps translated to code the code will make more sense.

And there's no need to for two controllers -- once I fully understand what you want I will be able to code it for you.
Jon McPhalen
EFX-TEK Hollywood Office

goober

Ok

Sequence I'd like to have programed:
   1- Pir1 trips a relay & goes for 45sec.
   2- Anytime while pir1 relay is running pir2 can be triggered. (for about 1/5sec)
   3-After the 45sec the program will reset even if the pir2 was never tripped.

Limits:
   Pir2 can only be triggered while pir1 relay is activated.
   Pir1 time line is unaffected by pir2

Problem I'm encountering:
   Pir1 time does not begin until pir2 has been tripped. in other words pir1 will run all day until pir2 has been triggered then the 45sec timer starts.

JonnyMac

Okay, we're getting there -- but you have a bunch of things defined (e.g., fogger, lights, etc) that you're not telling me how to operate -- give me those details, too.  To simply say "PIR 1 program" is vague and will just lead to more versions of the program than needed.

I know, the devil is in the details, but once you get used to spelling out the details, programming is a pretty simple chore.
Jon McPhalen
EFX-TEK Hollywood Office

goober

 1- Pir1 trips a relay for a fogger & goes for 45sec.
   2- Anytime while the fogger is running pir2 can be triggered. (for about 1/5sec)
          (Pir2 trips a relay for both a spot light & air cannon)
   3-After the 45sec the program will reset even if the pir2 was never tripped.
This is what I have so far:

Main:
  timer = 0
Check_pir1:
     PAUSE 5
     timer = timer + 5 * pir1
     IF timer < 200 THEN check_pir1
    HIGH fogger                                    'fogger on
  timer = 0
check_pir2:
    PAUSE 5
    timer = timer + 5 * pir2
    IF timer < 200 THEN check_pir2
    HIGH lightcannon                          ' light flashes & cannon fires
    PAUSE 50
    LOW lightcannon
    PAUSE 45000                               ' fogger runs 45sec
    LOW fogger                                  ' fogger off
  PAUSE 10000                                 ' 10sec til system resets
    GOTO reset

Spooky Dad

Did this thread move somewhere else?  I was interested in seeing the final outcome of the code as I have a very similar need.