November 22, 2024, 12:34:15 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.


Teleport 2000

Started by Jeff Haas, November 03, 2008, 11:48:09 PM

Previous topic - Next topic

Jeff Haas

Jon,

We started on this awhile back in the Prop-1 forum, but then I realized that it wasn't going to be needed for Halloween, and you'd have your hands full, so I put it on the back burner. 

I now have the Prop-2 and have spent some time going through the tutorials.  I'll copy the main info from the other forum into this post and the one below, and we can take it from there.

Here's my description of what I'd like to happen:

=========

Teleport 2000 v.2
Requirements, buttons, modes

1. Power switch - SPST switch
2. "Activate" switch - momentary contact switch
3. Mode switch - SPST switch.
4. Pot - Dual-gang 5k, one controls the EFX board, the other controls the sound board
5. LEDs along the top of the prop, pointed at the audience, arranged in this pattern:

1 2 3 4 5 6 7 8 9 0

The following "modes" are named for the performing effect, not what the software and/or hardware is actually doing.

-----------

Idle mode:

- Power switch is turned on.
- Activate switch is open.
- Mode switch is open.
- LEDs randomly blink at a slow rate.  Think of the lights under
the original Star Trek viewscreen.


-----------

Tuning mode:

- Activate switch is closed.
- Pot is adjusted.  (This will vary the sound effect from the sound board.)
- Mode switch remains open.
- LEDs scan (Knight Rider effect) at a slow rate.

In performance, after this mode, Activate switch is released and Pot is adjusted back to starting position.
LEDs go back to Idle blinking pattern.

-----------

Teleport mode:

- Pot has been adjusted back to starting position.
- Mode switch is closed.  (This changes the sound effect produced by the sound board.  Probably will have two mode switches, one for the EFX board and one for the sound board.)
- Activate switch is closed.
- LEDs scan at a slow rate.

Then...

- Pot is adjusted.  LEDs do the Knight Rider effect  As Pot is adjusted, LEDs start scanning faster.   After Pot has been turned to over a specific value (TBD), LEDs change pattern from left/right "Knight Rider" pattern and go from ends to the center.  i.e.:

1 2 3 4 5 6 7 8 9 0

LEDs 1 and 0 light up, then 2 and 9 light up, then 3 and 8 light up, then 4 and 7
light up, finally 5 and 6 light up.  Then pattern is repeated.

=====
I'll paste your first pass at the code into the next post to keep things easier to follow.

Jeff

Jeff Haas

Here's your first pass at the code.

' =========================================================================
'
'   File...... Teleport_2000.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... 18 SEP 2008
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

PotIn           PIN     15                      ' SETUP = out, no ULN
Activate        PIN     14                      ' SETUP = DN
Mode            PIN     13                      ' SETUP = DN


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

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


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

lottery         VAR     Word                    ' random value
potVal          VAR     Word                    ' current pot value
ledTimer        VAR     Word                    ' for LED pattern timing
ledSpeed        VAR     Word

idx             VAR     Byte                    ' loop controller
state           VAR     Byte                    ' program state, 0 - 2
actTimer        VAR     Byte                    ' debounce timer
pntr            VAR     Byte                    ' table pointer


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

Reset:
  OUTS = $0000                                  ' clear outputs
  DIRS = $03FF                                  ' make P0-P9 outputs


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

Main:
  FOR idx = 1 TO 3                              ' stir random #
    RANDOM lottery
  NEXT
  PAUSE 8                                       ' tune for ~10ms loop
  ledTimer = ledTimer + 10                      ' update LED timer

Read_Pot:
  HIGH PotIn                                    ' charge cap
  PAUSE 1
  RCTIME PotIn, 1, potVal                       ' read RC

Back_To_Zero:
  IF Activate = IsOff THEN                      ' check for release
    state = 0
    actTimer = 0
    GOTO Main
  ENDIF

  BRANCH state, [Idle, Tuning, Teleport]
  state = 0


Idle:
  actTimer = actTimer + 10 * Activate           ' debounce Activate
  IF actTimer >= 100 THEN                       ' valid press
    state = 1 + Mode                            ' set new state
    actTimer = 0                                ' clear activate timer
    pntr = 0                                    ' reset data pointer
    GOTO Main                                   ' handle new state now
  ENDIF
  IF ledTimer >= 1500 THEN                      ' 1.5 secs per change
    OUTS = lottery & $03FF                      ' randomize outputs
    ledTimer = 0                                ' restart the timer
  ENDIF
  GOTO Main


Tuning:
  IF ledTimer >= 250 THEN                       ' 0.25 secs per change
    READ Scanner + (pntr * 2), OUTS             ' new pattern
    pntr = pntr + 1 // 18                       ' update pointer, 0-17
    ledTimer = 0                                ' restart the timer
  ENDIF
  GOTO Main


Teleport:
  IF potVal < 300 THEN
    idx = potVal / 60
    LOOKUP idx, [250, 200, 150, 100, 50, 25], ledSpeed
    IF ledTimer >= ledSpeed THEN
      READ Scanner + (pntr * 2), OUTS
      pntr = pntr + 1 // 18
      ledTimer = 0
    ENDIF
  ELSE
    IF ledTimer >= 150 THEN                     ' 0.15 secs per change
      READ Center + (pntr * 2), OUTS            ' new pattern
      pntr = pntr + 1 // 5                      ' update pointer, 0-17
      ledTimer = 0                              ' restart the timer
    ENDIF
  ENDIF
  GOTO Main


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


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


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

Scanner         DATA    Word %0000000001        ' pntr = 0
                DATA    Word %0000000010        ' pntr = 1
                DATA    Word %0000000100
                DATA    Word %0000001000
                DATA    Word %0000010000
                DATA    Word %0000100000
                DATA    Word %0001000000
                DATA    Word %0010000000
                DATA    Word %0100000000
                DATA    Word %1000000010
                DATA    Word %0100000000
                DATA    Word %0010000000
                DATA    Word %0001000000
                DATA    Word %0000100000
                DATA    Word %0000010000
                DATA    Word %0000001000
                DATA    Word %0000000100
                DATA    Word %0000000010        ' pntr = 17


Center          DATA    Word %1000000001        ' pntr = 0
                DATA    Word %0100000010
                DATA    Word %0010000100
                DATA    Word %0001001000
                DATA    Word %0000110000        ' pntr = 4

Jeff Haas

I'd also like your advice on how to hook up the Prop-2 to all the other components.

From what I see in your code, the LEDs are on P0 through P9, with the Pot and the two switches on P13, 14, and 15.  The docs and forum seem to indicate I can connect the LEDs directly to the output terminals.  Do they need a resistor as well?


JonnyMac

November 04, 2008, 10:01:20 AM #3 Last Edit: November 04, 2008, 10:13:24 AM by JonnyMac
So what you're saying is that you haven't actually hooked up anything and tried?   :o

If yellow LEDs will work then you might give our WickLEDs a try; they are ready to connect between the V+ and OUTx terminals and have a capacitor which causes them to come on a little more slowly than a pure digital output and go off quite a bit more slowly -- I think this will mimic the lights a little better than straight LEDs.

If yellow doesn't work then you should build a similar circuit (resistor, capacitor, three LEDs) with red or an appropriate colors.  You code can allow too many active channels to be running the LEDs from the TTL headers.  Do not use the TTL headers for your LEDs; doing so will damage the Prop-2's processor and this is an expensive fix.

You can connect normally-open switches to the P13 and P14 headers.  An easy way to do this is to buy one of our extender cables and cut it in half.  This gives you two wires with a female connector and a loose end to connect the switch.  The code is setup for active-high inputs so you'll solder your normally-open switch between the white and red wires (strip off the black).

The pot will take a little more work; you'll need to solder a capacitor (0.1uF suggested) across the wiper and one end, then connect the legs with the cap attached between the white and black wires (again, cut one of our extender cables in half, on this one you'll strip off the red).  Once you get your potentiometer circuit setup you'll need to run some test code to see what its range is; this will depend on the size of your pot and the size of your cap.  Once the min and max values are determined the code can be updated to allow the pot to behave as you desire.
Jon McPhalen
EFX-TEK Hollywood Office

Jeff Haas

OK, I've got the LEDs on a protoboard and have tried out the program.  A few things I noticed:

1. Idle state doesn't seem to work.  You should be able to turn on the power, and even with no switches connected, only the pot, the LEDs should randomly blink.  They don't.

2. There was a typo in the "scanning" mode.  In the center of the pattern you had an extra 1 which made the lights scan one way, blink a single light at the end and then start over.

3. For some reason, I am only getting eight of the ten LEDs to light as part of the scanning mode.  The ones on OUT8 and OUT9 don't light as part of the pattern.

Also, when you define the inputs on this line:
PotIn           PIN     15                      ' SETUP = out, no ULN

Is this just a way of saying to remove the ULN chip?  Where should the jumper for pin 15 be?

Thanks!

Jeff

JonnyMac

November 06, 2008, 11:02:57 AM #5 Last Edit: November 06, 2008, 11:04:42 AM by JonnyMac
1. When we started this you didn't have hardware so I just knocked-out a "here's what it would probably look like" example without full testing.  My time is limited and I can't devote too much of it to examples that may not be used by anyone.  I found an errant GOTO in the code and the idle mode now works.

2. Whoops; typo fixed.

3. There was a missing Word modifier in the READ function; this was causing only the lower eight bits of the output pattern to be put onto the LEDs.  This was fixed in the Teleport section as well.

(RE: PotPin definition). No; this means that the influence of the ULN must be removed from P15 (only).  This can be accomplished by replacing the ULN2803 with a ULN2003 or by clipping pin 1 of the ULN2803.  We have thread devoted to this topic:

http://www.efx-tek.com/php/smf/index.php?topic=130.0

The comment adjacent to the PotIn definition explicitly sates: SETUP = out; this means you'll remove the jumper.


Here's an updated version of the program that seems to work.  I'm using a Prop-Pot which has a 10K pot instead of 5K -- this means you'll have to make some adjustments in the program.  I used a conditional compilation block  to see what the full-scale value of your pot input is and then adjust the values from there.  For the Prop-Pot (Prop-2 side) the max reading I get is 650, hence the use of 325 for a pot center value for teleport switch point.  You will, of course, have to test with your circuit and then fine-tune timing elements to your taste.

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


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


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


' -----[ Conditional Compilation ]-----------------------------------------

#DEFINE PotTest = 0                             ' change to 0 to disable


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

PotIn           PIN     15                      ' SETUP = out, no ULN
Activate        PIN     14                      ' SETUP = DN
Mode            PIN     13                      ' SETUP = DN


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

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


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

lottery         VAR     Word                    ' random value
potVal          VAR     Word                    ' current pot value
ledTimer        VAR     Word                    ' for LED pattern timing
ledSpeed        VAR     Word

idx             VAR     Byte                    ' loop controller
state           VAR     Byte                    ' program state, 0 - 2
actTimer        VAR     Byte                    ' debounce timer
pntr            VAR     Byte                    ' table pointer


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

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


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

Main:
  FOR idx = 1 TO 3                              ' stir random #
    RANDOM lottery
  NEXT
  PAUSE 8                                       ' tune for ~10ms loop
  ledTimer = ledTimer + 10                      ' update LED timer

Scan_Pot:
  HIGH PotIn                                    ' charge cap
  PAUSE 1
  RCTIME PotIn, 1, potVal                       ' read RC (10K / 0.1uF)

  #IF (PotTest = 1) #THEN
    DEBUG HOME, "Pot: ", DEC potVal, CLREOL
    PAUSE 100
    GOTO Scan_Pot
  #ENDIF

Back_To_Zero:
  IF Activate = IsOff THEN                      ' check for release
    state = 0
    actTimer = 0
  ENDIF

  BRANCH state, [Idle, Tuning, Teleport]
  state = 0


Idle:
  actTimer = (actTimer + 10) * Activate         ' debounce Activate
  IF (actTimer >= 100) THEN                     ' valid press
    state = 1 + Mode                            ' set new state
    actTimer = 0                                ' clear activate timer
    pntr = 0                                    ' reset data pointer
    GOTO Main                                   ' handle new state now
  ENDIF
  IF (ledTimer >= 350) THEN                     ' 0.35 secs per change
    OUTS = lottery & $03FF                      ' randomize outputs
    ledTimer = 0                                ' restart the timer
  ENDIF
  GOTO Main


Tuning:
  IF (ledTimer >= 150) THEN                     ' 0.1 secs per change
    READ Scanner + (pntr * 2), Word OUTS        ' new pattern
    pntr = pntr + 1 // 18                       ' update pointer, 0-17
    ledTimer = 0                                ' restart the timer
  ENDIF
  GOTO Main


Teleport:
  IF (potVal < 325) THEN
    idx = potVal / 60
    LOOKUP idx, [150, 95, 60, 38, 24, 15], ledSpeed
    IF (ledTimer >= ledSpeed) THEN
      pntr = (pntr + 1) // 18
      READ Scanner + (pntr * 2), Word OUTS
      ledTimer = 0
    ENDIF
  ELSE
    IF (ledTimer >= 75) THEN
      pntr = (pntr + 1) // 5
      READ Center + (pntr * 2), Word OUTS
      ledTimer = 0
    ENDIF
  ENDIF
  GOTO main


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


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


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

Scanner         DATA    Word %0000000001        ' pntr = 0
                DATA    Word %0000000010        ' pntr = 1
                DATA    Word %0000000100
                DATA    Word %0000001000
                DATA    Word %0000010000
                DATA    Word %0000100000
                DATA    Word %0001000000
                DATA    Word %0010000000
                DATA    Word %0100000000
                DATA    Word %1000000000
                DATA    Word %0100000000
                DATA    Word %0010000000
                DATA    Word %0001000000
                DATA    Word %0000100000
                DATA    Word %0000010000
                DATA    Word %0000001000
                DATA    Word %0000000100
                DATA    Word %0000000010        ' pntr = 17


Center          DATA    Word %1000000001        ' pntr = 0
                DATA    Word %0100000010
                DATA    Word %0010000100
                DATA    Word %0001001000
                DATA    Word %0000110000        ' pntr = 4
Jon McPhalen
EFX-TEK Hollywood Office

Jeff Haas

Thank you!  Originally, I was just asking which board to buy, and you knocked out some code in addition - which is going above and beyond.

I'll play with the timing tonight and get back to you with any other questions.

Jeff