November 23, 2024, 04:04:36 PM

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.


Tentacle coding

Started by vista, September 19, 2010, 06:39:46 PM

Previous topic - Next topic

vista

September 19, 2010, 06:39:46 PM Last Edit: September 19, 2010, 06:57:31 PM by vista
Hi Jon, this one should be pretty simple (for you that is)  ;D I took some old code that you wrote for me in 2008 and I re-purposed it but I don't think I grabbed everything I needed since this works but is buggy. (especially the PIR) I have a video up on youtube to show it's current action (http://www.youtube.com/watch?v=99wk3mhb0y0) and it isn't too bad. but I think it can be better. (code is at bottom)

I'm using a prop1 through the RC4 relay to power the solenoid. The Pir seems to be just firing in a loop and even if I leave the room it is still firing every 15-25 seconds (because I probably didn't close a statement correctly).

But instead of the random and lottery can we just set it to wait for input and fire the pneumatic  until the viewers leave for the next scare or 5 iterations happen.
I'm thinking that since I'd like this to seem less mechanical do you think throwing a random at the pause between firings so it fires and then pauses 1-3 seconds then fires again...  Do you or anyone else??) think this would make it seem more animal and less computer?

I'd also like to be able to control the iteration in the code so if I want more or less loops all I have to do is change the loop number.

After the loop I would like it to turn off the pir for 30 seconds and then reset it and be ready to fire again.

Did I give you enough info this time?
If not I apologize now as I know you hate not having all the facts...

Vista (did I just blow up my board? )

  ' =========================================================================
'
'   File...... Casket.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... 27 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN


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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0                     ' for active-high in/out

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   Arm            = BIT3                 ' RC-4 K4

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


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

Reset:
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear relays
  relays = %0000

  PAUSE 6000                                   ' 1-minute warm-up/delay


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

Main:
  timer = 0                                     ' reset timer

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



  Arm = IsUp                               ' make sure it's open
  GOSUB Set_RC4
  PAUSE 50
  Arm = IsDown                                         ' get lid out of the way


  GOTO Reset


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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

JonnyMac

Okay, as we're really in the heat of the season, simpler is better.  Just tell me what you want, in plain English.   Right now I'm confused by your post.  There is no need to show me code that doesn't work (I write plenty of that, thank you <wink>).

In my opinion, random timing between "firings" is always more organic.
Jon McPhalen
EFX-TEK Hollywood Office

vista


The pir will fire the pneumatic and it will extend then release (fall back)  (I currently have 50 for the pause and that seems to be long enough between the extension and releasing the air (two way valve). it will pause for a second or two no more than three and I'm thinking the variable pause should be in the hundredths of seconds and not whole seconds. It will fire 5 times (which I would like to be able to edit) hitting the glass as it tries to get the person standing in front of the tank.

Then the PIR will shut down for 20-30 seconds and be ready for the next victim/viewer.

Is this better?

Vista  (did I just blow up my board?)

bsnut

September 20, 2010, 01:17:01 AM #3 Last Edit: September 20, 2010, 06:00:17 AM by bsnut
Quote from: JonnyMac on September 19, 2010, 07:17:15 PM
Okay, as we're really in the heat of the season, simpler is better.  Just tell me what you want, in plain English.   Right now I'm confused by your post.  There is no need to show me code that doesn't work (I write plenty of that, thank you <wink>).

In my opinion, random timing between "firings" is always more organic.
I agree with Jon on this one.

This is what I can do for you, I can write a new program for you,which easy for me. Tell me how you want the program to work.

Now if the PIR is always triggering the prop without someone in front of it, you may have the setup jumper in the "up" position or your PIR is bad. Try this, disconnect the PIR and trigger the prop1 between the "W" and "R" on the pin that the PIR was connected to. If you have no problem after you removed the PIR, then you have a bad PIR, that is if the setup jumper is set for the "Down" position.
William Stefan
The Basic Stamp Nut

JonnyMac

Give this a try -- it randomizes the number of jumps (3 to 5) and the timing in between.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   Arm            =  BIT3                 ' RC-4 K4

SYMBOL  timer           = B2
SYMBOL  jumps           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

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

 relays = IsOff
 GOSUB Update_RC4

 PAUSE 30000                                   ' pir warm-up / reset delay


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

Main:
 timer = 0                                     ' reset timer

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

 jumps = lottery // 3 + 3                      ' 3 to 5 jumps

Get_Jumpy:
 Arm = IsUp
 GOSUB Update_RC4
 PAUSE 50
 Arm = IsDown
 GOSUB Update_RC4
 RANDOM lottery
 delay = lottery // 2001 + 500                 ' 0.5 to 2.5s
 PAUSE delay
 jumps = jumps - 1
 IF jumps > 0 THEN Get_Jumpy

 GOTO Reset


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

Update_RC4:
 SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
 RETURN

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


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

JackMan

September 20, 2010, 03:29:22 PM #5 Last Edit: September 20, 2010, 03:37:12 PM by JackMan
vista,
    You have a Pause value of 6000 in "Reset" for PIR warm up. This is only 6 seconds, not enough. This will cause the PIR to trigger the program several times before the PIR is ready to "wait for victim". Jon's version has 30 seconds for this which should be fine, I usually go with 60 seconds. Also, the last line of your "Check_Trigger" code  (your version) has a value of < 1000,  It should be < 100.

bsnut

I should have spotted the low value for the Pause and the line changed in the "Check_Trigger" code and JackMan pointed it out. PIR do go bad, but this problem lies in the line of code that was changed.

   
William Stefan
The Basic Stamp Nut

vista

finally got this loaded...
Jon first things first... Thanks
BSNut... thanks also

BS- the P6 jumper is set on down the P-7 is off

Jon, is the program supposed to keep running in a loop? It fires every 30 seconds whether I'm in the room or if I go into the other room and have a seat.
I just opened up my last PIR (gulp) as the other one went with a prop to the haunt this morning. So assuming that this one is good versus the last one then it shouldn't be a faulty PIR... Also this is a brand new Prop1.

Right now it fires a random burst  3-5 arm raises and then lays down for 30 seconds and then firs a random 3-5.
In looking over the code I see it checking the trigger but your note in the remarks section says " pir warm-up / reset delay". 

Obviously not the authority but shouldn't it have to wait for the trigger and then run pause 30 seconds and continue the rest of the code?
Is the "wait for 0.1 sec input" where it gets it's command to run the pgm but what stops it until next firing...

Sorry I was up to 2:30AM working on rebuilding a prop, so I'm thinking this is getting redundant sounding... my bad

I'll wait to hear back as how bad I have it messed up...

bsnut

What it sounds like too me, that the Setup jumper is set in wrong position on the prop1, check this first.

The program that Jon did for you, states that the Setup jumper should be set in Down position for the PIR. Move the Setup jumper to Down position and do not change the code in the program that Jon did for you. You should see the program work correctly.

The "Check_Trigger" code in the program is debounce code and it is use to make sure that the PIR is really triggering the pin that you are using as an input.
William Stefan
The Basic Stamp Nut

JackMan

September 22, 2010, 05:53:32 AM #9 Last Edit: September 22, 2010, 06:02:08 AM by JackMan
Quotethe P6 jumper is set on down the P-7 is off

Your P6 jumper is correct, the P7 jumper should be in the UP position and that pin on the ULN should be clipped.

QuoteObviously not the authority but shouldn't it have to wait for the trigger and then run pause 30 seconds and continue the rest of the code?
Is the "wait for 0.1 sec input" where it gets it's command to run the pgm but what stops it until next firing...

No, if there was a 30 second PAUSE after the PIR is triggered your victim will be long gone when the program executes. At the end of the program the last command is GOTO Reset which has the 30 second PAUSE. This prevents the program from  triggering again for 30 seconds.

vista

1. The 2803 has been clipped       (currently correct)
2. The P6 is on the right two pins (DN)   (currently correct)
3. The P7 is off on one pin only and I will put it on the two right pins (up)  (currently needs to be done)

We'll see if this makes a difference

I'll let you know.

JonnyMac

Pull the PIR and run the program -- you shouldn't see any activity.  If that's the case, try to connect a normally open switch to your input to use as a test (if you have a Prop-1  Trainer, install it and use the push-button).

PIRs can be finicky and very difficult to test with (which is why I prefer mat switches to them).
Jon McPhalen
EFX-TEK Hollywood Office

vista

I pulled the pir and nothing happens (prop doesn't start on it's own) but I'll have to wait till this afternoon to try a manual switch.. It only contacts two pins and I assume that will be ok. It worked for the prop last year so I assume it will fire it here... (let you know later)

Would it help if I took pictures of Prop 1/RC4 board setup to see if e can tell visually what I may have done wrong? I'm a photographer and work better visually but schematics don't do it...

JackMan

September 22, 2010, 11:56:35 AM #13 Last Edit: September 22, 2010, 12:15:25 PM by JackMan
QuoteI pulled the pir and nothing happens (prop doesn't start on it's own)

I'd say there's an issue with either the PIR or the wires connecting it to PIN6. With the PIR removed, connecting P6/W and P6/R should trigger the program. (after 30 seconds has elapsed from power up)

vista

@Jackman   when I get out of work I'll hook another two wire switch to the prop one. I know the reaction to pulling the pir since I've done that a few times trying to figure out if it's something I did.. Ie. reverse the wires so I made sure the white was on out on the pir and it is DN. I also tried high and low on the PIR. I assume that is for different sensitivity?
I even tried a different three wire to try.

heading home in an hour... and will try the two wire switch....