November 22, 2024, 02:34:25 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.


last one

Started by tj, October 09, 2008, 06:59:07 PM

Previous topic - Next topic

tj

last prop for this year. this is the one i mentioned on the phone.  the prop is an electric chair.

i have a led spot that i want to be on (bright) untill triggered (matswitch) i want ap-8 to play segment 1 (last for 20 sec.) two soleniods

to be fired randomly while led spot pwms randomly. after 14 seconds. fogger on for 6 remaining secs then reset.

thanks 


JonnyMac

October 09, 2008, 07:46:36 PM #1 Last Edit: October 11, 2008, 09:54:35 AM by JonnyMac
Yeah... an easy one -- except that you didn't give me a name for this dude (which means it's not saved on my pc!).

Note that PWM provides the delay instead of PAUSE.  I used 20 units in the cycles parameter which means that the PWM delay will be 100ms.  If you want to slow things make this number (20) bigger and then update the value (100) that's added into timer for show control.

[Edit] Added fogger output 14 seconds into thrashing cycle.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Fogger          = PIN3
SYMBOL  Valve2          = PIN2
SYMBOL  Valve1          = PIN1
SYMBOL  Led             = 0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  lottery         = W0                    ' allow bit access
SYMBOL   level          =  B0
SYMBOL   v1Enable       =  BIT8
SYMBOL   v2Enable       =  BIT15

SYMBOL  timer           = W1


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

Reset:
  PINS = %00000001                              ' clear all
  DIRS = %00001111                              ' set outputs

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


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

Main:
  timer = 0                                     ' reset timer

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

  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' start audio
  timer = 0                                     ' clear thrashing timer

Thrash:
  RANDOM lottery
  Valve1 = v1Enable
  Valve2 = v2Enable
  PWM Led, level, 20                            ' 20 x 5ms = 100ms
  timer = timer + 100

Check_Fogger:
  IF Fogger = IsOn THEN Check_Timer             ' skip if already on
  IF timer < 14000 THEN Thrash                  ' check fogger start time
    Fogger = IsOn                               ' let it smoke!

Check_Timer:
  IF timer < 20000 THEN Thrash                  ' keep going if not 20 secs
    Valve1 = IsOff
    Valve2 = IsOff
    Fogger = IsOff
    PAUSE 5000                                  ' rest
    GOTO Reset


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


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


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

tj

looks good just noticed the fogger wasn't in the code. after 14 secs, i wanted the fogger for the remainig six with the other stuff still going.

JonnyMac

Whoops, sorry about that -- see the updated listing.
Jon McPhalen
EFX-TEK Hollywood Office

tj

thanks. i didn't think it was that simple, guess i should have tried.

JonnyMac

Yes, you should have.  ;D  But now that you've seen how it's done, you can fold this trick into other programs.
Jon McPhalen
EFX-TEK Hollywood Office

tj

got everything in today, i was wondering if i could slow down only the v2enable loop. this is what controls the leg and it takes longer

to move. i would like for it to move less often also. everything else looks ok.

JonnyMac

Try this -- it should slow V2 down to half speed.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Fogger          = PIN3
SYMBOL  Valve2          = PIN2
SYMBOL  Valve1          = PIN1
SYMBOL  Led             = 0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  lottery         = W0                    ' allow bit access
SYMBOL   level          =  B0
SYMBOL   v1Enable       =  BIT8
SYMBOL   v2Enable       =  BIT15

SYMBOL  timer           = W1
SYMBOL  v2Control       = B4


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

Reset:
  PINS = %00000001                              ' clear all
  DIRS = %00001111                              ' set outputs

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


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

Main:
  timer = 0                                     ' reset timer

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

  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' start audio
  timer = 0                                     ' clear thrashing timer

Thrash:
  RANDOM lottery
  Valve1 = v1Enable
  IF v2Control = 0 THEN Led_On
    Valve2 = v2Enable

Led_On:
  v2Control = 1 - v2Control
  PWM Led, level, 20                            ' 20 x 5ms = 100ms
  timer = timer + 100

Check_Fogger:
  IF Fogger = IsOn THEN Check_Timer             ' skip if already on
  IF timer < 14000 THEN Thrash                  ' check fogger start time
    Fogger = IsOn                               ' let it smoke!

Check_Timer:
  IF timer < 20000 THEN Thrash                  ' keep going if not 20 secs
    Valve1 = IsOff
    Valve2 = IsOff
    Fogger = IsOff
    PAUSE 5000                                  ' rest
    GOTO Reset


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


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


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

tj

awsome, i dont understand the code yet, but lookin. thanks

JonnyMac

The new variable, v2Control, causes the v2Enable pin to get updated every other cycle -- this slows it to about 50% of the speed it was running before.
Jon McPhalen
EFX-TEK Hollywood Office