November 24, 2024, 02:56:28 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.


Program for Dr. Phobic

Started by WolfManor, October 03, 2007, 01:13:54 PM

Previous topic - Next topic

WolfManor

October 03, 2007, 01:13:54 PM Last Edit: October 03, 2007, 06:40:07 PM by WolfManor
Jon,

To start, I just want to say thanks for the support you and the EFX-TEK team put into these products.  This is crunch time for you guys and we (everyone) appreciates the time you put in to help all of us!

I am looking for a program that will run my graveyard keeper.  It should run along these lines.  I do not have the RC-4 inline at the moment but may incorporate that later if time and planning permit (That never happens this time of year).  If there is anything that I have left out let me know.  Also, I am not super savvy in electronics so if I am powering a couple of LEDs for the Eyes, do I need to use a specific Resistor (Value) and Output (PIN or OUT) on the Prop-1 to get the best results?  I should be able to handle the rest from that. 

I will be moving the PIN6 SETUP Jumper to DN.  And I am changing to the ULN2003.  If there are any additional changes I need to make to the boards let me know as well. 


Details:
Prop-1 ? Controller
RC-4 ? AC Relay Board (%00) ? Currently Not Used but may add function later
AP-8 ? Sound Board (%00)
PIR Sensor ? Trigger - PIN6
Rotary Cylinder by Solenoid ? Head Turning Left and Right (Default to Left) ? OUT0
WickLED ? Placed in Lantern (Default OFF) ? OUT3
Two LEDs (Green) ? Placed in Eyes (Default OFF) ? OUT2

Program Details:
1.   Head is set to the Left during Reset/Wait Period.
2.   When a Trigger is detected (PIR) in PIN6 the sequence starts.
3.   Light Lantern WickLED (Until Reset) - May want to add a short delay for effect (2 seconds)
4.   Light LED Eyes (Until Reset) - (If an RC-4 is implemented it would turn on a 120VAC spot light here.  Then the spot light would remain on until reset at the end).
5.   Randomly Pick a Sound (AP-8) from one of 8 sounds (2-5 seconds each)
6.   Play sound and Turn head to the right (As close to simultaneously to start of sound)
7.   Wait 2 seconds after sound ends (Sounds are 2-5 seconds in length) - Can you get the length of the sound and then set accordingly?
8.   Turn Head to Left (Reset Head) - No delay between Head and Eyes reset
9.   Turn LED Eyes Off (Reset LED Eyes) - No delay between Head and Eyes reset
10.   Wait 3 seconds
11.   Turn Lantern WickLED off (Reset WickLED)
12.   Wait 30-45 Seconds (Reset Everything for next ?Victim?)
Steve

JonnyMac

Is the WickLED supposed to flicker?  If yes, that complicates things -- but not so much that I can't do it.   ;)
Jon McPhalen
EFX-TEK Hollywood Office

WolfManor

Jon,

I was thinking it would.  However, those are in my next order (I haven't had a chance to play with them yet) so I was not aware that I could have them flicker or not. 

If you can make it flicker that would be great!  You are the master!

Thanks!
Steve

JonnyMac

October 03, 2007, 03:29:06 PM #3 Last Edit: October 03, 2007, 03:31:45 PM by JonnyMac
I am the master! (insert evil laugh here)   ;D

The WickLED doesn't flicker on its own (we're working on one that does), it counts on a random pulse train and its onboard cap to create the flame effect.  No worries, since most programs actually need to wait for things to finish, I've created a subroutine called Flicker_Pause that you'll use instead of PAUSE.  Instead of:

PAUSE 2000

... you'll do this:

delay = 2000
GOSUB Flicker_Pause


This will create the desired delay AND create the proper output for the WickLED.

Here's your program (with RC-4 support for later):

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN (or out)
SYMBOL  WickLed         = PIN3
SYMBOL  Eyes            = PIN2
SYMBOL  Head            = PIN0


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

SYMBOL  Baud            = OT2400                ' for Prop-1

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

SYMBOL  TurnLeft        = 0
SYMBOL  TurnRight       = 1


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

SYMBOL  relays          = B0                    ' RC-4 relays
SYMBOL   K1             = BIT0
SYMBOL   K2             = BIT1
SYMBOL   K3             = BIT2
SYMBOL   K4             = BIT3

SYMBOL  sfx             = B1                    ' AP-8 segment
SYMBOL  flickDelay      = B2                    ' for WickLED ops
SYMBOL  timer           = W3
SYMBOL  delay           = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00001111                              ' set output pins

  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X", "!RC4", %00, "X")

  PAUSE 30000                                   ' warm-up/inter-show delay
  timer = 0


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

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

  delay = 2000
  GOSUB Flicker_Pause

  Eyes = IsOn

  sfx = lottery // 8                            ' select sound, 0..7
  GOSUB Play_Sound                              ' play it

  Head = TurnRight

  ' Update LOOKUP table with sound duration (ms) + 2000 for each
  ' entry. First entry is sound 0, last is sound 7

  LOOKUP sfx, (7000, 7000, 7000, 7000, 7000, 7000, 7000, 7000), delay
  GOSUB Flicker_Pause

  Head = TurnLeft
  Eyes = IsOff

  delay = 3000
  GOSUB Flicker_Pause

  WickLed = IsOff

  GOTO Reset


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

' Use in place of PAUSE
' -- creates delay while flickering WickLED

Flicker_Pause:
  timer = 0                                     ' clear timer

Flick_Again:
  RANDOM lottery                                ' stir random value
  WickLed = lottery                             ' copy bit 0
  flickDelay = lottery // 16 + 20               ' 20 to 35
  PAUSE flickDelay                              ' hold
  timer = timer + flickDelay                    ' update timer
  IF timer < delay THEN Flick_Again             ' time left?
  RETURN

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

' Plays "sfx" in AP-8
' -- make sure "sfx" is 0..7

Play_Sound:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN

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

' Sends "relays" to RC-4

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


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

WolfManor

Jon,

As always, THANKS!

I will download and test this weekend. 

I see in the documentation for the Prop-1 that you are showing the LED Strobe as using 470ohm Resistors for one LED.  Should I look to use this same ohm resistor for the two LED?  Will this cause any power issues on the board?

Thanks!
Steve

JonnyMac

Depends on where you're connecting them; if you use a Px terminal you've only got 5 volts out; if you use an OUTx terminal you will [likely] have 12 volts -- this means that you have to size your resistor accordingly.

Assuming...
-- OUTx
-- foward current of 20 mA
-- forward LED voltage of 1.5 volts
-- LEDs are connected in series.

  12v - 3v = 9v / 0.02 = 450; so a 470 (standard value) will be fine
Jon McPhalen
EFX-TEK Hollywood Office