November 21, 2024, 11:33:05 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.


Shaking Affect Programming

Started by gremlock, October 22, 2009, 10:09:13 AM

Previous topic - Next topic

gremlock

I currently love the programming I have and would like to personally thank Johnny Mac.  I would like to add about 5 seconds of very quick on/off sequences before the random kicks in on the chair valve, I would like to keep the current valve just add 5 seconds of really quick on/off.  If you can, provide me with how i can change it if the 5 second on/off sequenes are too fast or too slow.  My current program is below..............


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


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CARP            = PIN5                  ' V+/OUT5 to V-Trig @12v

SYMBOL  Fogger          = PIN2                  ' V+/OUT2 to relay
SYMBOL  Chair           = PIN1                  ' V+/OUT1 to valve
SYMBOL  Light           = PIN0                  ' V+/OUT0 to relay


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

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


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00111111                              ' set output pins

  PAUSE 30000                                   ' PIR warm-up


' -----[ 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

  Light = IsOn
  timer = 0

Start_Audio:
  CARP = IsOn
  PAUSE 50
  CARP = isOff

Shake_It:
  Chair = 1 - Chair                             ' toggle chair valve
  RANDOM lottery                                ' restir random #
  delay = lottery // 201 + 50                   ' 0.05 to 0.25s
  PAUSE delay
  timer = timer + delay

Check_Fog:
  IF timer < 1000 THEN Shake_It                 ' run 1s before smoke
    Fogger = IsOn

Check_Show:
  IF timer < 10000 THEN Shake_It                ' (adjust for audio timing)
    PINS = %00000000                            ' everything off

Program_Delay:                                  ' hold 5 minutes
  FOR timer = 1 TO 5
    PAUSE 60000
  NEXT
  GOTO Main


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


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



JonnyMac

That's an easy update:

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


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CARP            = PIN5                  ' V+/OUT5 to V-Trig @12v

SYMBOL  Fogger          = PIN2                  ' V+/OUT2 to relay
SYMBOL  Chair           = PIN1                  ' V+/OUT1 to valve
SYMBOL  Light           = PIN0                  ' V+/OUT0 to relay


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

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


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00111111                              ' set output pins

  PAUSE 30000                                   ' PIR warm-up


' -----[ 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

  Light = IsOn

Start_Audio:
  CARP = IsOn
  PAUSE 50
  CARP = isOff

  timer = 0

Buzz:
  Chair = 1 - Chair                             ' toggle chair valve
  PAUSE 50                                      ' short delay
  timer = timer + 50                            ' update timer
  IF timer < 5000 THEN Buzz                     ' done buzzing?

  timer = 0

Shake_It:
  Chair = 1 - Chair                             ' toggle chair valve
  RANDOM lottery                                ' restir random #
  delay = lottery // 201 + 50                   ' 0.05 to 0.25s
  PAUSE delay
  timer = timer + delay

Check_Fog:
  IF timer < 1000 THEN Shake_It                 ' run 1s before smoke
    Fogger = IsOn

Check_Show:
  IF timer < 10000 THEN Shake_It                ' (adjust for audio timing)
    PINS = %00000000                            ' everything off

Program_Delay:                                  ' hold 5 minutes
  FOR timer = 1 TO 5
    PAUSE 60000
  NEXT
  GOTO Main


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


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

gremlock

Thanks again johnny mac for the 5 second addition to my program, i like whats its trying to do but it is currently triggering the valve so fast that it doesnt move during the first 5 seconds(buzz).  What part of the program needs editing so that i can tweak how fast its activating the valve during the "Buzz"?  Thanks

JonnyMac

This part:

Buzz:
  Chair = 1 - Chair                             ' toggle chair valve
  PAUSE 50                                      ' short delay
  timer = timer + 50                            ' update timer
  IF timer < 5000 THEN Buzz                     ' done buzzing?


Try changing the 50 to 100 -- both lines have to match in order for the timing line (last line) to work.
Jon McPhalen
EFX-TEK Hollywood Office