November 22, 2024, 10:45:23 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.


Need program adjusted for PIR

Started by logs117, September 21, 2008, 01:13:26 PM

Previous topic - Next topic

logs117

I need the attached program to be changed to allow it to work with a PIR. The current program only loops while the PIR is attached.  I am new at this and trying to figure this out.

EricTheMannn

i looked at your code and added the pir script to it, i am no professional but this has worked for my pir trigger hope it works for you as well :)

-Eric
WooHoo

EricTheMannn

ps, i used the pntr code as the time because i didn't want to change anything within your code the origanal code Ive used looks like this (if needed)

-variables-
Symbol timer = b2

main:
timer = 0                                         'reset timer

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

JonnyMac

September 21, 2008, 02:57:36 PM #3 Last Edit: September 21, 2008, 03:20:55 PM by JonnyMac
Eric,

What you did is fine, though you neglected to reset the pntr variable after the trigger event and this will cause a problem as the show will want to start reading form address 100 instead of address 0.

Here's what that looks like when corrected:

Main:
  pntr = 0                                      ' reset timer

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


  pntr = 0                                      ' reset to start of show


Another option is to use a variable called delay as it's time oriented and already defined.


Mike,

Here's an update of your program.  Interestingly, I actually wrote that framework for Dale (Scare Parts) a long time ago so I know it well.  I've brought the code  up to date -- this should work for you.

' =========================================================================
'
'   File...... Gothic Dragon.BS1
'   Purpose... Scare Parts Prop Control Gothic Dragon for WV Penitentiary
'   Author.... Dale Underwood (www.scareparts.com)
'   E-mail.... dunderwood@scareparts.com
'   Started...
'   Updated... 21 SEP 2008 (Jon Williams, EFX-TEK)
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' serial I/O for AP-8
SYMBOL  Trigger         = PIN6                  ' trigger input button
SYMBOL  Valves          = PINS                  ' uses P0..P4 only


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

SYMBOL  Yes             = 1                     ' for active high input
SYMBOL  No              = 0


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

SYMBOL  temp            = B0                    ' value for pins
SYMBOL   fini           =  BIT7                 ' sequenced finished
SYMBOL  pntr            = B2                    ' table pointer
SYMBOL  delay           = B3                    ' delay in 1/10 seconds


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

Setup:
  PINS = %00000000                              ' clear outputs
  DIRS = %00011111                              ' P0..P4 are outputs

  SEROUT Sio, OT2400, ("!!!!!!AP8", %00, "X")   ' kill if playing


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

Main:
  delay = 0

Check_Trigger:
  PAUSE 5
  delay = delay + 5 * Trigger
  IF delay < 100 THEN Check_Trigger

  pntr = 0                                      ' reset to start of show

Start_SFX:                                      ' activate sound
  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)

Engine:
  READ pntr, temp                               ' read valves from table
  pntr = pntr + 1                               ' point to delay
  READ pntr, delay                              ' read delay from table
  pntr = pntr + 1                               ' point to next record

  Valves = temp & %00111111                     ' update the valves outputs
  GOSUB Timer                                   ' hold for timing

  IF fini = Yes THEN Main                       ' sequence done?
    GOTO Engine                                 ' no, continue


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

Timer:
  IF delay = 0 THEN Timer_Exit                  ' delay finished?
    PAUSE 75                                    ' no, hold 1/10 second
    delay = delay - 1                           ' update delay counter
    GOTO Timer                                  ' keep going

Timer_Exit:
  RETURN                                        ' return to caller


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

Move_Table:
'             LRJUO
  EEPROM (%00000101,  20)
  EEPROM (%00001011,  10)
  EEPROM (%00001111,   5)
  EEPROM (%00000011,   5)
  EEPROM (%00000101,   5)
  EEPROM (%00001011,  10)
  EEPROM (%00001111,  15)
  EEPROM (%00000001,  10)
  EEPROM (%00001111,   5)
  EEPROM (%00001011,   5)
  EEPROM (%00001101,   5)
  EEPROM (%00000001,   5)
  EEPROM (%00001101,   5)
  EEPROM (%00001011,   5)
  EEPROM (%00000111,   5)
  EEPROM (%00000101,   5)
  EEPROM (%00001001,   5)
  EEPROM (%00001011,   5)
  EEPROM (%00000111,   5)
  EEPROM (%00001011,   5)
  EEPROM (%00000011,   5)
  EEPROM (%00001101,   5)
  EEPROM (%00000001,   5) '
  EEPROM (%00001011,  10)
  EEPROM (%00000111,   5)
  EEPROM (%00001011,   5)
  EEPROM (%00000101,   5)
  EEPROM (%00001010,  10)
  EEPROM (%00000110,  15)
  EEPROM (%00000000,  10)
  EEPROM (%00001110,   5)

  EEPROM (%10000000, 100)                       ' 10 sec re-trigger delay
Jon McPhalen
EFX-TEK Hollywood Office

logs117

Thanks for all of the help that you have provided.  It is much appreciated. Mike

logs117

I uploaded the program that JonnyMac posted into the Prop1 board for the Gothic Dragon.  Now when it is turned on, the dragon continues to loop. The only difference is now his mouth doesn't open and close during the process. Can you help with this problem?
Mike

JonnyMac

If the dragon continues to loop then you have a continuous trigger input.  You asked for it to be adjusted for a PIR, I was assuming (silly me) that you meant the Parallax PIR that we sell.  What model is your PIR.  If it is the one we carry, make sure that the P6 SETUP jumper is in the DN position (if the P6 SETUP jumper is in the UP position that will cause the program to loop).

There were no operation changes made to the code so the mouth not working is likely a wiring problem.  I just ran the code on a Prop-1 Trainer and all the outputs used (P0 - P3) do in fact run.
Jon McPhalen
EFX-TEK Hollywood Office

livinlowe

I bet its the setup jumper. This has happened to me as well!
Shawn
Scaring someone with a prop you built -- priceless!

logs117

I have check the jumpers and the setup is off and the other jumper is in the down position. Attached is the information that I found for the PIR.

JonnyMac

Well, if you've connected it correctly it seems like it should work.

Sensor (O/P) --> P6.W
Sensor (V+) --> P6.R
Sensor (GND) --> P6.B

Again, the P6 SETUP jumper should be in the DN position.  If you remove the PIR the prop should not cycle.  Is that the case If it does cycle when you've connected the sensor it's either, 1) bad, or 2) it is being triggered by your body -- put it into a cup to that you can hide yourself from it during testing.
Jon McPhalen
EFX-TEK Hollywood Office