November 23, 2024, 10:27:21 AM

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.


Program help

Started by zeenon, October 01, 2013, 10:07:20 AM

Previous topic - Next topic

zeenon

Long story short, I ran out of Prop-1's for my haunt but have a Prop-2 available. A quick search nabbed a program I needed but since it's a Prop2 I'm a little out of my element.

Basically I'm going to split the outputs on 3 - 12v cylinder to blow quick puffs of air knee to ankle height along a 8' hallway, and also pop a 3' spider up/down a few times via another 12v cylinder.  Pressure mat on P14. I was hoping to reuse a program Johnny created but initially hear the valves click once a piece. For example:

Sequence        DATA    0, 1, 2, 1, 0, 2, 2, 1

I only hear 0, 1, 2 once, never  0, 1, 2, 1, 0, 2, 2, 1.

I was hoping to do this Sequence        DATA    3, 3, 3, 0, 1, 2, 1, 0, 2, 2, 1, 3, 3, 3
(0,1,2 are just air cylinder, 3 would be the bimba cylinder

I know the idx needs to be
  FOR idx = 0 TO 13                              ' loop through all
but I'm guessing this is the problem line:
    READ Sequence+idx, activePin                ' get pin

    ' =========================================================================
'
'   File......  Spider Scene
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

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


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

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

TrOn            CON     1
TrOff           CON     0

Yes             CON     1
No              CON     0

ON_TIME         CON     175
OFF_DELAY       CON     175


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

idx             VAR     Byte                    ' sequence index
activePin       VAR     Byte

timer           VAR     Word


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

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

  timer = 0                                     ' reset for new cycle


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

Main:
  DO WHILE (timer < 100)                        ' debounce = 100ms
    PAUSE 5
    IF (Trigger = TrOn) THEN
      timer = timer + 5
    ELSE
      timer = 0
    ENDIF
  LOOP

Fire_Cycle:
  FOR idx = 0 TO 7                              ' loop through all
    READ Sequence+idx, activePin                ' get pin
    HIGH activePin                              ' activate
    PAUSE ON_TIME                               ' hold on
    LOW activePin                               ' de-activate
    PAUSE OFF_DELAY                             ' off delay
  NEXT

  IF (Trigger = TrOn) THEN                      ' trigger still active?
    GOTO Fire_Cycle                             ' run again
  ELSE
    GOTO Reset                                  ' wait for next trigger
  ENDIF


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


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


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

Sequence        DATA    0, 1, 2, 1, 0, 2, 2, 1

JonnyMac

I don't see anything wrong with your program. I'm in the middle of something and can't connect a Prop-2 at the moment, but I'll give it a try later.

You might want to add a DEBUG statement under the READ line to see what it's telling you.
Jon McPhalen
EFX-TEK Hollywood Office

Jeff Haas

Try this out.  I only made a couple of changes:

- Added the suggested DEBUG statement.
- Updated your idx and sequence sections as you mentioned.

This version pops up a debug window and shows the number of the valve being triggered.  I tried it out with a Prop-1 Trainer; by pressing the button I was able to see the sequence cycle through your data as I think you want.

' =========================================================================
'
'   File......  Spider Scene
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

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


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

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

TrOn            CON     1
TrOff           CON     0

Yes             CON     1
No              CON     0

ON_TIME         CON     175
OFF_DELAY       CON     175


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

idx             VAR     Byte                    ' sequence index
activePin       VAR     Byte

timer           VAR     Word


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

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

  timer = 0                                     ' reset for new cycle


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

Main:
  DO WHILE (timer < 100)                        ' debounce = 100ms
    PAUSE 5
    IF (Trigger = TrOn) THEN
      timer = timer + 5
    ELSE
      timer = 0
    ENDIF
  LOOP

Fire_Cycle:
  FOR idx = 0 TO 13                              ' loop through all
    READ Sequence+idx, activePin                ' get pin
    DEBUG DEC activePin
    HIGH activePin                              ' activate
    PAUSE ON_TIME                               ' hold on
    LOW activePin                               ' de-activate
    PAUSE OFF_DELAY                             ' off delay
  NEXT

  IF (Trigger = TrOn) THEN                      ' trigger still active?
    GOTO Fire_Cycle                             ' run again
  ELSE
    GOTO Reset                                  ' wait for next trigger
  ENDIF


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


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


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

'Sequence        DATA    0, 1, 2, 1, 0, 2, 2, 1
Sequence        DATA    3, 3, 3, 0, 1, 2, 1, 0, 2, 2, 1, 3, 3, 3

JonnyMac

I also tried the program with a DEBUG statement and get the correct output.
Jon McPhalen
EFX-TEK Hollywood Office