November 05, 2024, 01:00:55 AM

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.


Thrashing Coffin

Started by Lotus, June 29, 2008, 05:48:29 PM

Previous topic - Next topic

Lotus

Hey I am wondering if my coding is correct

              File....... Thrashing_Coffin.BS1
'   Purpose.... Outcome of when PIR sensor is tiggered
'   Author..... Joseph (Lotus) Lajoie
'   E-mail..... Joey7252@yahoo.com
'   Started.... 29 June 2008
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================
' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger        = PIN6                  ' P6; SETUP = DN
SYMBOL  Fogger         = PIN2                  ' V+/OUT2
SYMBOL  Coffin lid     = PIN1                  ' V+/OUT6
' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0
' -----[ Variables ]-------------------------------------------------------

SYMBOL  delay           = W4                    ' for random delays
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear everything
  DIRS = %00000111                              ' set outputs


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

Main:
  RANDOM lottery                                ' stir random value
  IF Trigger = IsOff THEN Main                  ' wait for trigger

  Fogger = IsOn                                 'Fogger turns on
  PAUSE 5000                                    'Wait 5 seconds
  Coffin = IsUp                                 'Lid goes up
  PAUSE 500                                     'Wait .5 seconds
  Coffin = IsDown                               'Lid goes down
  PAUSE 500                                     'Wait .5 seconds
  Coffin = IsUp                                 'Lid goes up
  PAUSE 2000                                    'Wait 2 seconds
  Coffin = IsDown                               'Lid goes Down
  PAUSE 1000                                    'Wait 1 second
  Coffin = IsUp                                 'Lid goes up
  PAUSE 500                                     'Wait .5 seconds
  Coffin = IsDown                               'Lid goes down
  PAUSE 500                                     'Wait .5 seconds
  Coffin = IsUp                                 'Lid goes up
  PAUSE 2000                                    'Wait 2 seconds
  Coffin = IsDown                               'Lid goes Down
  PAUSE 10000                                   'Wait 10 seconds for audio to finish
  Audio = IsOff                                 'Turn Audio off
  PAUSE 2000                                    'Wait 2 seconds
  Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 60000                                   ' one minute

  GOTO Main

JonnyMac

It looks fine -- does it work?  The only think I would suggest is debouncing the trigger to prevent false inputs, especially since you're using a PIR (which can be twitchy).  Add a byte variable called 'timer' and then use this code at the beginning:

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

  ' prop code here
Jon McPhalen
EFX-TEK Hollywood Office

Lotus

I tried it a little bit ago and the prop 1 made a puff of smoke so now i am trying to find what went wrong

Lotus

it looks like nothing is broken but no idea where the puff of smoke came from

JonnyMac

Clearly something is miswired or you're using solenoids that draw much more current that the Prop-1 can handle (specs are published in the documentation).
Jon McPhalen
EFX-TEK Hollywood Office

Lotus

And now the thrashing coffin code works great, looks like the puff of smoke fixed it

Lotus

June 29, 2008, 10:07:21 PM #6 Last Edit: June 29, 2008, 10:57:11 PM by Lotus
just that it is trigger as soon as i turn the prop 1 on, is that because of my code,  also the motion sensor all of the sudden stoped responding, I tried it out with the prop-1 trainer and the leds just go on even if i put the motion senor in a box

livinlowe

Smoke is never good with electronics - it's the 'magic' that makes it go! Look over your wiring CAREFULLY!  :P
Shawn
Scaring someone with a prop you built -- priceless!

Lotus

Alright it looks like the reset button made the smoke

JonnyMac

Check the position of the SETUP jumper on P6 -- it should be in the DN position.
Jon McPhalen
EFX-TEK Hollywood Office

Lotus

June 30, 2008, 08:11:27 AM #10 Last Edit: June 30, 2008, 08:28:39 AM by Lotus
Yup both are DN,

JonnyMac

I pulled your code into my editor and found a couple little things -- though they should effect operation.  I suspect there's some kind of wiring thing, but can't tell unless you send me a (clear) picture of the board.  For example, you have a line that turns off the audio, but never one that turns it on.  What kind of audio player are you using?

For grins, I modified your program to use the RANDOM feature of PBASIC. 

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


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


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


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

SYMBOL  Trigger         = PIN6                  ' P6; SETUP = DN
SYMBOL  Fogger          = PIN2                  ' V+/OUT2
SYMBOL  Coffin          = PIN1                  ' V+/OUT1
SYMBOL  Audio           = PIN0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0


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

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random value


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

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


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

Main:
  timer = 0                                     ' reset timer

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

  Fogger = IsOn                                 ' fog it up
  PAUSE 5000
  Fogger = IsOff

  Audio = IsOn                                  ' blip the audio player
  PAUSE 50
  Audio = IsOff

  timer = 0

Bounce_Lid:
  RANDOM lottery
  delay = lottery // 751 + 250
  Coffin = 1 - Coffin                           ' toggle coffin output
  PAUSE delay
  timer = timer + delay
  IF timer < 16500 THEN Bounce_Lid
    Coffin = IsDown

Long_Delay:
  PAUSE 60000
  PAUSE 60000

  GOTO Main


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


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


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


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

Lotus

yea the audio found its way in there I was copying and pastsing and must of highlighted it

Lotus

the code and prop 1 work great but the motion senor seem like its broke it does not trigger with motion seems like it is always on and just set the prop 1 off after the delay time

livinlowe

It's possible you have a bad sensor. I know last year parallax ( the company that makes them) had a bad batch. It wasn't the sensor you "let the smoke out of" was it?
Shawn
Scaring someone with a prop you built -- priceless!