November 24, 2024, 02:38:19 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.


Pillar Program

Started by ravenscroft, September 17, 2007, 02:13:10 PM

Previous topic - Next topic

ravenscroft

I'm in need of a program for my pillars:
http://i8.photobucket.com/albums/a26/bktucker/Halloween%202006/CIMG1332.jpg

I had a program written a while ago, brandon_template.bs1, but I have a change.  what I need is this:
1. PIR triggers the sequence
2. 110v incandescent starts flickering for whole sequence. I have a couple RC-4's
3. 7 sec. later the solenoid is activated. ( using out0)
4. 1/2 sec later LEDs turn on. (using out1, and out2)
5. 1 sec. later cowlacious sound board is activated
6. run for 8 sec.
7. all off except Incandescent bulb which runs for another 5 sec.

It's the Rc-4 and the PIR that I have the biggest problem with right now, but I still need help.

JonnyMac

So long as you have flicker bulb connected to the RC-4 and you're not expecting the Prop-1 to create that flicker, this code will work for you. 

' =========================================================================
'
'   File...... Pillar.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Notes:
' -- replace ULN2803 with ULN2003
' -- remove P7 SETUP jumper
' -- move P6 SETUP jumper to DN position


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  SndFX           = PIN5                  ' for Cowlacious board
SYMBOL  Led2            = PIN2
SYMBOL  Led1            = PIN1
SYMBOL  Solenoid        = PIN0


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

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


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

SYMBOL  relays          = B0
SYMBOL   Lamp           = BIT0
SYMBOL   K2             = BIT1
SYMBOL   K3             = BIT2
SYMBOL   K4             = BIT3

SYMBOL  timer           = B2


SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear everything
  DIRS = %00100111                              ' configure output pins

  relays = IsOff                                ' clear RC-4 outputs
  GOSUB Set_RC4

  PAUSE 20000                                   ' let PIR stabilize
  timer = 0                                     ' clear timer for PIR


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' update PIR timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  Lamp = IsOn
  GOSUB Set_RC4
  PAUSE 7000

  Solenoid = IsOn
  PAUSE 500

  Led1 = IsOn
  Led2 = IsOn
  PAUSE 1000

  SndFX = IsOn
  PAUSE 50
  SndFX = IsOff
  PAUSE 8000

  Led2 = IsOff
  Led1 = IsOff
  Solenoid = IsOff
  PAUSE 5000

  GOTO Reset


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

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

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


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

ravenscroft

Sorry it took so long to get back, this is the first time all week that I have been able to get on my computer............I fall asleep as soon as I get home these days.  I did want the light to flicker using the prop-1, then I realized that it can't do that, am I right?  But never mind about recoding it if it can because I came up with another way of flickering it, and still using the prop-1 rc-4 combo.  I'll let you know what it is after I find out if it works, otherwise I have to think of something else.

Thanks again my good man!!!!

JonnyMac

Give this version a try -- flickering via RC-4 is tough for a couple reasons, but this may flicker enough to satisfy your prop requirement.

' =========================================================================
'
'   File...... Pillar_v2.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Notes:
' -- replace ULN2803 with ULN2003
' -- remove P7 SETUP jumper
' -- move P6 SETUP jumper to DN position


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  SndFX           = PIN5                  ' for Cowlacious board
SYMBOL  Led2            = PIN2
SYMBOL  Led1            = PIN1
SYMBOL  Solenoid        = PIN0


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

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


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

SYMBOL  relays          = B0
SYMBOL   Lamp           = BIT0
SYMBOL   K2             = BIT1
SYMBOL   K3             = BIT2
SYMBOL   K4             = BIT3

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


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

Reset:
  PINS = %00000000                              ' clear everything
  DIRS = %00100111                              ' configure output pins

  relays = IsOff                                ' clear RC-4 outputs
  GOSUB Set_RC4

  PAUSE 20000                                   ' let PIR stabilize
  timer = 0                                     ' clear timer for PIR


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

Main:
  RANDOM lottery                                ' stire random value
  PAUSE 10
  timer = timer + 10 * PIR                      ' update PIR timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  flickTm = 7000
  GOSUB Flicker

  Solenoid = IsOn
  flickTm = 500
  GOSUB Flicker

  Led1 = IsOn
  Led2 = IsOn
  flickTm = 1000
  GOSUB Flicker

  SndFX = IsOn
  PAUSE 50
  SndFX = IsOff
  flickTm = 8000
  GOSUB Flicker

  Led2 = IsOff
  Led1 = IsOff
  Solenoid = IsOff
  flickTm = 5000
  GOSUB Flicker

  GOTO Reset


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

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

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

' Used to simulate flicker on K1 of RC-4. May not work well as zero-cross
' switching of RC-4 relay prevents direct control over lamp.

Flicker:
  timer = 0

Flick_Again:
  IF timer >= flickTm THEN Flicker_Done
    RANDOM lottery                              ' re-stir
    Lamp = lottery                              ' copy bit0
    GOSUB Set_RC4
    timer = timer + 30                          ' command time to RC-4
    GOTO Flick_Again

Flicker_Done:
  RETURN


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

livinlowe

I would imagine that flickering a light bulb with a RC-4 would shorten its life span significantly, wouldn't it? Of course, this is for halloween, so I'm sure cost isn't that big an issue. Just being a geek!  8)
Shawn
Scaring someone with a prop you built -- priceless!

ravenscroft

Even if it does shorten its life it can't shorten it anymore than I already do with it.  (if that wasn't clear this will be)  The bulb is on top of pillar and it rises up on a pneumatic piston, the violent slamming up and down usually breaks the filament at least twice a night on both of my pillars.  That is why I have 10 green bulbs ready, of course I think next year I will be switching the incandescent to a host of LEDs so I will be changing it again but that I don't need to worry about until I get off my lazy butt and make the darn things. :)