November 23, 2024, 09:07:00 AM

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.


12 arch strands

Started by jeffh, October 30, 2009, 11:40:51 PM

Previous topic - Next topic

jeffh

i used this program to get 2 rc-4 boards connected serially to a prop2 board.
i was using 2 rc-4 boards and channel 9-14 off the prop2
the jumpers: as told to do
RC4-1st board  address %00 (no jumper)

RC4-2nd board )
put in both jumpers. Address = %11
******************************
i need it modified to get 3 or 4 rc-4 boards to work
do i set the jumpers on the rc-4 boards like the book says.

               ' =========================================================================
'
'   File...... jeffh prop2_Sound.BS2
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Triggered, table-drive sequencer capable of driving six control outputs.
' P6 is used as the trigger input.
'
' Note: Replace ULN2803 with ULN2003 to allow serial comms with AP-8
' (on P7).


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


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

Sio                     CON 15                    ' SETUP = out; no ULN
Trigger                 VAR IN14                  ' SETUP = DN


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

T2400                   CON 396
IsOn                    CON 1                     ' for active-high input
IsOff                   CON 0
Open                    CON $8000
Baud                    CON Open + T2400          ' baud jumper out
TicTiming               CON 95                    ' 0.1 sec per step (-5 for serouts)
PreDelay                CON 2000                  ' Show delay after triggered


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

showBits                VAR Word
showBitsHi              VAR showBits.HIGHBYTE
showBitsLo              VAR showBits.LOWBYTE
endOfShow               VAR showBits.BIT15
playAudio               VAR showBits.BIT14

pntr                    VAR Word
tix                     VAR Byte


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

Reset:
  OUTS = %0000000000000000                      ' clear pins
  DIRS = %0001111111111111                      ' P0..P12 are outputs

  SEROUT Sio, Baud, ["!!!!!!!AP8", %00, "X"]    ' kill sound if reset
  pntr = 0                                      ' point to start of show


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

Main:
  IF Trigger = IsOff THEN Main                  ' wait for trigger

  PAUSE PreDelay                                ' wait for a period of time

Play_Show:
  READ pntr+0, showBits.HIGHBYTE                ' get step (high part)
  READ pntr+1, showBits.LOWBYTE                 ' get step (low part)
  READ pntr+2, tix                              ' get step (time part)

Check_Sound:
  IF playAudio = IsOff THEN Engine
    SEROUT Sio, Baud, ["!AP8", %00, "P", 0]     ' start the sound

Engine:
  OUTS = showBits & %0001111111111111           ' update outputs
  SEROUT Sio, Baud, ["!RC4", %00, "S", OUTA]
  SEROUT Sio, Baud, ["!RC4", %11, "S", OUTB]
  GOSUB Timer                                   '   run the timer
  pntr = pntr + 3                               '   point to next step

  IF endofShow = IsOn THEN Reset                ' done?
    GOTO Play_Show


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

Timer:
  IF tix = 0 THEN Timer_Done                    ' timer expired?
    PAUSE TicTiming                             ' no, time on "tic"
    tix = tix - 1                               ' decrement timer
    GOTO Timer                                  ' check again

Timer_Done:
  RETURN

' -----[ EEPROM Data ]-----------------------------------------------------

Show_Data:
'          +---------------------- end of show bit
'          |+--------------------- start audio player
'          ||+-------------------- unused
'          |||+------------------- valve 12
'          ||||+------------------ valve 11
'          |||||+----------------- valve 10
'          ||||||+---------------- valve 9
'          |||||||+--------------- valve 8
'          ||||||||  |+----------- valve 7
'          ||||||||  ||+---------- valve 6
'          ||||||||  |||+--------- valve 5
'          ||||||||  ||||+-------- valve 4
'          ||||||||  |||||+------- valve 3
'          ||||||||  ||||||+------ valve 2
'          ||||||||  |||||||+----- valve 1
'          ||||||||  ||||||||
'          ||||||||  ||||||||  +-- timing multiplier (1 to 255

  DATA %01000000,%00000011, 4
  DATA %00000000,%00000111, 4
  DATA %00000000,%00001111, 4
  DATA %00000000,%00011111, 4
  DATA %00000000,%00111111, 4
  DATA %00000000,%01111111, 4
  DATA %00000000,%11111111, 4
  DATA %00000001,%11111111, 4
  DATA %00000011,%11111111, 4
  DATA %00000111,%11111111, 4
  DATA %00001111,%11111111, 4
  DATA %00011111,%11111111, 4
  DATA %00111111,%11111111, 4
  DATA %00011111,%11111111, 8
  DATA %00001111,%11111111, 8
  DATA %00000111,%11111111, 8
  DATA %00000011,%11111111, 8
  DATA %00000001,%11111111, 8
  DATA %00000000,%11111111, 8
  DATA %00000000,%01111111, 8
  DATA %00000000,%00111111, 8
  DATA %00000000,%00011111, 8
  DATA %00000000,%00001111, 8
  DATA %00000000,%00001111, 8
  DATA %00000000,%00000111, 8
  DATA %00000000,%00000011, 8
  DATA %00000000,%00000001, 8
  DATA %00000000,%00000000, 8
  DATA %10000000,%00000000, 0      'end of show


JonnyMac

Do you want to convert the program so that it just runs the RC-4s, or do you still want the mix of local outputs on the Prop-2 and on the RC-4s?
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

just run the rc4's

i have only 3 rc-4 connected but would like to be able to run 4 rc-4 's when needed.

thank you

JonnyMac

Here you go, Jeff.   This program has been fully upgraded to PBASIC 2.5 to make the coding a little nicer.  You should also install the B/R jumpers in the RC-4s and AP-8 to take advantage of the Prop-2's faster serial communications.

Note that I put the RC-4 updates into a subroutine so it can be called from anywhere.  You could, for example, randomize the outputs in the debounce loop so that the lights are "dancing" until you get a trigger. 


' =========================================================================
'
'   File...... JEFFH_Prop2_Sound.BS2
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 03 NOV 2009
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN
Trigger         PIN     14                      ' SETUP = DN


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

T2400           CON     396                     ' B/R jumper out
T38K4           CON     6                       ' B/R jumper in
Open            CON     $8000
Baud            CON     Open | T38K4

IsOn            CON     1                       ' for active-high input
IsOff           CON     0

TicTiming       CON     98                      ' 0.1 sec per step
PreDelay        CON     2000                    ' Show delay after triggered


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

timer           VAR     Byte                    ' for trigger debouncing

pntr            VAR     Word                    ' show record pointer

control         VAR     Byte                    ' control bits
endOfShow      VAR     control.BIT1
playAudio      VAR     control.BIT0

showBits        VAR     Word                    ' RC-4 control bits
tix             VAR     Byte                    ' "tick" timing for steps


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

Reset:
  OUTS = $0000                                  ' clear pins
  DIRS = $0000                                  ' no local outputs

  SEROUT Sio, Baud, ["!AP8", %00, "X"]          ' kill sound if reset
  pntr = 0                                      ' point to start of show


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

Main:
  timer = 0
  DO WHILE (timer < 100)                        ' debounce for 100ms
    PAUSE 5
    timer = (timer + 5) * Trigger
  LOOP
  PAUSE PreDelay                                ' wait for a period of time

Play_Show:
  READ pntr, control, Word showBits, tix        ' read a record
  pntr = pntr + 4                               ' update recrod pointer

Check_Sound:
  IF (playAudio = IsOn) THEN
    SEROUT Sio, Baud, ["!AP8", %00, "P", 0]     ' start the sound
  ENDIF

  GOSUB Set_Outputs                             ' update RC-4s

Run_Timer:
  DO WHILE (tix > 0)
    PAUSE TicTiming                             ' no, time on "tic"
    tix = tix - 1                               ' decrement timer
  LOOP

  IF (endofShow = IsOn) THEN Reset              ' done?
    GOTO Play_Show


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

Set_Outputs:
  SEROUT Sio, Baud, ["!RC4", %00, "S", showBits.NIB0,
                     "!RC4", %01, "S", showBits.NIB1,
                     "!RC4", %10, "S", showBits.NIB2,
                     "!RC4", %11, "S", showBits.NIB3 ]
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

Show_Data:
'
'        +------------------------------ end of show bit
'        |+----------------------------- start audio player
'        ||           +----------------- Output 13 (RC-4, %11, K1)
'        ||           |   +------------- Output  9 (RC-4, %10, K1)
'        ||           |   |   +--------- Output  5 (RC-4, %01, K1)
'        ||           |   |   |   +----- Output  1 (RC-4, %00, K1)
'        ||           |   |   |   |  +-- timing multiplier (1 to 255
'        ||           |   |   |   |  |
  DATA  %01, Word %0000000000000001, 4
  DATA  %00, Word %0000000000000010, 4
  DATA  %00, Word %0000000000000100, 4
  DATA  %00, Word %0000000000001000, 4
  DATA  %00, Word %0000000000010000, 4
  DATA  %00, Word %0000000000100000, 4
  DATA  %00, Word %0000000001000000, 4
  DATA  %00, Word %0000000010000000, 4
  DATA  %00, Word %0000000100000000, 4
  DATA  %00, Word %0000001000000000, 4
  DATA  %00, Word %0000010000000000, 4
  DATA  %00, Word %0000100000000000, 4
  DATA  %00, Word %0001000000000000, 4
  DATA  %00, Word %0010000000000000, 4
  DATA  %00, Word %0100000000000000, 4
  DATA  %00, Word %1000000000000000, 4
  DATA  %00, Word %0100000000000000, 4
  DATA  %00, Word %0010000000000000, 4
  DATA  %00, Word %0001000000000000, 4
  DATA  %00, Word %0000100000000000, 4
  DATA  %00, Word %0000010000000000, 4
  DATA  %00, Word %0000001000000000, 4
  DATA  %00, Word %0000000100000000, 4
  DATA  %00, Word %0000000010000000, 4
  DATA  %00, Word %0000000001000000, 4
  DATA  %00, Word %0000000000100000, 4
  DATA  %00, Word %0000000000010000, 4
  DATA  %00, Word %0000000000001000, 4
  DATA  %00, Word %0000000000000100, 4
  DATA  %00, Word %0000000000000010, 4
  DATA  %10, Word %0000000000000000, 0
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

Thank you,
This  program runs continuous. Works perfect.

Prop2 with 4 RC-4 board connected
****
I also need this program to be triggered via pin 14
I will add the lines for the amount of time i need.
P 15 is pulled up, via setup jumpers
P 14 is pulled down, via setup jumpers
The second 2803chip has been replaced with a 2003 chip
P15 is going to the AP-8 card.
Is my end of show bit set correct?


' =========================================================================
'
'   File...... JEFFH_Prop2_Sound.BS2
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 03 NOV 2009
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN
Trigger         PIN     14                      ' SETUP = DN


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

T2400           CON     396                     ' B/R jumper out
T38K4           CON     6                       ' B/R jumper in
Open            CON     $8000
Baud            CON     Open | T38K4

IsOn            CON     1                       ' for active-high input
IsOff           CON     0

TicTiming       CON     99                      ' 0.1 sec per step
PreDelay        CON     2000                    ' Show delay after triggered


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

timer           VAR     Byte                    ' for trigger debouncing

pntr            VAR     Word                    ' show record pointer

control         VAR     Byte                    ' control bits
endOfShow      VAR     control.BIT1
playAudio      VAR     control.BIT0

showBits        VAR     Word                    ' RC-4 control bits
tix             VAR     Byte                    ' "tick" timing for steps


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

Reset:
  OUTS = $0000                                  ' clear pins
  DIRS = $0000                                  ' no local outputs

  SEROUT Sio, Baud, ["!AP8", %00, "X"]          ' kill sound if reset
  pntr = 0                                      ' point to start of show


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

Main:
  timer = 0
  DO WHILE (timer < 100)                        ' debounce for 100ms
    PAUSE 5
    timer = (timer + 5) * Trigger
  LOOP
  PAUSE PreDelay                                ' wait for a period of time

Play_Show:
  READ pntr, control, Word showBits, tix        ' read a record
  pntr = pntr + 4                               ' update record pointer

Check_Sound:
  IF (playAudio = IsOn) THEN
    SEROUT Sio, Baud, ["!AP8", %00, "P", 0]     ' start the sound
  ENDIF

  GOSUB Set_Outputs                             ' update RC-4s

Run_Timer:
  DO WHILE (tix > 0)
    PAUSE TicTiming                             ' no, time on "tic"
    tix = tix - 1                               ' decrement timer
  LOOP

  IF (endofShow = IsOn) THEN Reset              ' done?
    GOTO Play_Show


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

Set_Outputs:
  SEROUT Sio, Baud, ["!RC4", %00, "S", showBits.NIB0,
                     "!RC4", %01, "S", showBits.NIB1,
                     "!RC4", %10, "S", showBits.NIB2,
                     "!RC4", %11, "S", showBits.NIB3 ]
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

Show_Data:
'
'        +------------------------------ end of show bit
'        |+----------------------------- start audio player
'        ||           +----------------- Output 13 (RC-4, %11, K1)
'        ||           |   +------------- Output  9 (RC-4, %10, K1)
'        ||           |   |   +--------- Output  5 (RC-4, %01, K1)
'        ||           |   |   |   +----- Output  1 (RC-4, %00, K1)
'        ||           |   |   |   |  +-- timing multiplier (1 to 255
'        ||           |   |   |   |  |
  DATA  %01, Word %0000000000000001, 6
  DATA  %00, Word %0000000100000000, 6
  DATA  %00, Word %0000000000001000, 6
  DATA  %00, Word %0000000000010000, 6
  DATA  %00, Word %0000000000100000, 6
  DATA  %10, Word %0000000000000000, 0      ' END OF SHOW

**************************************************************************
***********
Posts: 2976
***********


View Profile WWW Email Personal Message (Offline)


Re: 12 arch strands
« Reply #3 on: Today at 09:32:16 AM »
  Reply with quoteQuote
Here you go, Jeff.   This program has been fully upgraded to PBASIC 2.5 to make the coding a little nicer.  You should also install the B/R jumpers in the RC-4s and AP-8 to take advantage of the Prop-2's faster serial communications.

Note that I put the RC-4 updates into a subroutine so it can be called from anywhere.  You could, for example, randomize the outputs in the debounce loop so that the lights are "dancing" until you get a trigger.


   

JonnyMac

Which outputs?  All of them?  You could do something like this:

' =========================================================================
'
'   File...... JEFFH_Prop2_Sound.BS2
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 14 DEC 2009
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN
Trigger         PIN     14                      ' SETUP = DN


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

T2400           CON     396                     ' B/R jumper out
T38K4           CON     6                       ' B/R jumper in
Open            CON     $8000
Baud            CON     Open | T38K4

IsOn            CON     1                       ' for active-high input
IsOff           CON     0

TicTiming       CON     99                      ' 0.1 sec per step
PreDelay        CON     2000                    ' Show delay after triggered


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

idx             VAR     Byte                    ' loop controller
timer           VAR     Byte                    ' for trigger debouncing
pntr            VAR     Word                    ' show record pointer

control         VAR     Byte                    ' control bits
endOfShow      VAR     control.BIT1
playAudio      VAR     control.BIT0

showBits        VAR     Word                    ' RC-4 control bits
tix             VAR     Byte                    ' "tick" timing for steps


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

Reset:
 OUTS = $0000                                  ' clear pins
 DIRS = $0000                                  ' no local outputs

 SEROUT Sio, Baud, ["!AP8", %00, "X"]          ' kill sound if reset


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

Main:
 timer = 0
 FOR idx = 1 TO 20
   RANDOM showBits
   PAUSE 5
   timer = (timer + 5) * Trigger
 NEXT
 GOSUB Set_Outputs                             ' update RC-4s
 IF (timer < 100) THEN Main

 PAUSE PreDelay                                ' wait for a period of time
 pntr = 0                                      ' point to start of show

Play_Show:
 READ pntr, control, Word showBits, tix        ' read a record
 pntr = pntr + 4                               ' update record pointer

Check_Sound:
 IF (playAudio = IsOn) THEN
   SEROUT Sio, Baud, ["!AP8", %00, "P", 0]     ' start the sound
 ENDIF

 GOSUB Set_Outputs                             ' update RC-4s

Run_Timer:
 DO WHILE (tix > 0)
   PAUSE TicTiming                             ' no, time on "tic"
   tix = tix - 1                               ' decrement timer
 LOOP

 IF (endofShow = IsOn) THEN Reset              ' done?
   GOTO Play_Show


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

Set_Outputs:
 SEROUT Sio, Baud, ["!RC4", %00, "S", showBits.NIB0,
                    "!RC4", %01, "S", showBits.NIB1,
                    "!RC4", %10, "S", showBits.NIB2,
                    "!RC4", %11, "S", showBits.NIB3 ]
 RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

Show_Data:
'
'        +------------------------------ end of show bit
'        |+----------------------------- start audio player
'        ||           +----------------- Output 13 (RC-4, %11, K1)
'        ||           |   +------------- Output  9 (RC-4, %10, K1)
'        ||           |   |   +--------- Output  5 (RC-4, %01, K1)
'        ||           |   |   |   +----- Output  1 (RC-4, %00, K1)
'        ||           |   |   |   |  +-- timing multiplier (1 to 255
'        ||           |   |   |   |  |
 DATA  %01, Word %0000000000000001, 6
 DATA  %00, Word %0000000100000000, 6
 DATA  %00, Word %0000000000001000, 6
 DATA  %00, Word %0000000000010000, 6
 DATA  %00, Word %0000000000100000, 6
 DATA  %10, Word %0000000000000000, 0          ' END OF SHOW
Jon McPhalen
EFX-TEK Hollywood Office

BigRez

December 15, 2009, 12:55:56 PM #6 Last Edit: December 15, 2009, 12:57:37 PM by bigrez
Oh no!!!!  You may have just done it - you switched topics and may have released the monster!   ;D

You may be able to fix this by removing your post and reposting as a new thread.

BigRez

yep...  Article IV, Part III, Section IV, paragraph 2b of the forum guidelines states: One topic per subject.   Well, not really sure where it states that but it does.  It helps keeps the boards organized and allows for better search results.

TinkersALot

okay. will try to comply . sorry . ooops.