November 21, 2024, 11:34:52 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.


Prop-2 Christmas Light Controller Program

Started by rawille, November 24, 2008, 12:54:15 PM

Previous topic - Next topic

rawille

I built a Christmas light controller box that controls 32 Christmas light strings using 4 RC-4 & 4 FC-4 boards and the Prop-2 controller. I'm trying to develop a program that will:
1) Turn off or on any or all light strings
2) Be able to adjust and set the on and off time sequence (vary the length of on and off times)
3) have a total on / off sequence that lasts between 60 to 90 seconds (longer would be nice if possible)
4) no trigger requirement (sequence will reset and start when the control box is turn on)
5) no sound requirement (probably will be added in the future - next year?)
6) when the sequence ends it will loop and start over (run continuously)

Any help would be greatly appreciated.

JonnyMac

November 24, 2008, 07:10:17 PM #1 Last Edit: November 26, 2008, 02:31:10 PM by JonnyMac
Here's a framework to get you started.  Since you're mixing RC-4s and FC-4s I'm using the "D" command in the FC-4 -- this makes it behave like an RC-4 and keeps the data table simple (and smaller).

' =========================================================================
'
'   File...... Lights.BS2
'   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... 24 NOV 2008
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN


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

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

Yes             CON     1
No              CON     0

T2400           CON     396
T9600           CON     84
T19K2           CON     32
T38K4           CON     6

Inverted        CON     $4000
Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

pntr            VAR     Word                    ' data pointer
lightsLo        VAR     Word                    ' RC-4 channels ( 1 - 16)
lightsHi        VAR     Word                    ' FC-4 channels (17 - 32)
timer           VAR     Byte


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000000 : DIRL = %00000000           ' set outputs


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

Main:
  pntr = 0

Run_Show:
  READ pntr, lightsHi.BYTE1, lightsHi.BYTE0, lightsLo.BYTE1, lightsLo.BYTE0,
       timer

  IF (timer = 0) THEN
    GOTO Main                                   ' start over
  ELSE
    pntr = pntr + 5                             ' point to next record
  ENDIF

Update_Outputs:
  SEROUT Sio, Baud, ["!FC4", %11, "D", lightsHi.nib3,
                     "!FC4", %10, "D", lightsHi.Nib2,
                     "!FC4", %01, "D", lightsHi.nib1,
                     "!FC4", %00, "D", lightsHi.NIB0,
                     "!RC4", %11, "S", lightsLo.NIB3,
                     "!RC4", %10, "S", lightsLo.NIB2,
                     "!RC4", %01, "S", lightsLo.NIB1,
                     "!RC4", %00, "S", lightsLo.NIB0]

  DO WHILE (timer > 0)
    PAUSE 100
    timer = timer - 1
  LOOP

  GOTo Run_Show


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


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

Show:
'        +------------------------------------------------ channel 32
'        |                                       +-------- channel 1
'        |                                       |    +--- timing (x 0.1s)
'        |                                       |    |
'        v                                       v    v
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
  DATA  %00000000, %00000000, %00000000, %00000000, 000
Jon McPhalen
EFX-TEK Hollywood Office

tds234

I think this section
SEROUT Sio, Baud, ["!FC4", %11, "D", lightsHi.nib3,
                     "!FC4", %10, "D", lightsHi.Nib2,
                     "!FC4", %01, "D", lightsHi.nib1,
                     "!FC4", %01, "D", lightsHi.NIB0,
                     "!RC4", %11, "S", lightsLo.NIB3,
                     "!RC4", %10, "S", lightsLo.NIB2,
                     "!RC4", %01, "S", lightsLo.NIB1,
                     "!RC4", %01, "S", lightsLo.NIB0]

needs to read:

SEROUT Sio, Baud, ["!FC4", %11, "D", lightsHi.nib3,
                     "!FC4", %10, "D", lightsHi.Nib2,
                     "!FC4", %01, "D", lightsHi.nib1,
                     "!FC4", %00, "D", lightsHi.NIB0,
                     "!RC4", %11, "S", lightsLo.NIB3,
                     "!RC4", %10, "S", lightsLo.NIB2,
                     "!RC4", %01, "S", lightsLo.NIB1,
                     "!RC4", %00, "S", lightsLo.NIB0]


Freshly Doug

JonnyMac

November 24, 2008, 09:52:26 PM #3 Last Edit: November 24, 2008, 09:56:03 PM by JonnyMac
Yep, copy-and-past typo -- thanks for the catch.

Listing is fixed.
Jon McPhalen
EFX-TEK Hollywood Office

rawille

Thanks Jon!
Absolutely amazing. I've been struggling for a month to get something to work. I could get the lights flashing but could never figure out an acceptable timing routine.
Thanks again. I'll be trying it out this weekend and will let you know how it worked out.

JonnyMac

Have fun.  Remember that you can have as many lines in the DATA table as the memory will hold -- as soon as the timing column is zero the sequence will repeat itself.  I find that 0.1 second timing is plenty of resolution for blinking holiday lights and it's very easy to remember.  This means your timing column can hold a value from 0.1 second to 25.5 seconds; that should work pretty well for this kind of project.
Jon McPhalen
EFX-TEK Hollywood Office

rawille

Jon, I  had to make one small change to your program to get to work. I had to add the data pointer to the read statement:

READ pntr, lightsHi.BYTE1, lightsHi.BYTE0, lightsLo.BYTE1, lightsLo.BYTE0, timer

Just in case somebody else wants to use the program.
Otherwise it works great.
Thanks again.

JonnyMac

Whoops... that's what I get for writing programs either too early (before the Starbucks has kicked in) or too late (after my feeble brain has long given in).  You're absolutely right, I left out the address pointer from that call -- and have (for the second time) fixed the listing.
Jon McPhalen
EFX-TEK Hollywood Office