November 23, 2024, 05:28:02 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.


prop1 delay start, loop then delay

Started by jeffh, November 15, 2008, 11:13:34 PM

Previous topic - Next topic

jeffh



hello again, i need a modification to this code.

this code loops two times due to the number of instructions a prop1 can handle.

i need to delay the show for four seconds, then loop 3 times without the delay between  loops and have a delay after the show ends so the rear wheels do not set it off again as the tractor and trailer leave.

thanks for all you do

' =========================================================================
'
'   File...... Jack in the Box.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)   for JEFF HAILTON
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15NOV2008 modified for Jeff Hamilton
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ 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 ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  TicTiming       = 100                   ' 0.1 sec per step


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

SYMBOL  showBits        = B0
SYMBOL  playAudio       = BIT6
SYMBOL  endOfShow       = BIT7

SYMBOL  pntr            = B2                    ' step pointer
SYMBOL  tix             = B3

SYMBOL  shows           = B4


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00111111                              ' P0..P5 are outputs

  SEROUT Sio, OT2400, ("!!!!!!!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


Show_Loop:                                      'SHOW LOOP
  FOR shows = 1 TO 3
    pntr = 0


Play_Show:
  READ pntr, showBits                           ' get step

Check_Sound:
  IF playAudio = IsOff THEN Engine
    SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)   ' start the sound

Engine:
  PINS = showBits & %00111111                   '   update outputs
  pntr = pntr + 1                               '   point to timing
  READ pntr, tix                                '   read it
  GOSUB Timer                                   '   run the timer
  pntr = pntr + 1                               '   point to next step

  IF endofShow = IsOn THEN End_Of_Show          '   done?
    GOTO Play_Show

End_Of_Show:
  NEXT
  GOTO Reset


' -----[ 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
'          ||+---------- rocking horse air
'          |||+--------- rocking horse
'          ||||+-------- see saw air
'          |||||+------- see saw
'          ||||||+------ jack in the box air
'          |||||||+----- jack in the box
'          ||||||||
'          ||||||||  +-- timing (1 to 255)

  EEPROM (%00000000, 400)


  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00111001,
  EEPROM (%00010001,
  EEPROM (%00010100,
  EEPROM (%00000111,
  EEPROM (%00101001,
  EEPROM (%00101010,
  EEPROM (%00101101,
  EEPROM (%00000101,
  EEPROM (%00010000,
  EEPROM (%00010011,
  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00101001,
  EEPROM (%00000001,
  EEPROM (%00000100,
  EEPROM (%00000111,
  EEPROM (%00111010,
  EEPROM (%00111001,
  EEPROM (%00111101,
  EEPROM (%00110100,
  EEPROM (%00110101,
  EEPROM (%00110110,
  EEPROM (%00110001,
  EEPROM (%00011001,
  EEPROM (%00011100,
  EEPROM (%00001111,
  EEPROM (%00100001,
  EEPROM (%00100010,
  EEPROM (%00100101,
  EEPROM (%00001101,
  EEPROM (%00011000,
  EEPROM (%00011011,
  EEPROM (%00110101,
  EEPROM (%00110110,
  EEPROM (%00100001,
  EEPROM (%00001001,
  EEPROM (%00001100,
  EEPROM (%00001111,
  EEPROM (%00110010,
  EEPROM (%00110001,
  EEPROM (%00110101,
  EEPROM (%00111100,
  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00110001,
  EEPROM (%00010001,
  EEPROM (%00010100,
  EEPROM (%00000111,
  EEPROM (%00101001,
  EEPROM (%00101010,
  EEPROM (%00101101,
  EEPROM (%00000101,
  EEPROM (%00010000,
  EEPROM (%00010011,
  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00101001,
  EEPROM (%00000001,
  EEPROM (%00000100,
  EEPROM (%00000111,
  EEPROM (%00111010,
  EEPROM (%00111001,
  EEPROM (%00111101,
  EEPROM (%00111100,
  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00101001,
  EEPROM (%00000001,
  EEPROM (%00000100,
  EEPROM (%00000111,
  EEPROM (%00111010,
  EEPROM (%00111001,
  EEPROM (%00111101,
  EEPROM (%00111100,
  EEPROM (%00111101,
  EEPROM (%00111110,
  EEPROM (%00101001,
  EEPROM (%00000001,

  EEPROM (%10000000, 200)                       ' inter-show delay (ver4 120 was 150)

JonnyMac

Since you removed the timing column from the EE table I'm going to assume that each step can run for the same amount of time -- this is set by a constant called StepTime.  I think this does what you want.

' =========================================================================
'
'   File...... Jack in the Box.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)   for JEFF HAILTON
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 NOV 2008 modified for Jeff Hamilton
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ 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 ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  StepTime        = 100                   ' 0.1 sec per step


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

SYMBOL  showBits        = B0
SYMBOL   playAudio      =  BIT6
SYMBOL   endOfShow      =  BIT7

SYMBOL  flags           = B1
SYMBOL   played         =  BIT8

SYMBOL  timer           = B2
SYMBOL  cycles          = B3
SYMBOL  pntr            = B4                    ' step pointer


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00111111                              ' P0..P5 are outputs

  SEROUT Sio, OT2400, ("!!!!!AP8", %00, "X")    ' kill sound if reset
  PAUSE 10000                                   ' post-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  PAUSE 4000                                    ' pre-show delay
  cycles = 3                                    ' set sequence loops
  played = No                                   ' allow audio

Start_Show:
  pntr = 0

Play_Show:
  READ pntr, showBits                           ' get step

Check_Sound:
  IF playAudio = IsOff THEN Engine
    IF played = Yes THEN Engine
      SEROUT Sio, OT2400, ("!AP8", %00, "P", 0) ' start the sound
      played = Yes                              ' mark played

Engine:
  PINS = showBits & %00111111                   ' update outputs
  pntr = pntr + 1                               ' point to next step

  IF endofShow = IsOn THEN Check_Cycles         ' done?
    PAUSE StepTime                              ' no, delay for step
    GOTO Play_Show                              ' and do next

Check_Cycles:
  IF cycles = 0 THEN Reset                      ' all cycles finished?
    cycles = cycles - 1
    GOTO Start_Show                             ' no, re-start EE sequence


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


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

Show_Data:
'          +------------ end of show bit
'          |+----------- start audio player
'          ||+---------- rocking horse air
'          |||+--------- rocking horse
'          ||||+-------- see saw air
'          |||||+------- see saw
'          ||||||+------ jack in the box air
'          |||||||+----- jack in the box
'          ||||||||
'          ||||||||
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00111001)
  EEPROM (%00010001)
  EEPROM (%00010100)
  EEPROM (%00000111)
  EEPROM (%00101001)
  EEPROM (%00101010)
  EEPROM (%00101101)
  EEPROM (%00000101)
  EEPROM (%00010000)
  EEPROM (%00010011)
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00101001)
  EEPROM (%00000001)
  EEPROM (%00000100)
  EEPROM (%00000111)
  EEPROM (%00111010)
  EEPROM (%00111001)
  EEPROM (%00111101)
  EEPROM (%00110100)
  EEPROM (%00110101)
  EEPROM (%00110110)
  EEPROM (%00110001)
  EEPROM (%00011001)
  EEPROM (%00011100)
  EEPROM (%00001111)
  EEPROM (%00100001)
  EEPROM (%00100010)
  EEPROM (%00100101)
  EEPROM (%00001101)
  EEPROM (%00011000)
  EEPROM (%00011011)
  EEPROM (%00110101)
  EEPROM (%00110110)
  EEPROM (%00100001)
  EEPROM (%00001001)
  EEPROM (%00001100)
  EEPROM (%00001111)
  EEPROM (%00110010)
  EEPROM (%00110001)
  EEPROM (%00110101)
  EEPROM (%00111100)
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00110001)
  EEPROM (%00010001)
  EEPROM (%00010100)
  EEPROM (%00000111)
  EEPROM (%00101001)
  EEPROM (%00101010)
  EEPROM (%00101101)
  EEPROM (%00000101)
  EEPROM (%00010000)
  EEPROM (%00010011)
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00101001)
  EEPROM (%00000001)
  EEPROM (%00000100)
  EEPROM (%00000111)
  EEPROM (%00111010)
  EEPROM (%00111001)
  EEPROM (%00111101)
  EEPROM (%00111100)
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00101001)
  EEPROM (%00000001)
  EEPROM (%00000100)
  EEPROM (%00000111)
  EEPROM (%00111010)
  EEPROM (%00111001)
  EEPROM (%00111101)
  EEPROM (%00111100)
  EEPROM (%00111101)
  EEPROM (%00111110)
  EEPROM (%00101001)
  EEPROM (%00000001)
  EEPROM (%10000000)                            ' end of sequence data


Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Do all of the table elements run for the same amount of time (8 units) or are they different?  If they're the same then you can simply change the value of StepTime to suit, otherwise I will have to put them back in -- and hope it all fits into the memory.  Let me know
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

November 16, 2008, 01:50:11 AM #3 Last Edit: November 16, 2008, 01:57:16 AM by JonnyMac
Bad news... that sequence won't fit if you add step timing to each element; can the number of steps be shortened?

Here's the program with timing added back in; note that the table is shorter and the code below is MAXED out (0 bytes of program space are free).

Oh, you can defeat the smilies by adding a space before the ")" character.

' =========================================================================
'
'   File...... Jack in the Box.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)   for JEFF HAILTON
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 NOV 2008 modified for Jeff Hamilton
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ 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 ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  StepTic         = 100                   ' 0.1 sec per "tick"


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

SYMBOL  showBits        = B0
SYMBOL   playAudio      =  BIT6
SYMBOL   endOfShow      =  BIT7

SYMBOL  flags           = B1
SYMBOL   played         =  BIT8

SYMBOL  timer           = B2
SYMBOL  cycles          = B3
SYMBOL  pntr            = B4                    ' step pointer


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00111111                              ' P0..P5 are outputs

  SEROUT Sio, OT2400, ("!!!!!AP8", %00, "X")    ' kill sound if reset
  PAUSE 10000                                   ' post-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  PAUSE 4000                                    ' pre-show delay
  cycles = 3                                    ' set sequence loops
  played = No                                   ' allow audio

Start_Show:
  pntr = 0

Play_Show:
  READ pntr, showBits                           ' get step

Check_Sound:
  IF playAudio = IsOff THEN Engine
    IF played = Yes THEN Engine
      SEROUT Sio, OT2400, ("!AP8", %00, "P", 0) ' start the sound
      played = Yes                              ' mark played

Engine:
  PINS = showBits & %00111111                   ' update outputs
  pntr = pntr + 1                               ' point to next step
  READ pntr, timer                              ' read step timing
  pntr = pntr + 1                               ' point to next step

  IF endofShow = IsOn THEN Check_Cycles         ' done?

Step_Delay:
  IF timer = 0 THEN Play_Show
    PAUSE StepTic
    timer = timer - 1
    GOTO Step_Delay                             ' and do next

Check_Cycles:
  IF cycles = 0 THEN Reset                      ' all cycles finished?
    cycles = cycles - 1
    GOTO Start_Show                             ' no, re-start EE sequence


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


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

Show_Data:
'           +------------ end of show bit
'           |+----------- start audio player
'           ||+---------- rocking horse air
'           |||+--------- rocking horse
'           ||||+-------- see saw air
'           |||||+------- see saw
'           ||||||+------ jack in the box air
'           |||||||+----- jack in the box
'           ||||||||
'           ||||||||  +-- timing "ticks"
'           ||||||||  |
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00111001, 8 )
  EEPROM ( %00010001, 8 )
  EEPROM ( %00010100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00101010, 8 )
  EEPROM ( %00101101, 8 )
  EEPROM ( %00000101, 8 )
  EEPROM ( %00010000, 8 )
  EEPROM ( %00010011, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00000001, 8 )
  EEPROM ( %00000100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00111010, 8 )
  EEPROM ( %00111001, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00110100, 8 )
  EEPROM ( %00110101, 8 )
  EEPROM ( %00110110, 8 )
  EEPROM ( %00110001, 8 )
  EEPROM ( %00011001, 8 )
  EEPROM ( %00011100, 8 )
  EEPROM ( %00001111, 8 )
  EEPROM ( %00100001, 8 )
  EEPROM ( %00100010, 8 )
  EEPROM ( %00100101, 8 )
  EEPROM ( %00001101, 8 )
  EEPROM ( %00011000, 8 )
  EEPROM ( %00011011, 8 )
  EEPROM ( %00110101, 8 )
  EEPROM ( %00110110, 8 )
  EEPROM ( %00100001, 8 )
  EEPROM ( %00001001, 8 )
  EEPROM ( %00001100, 8 )
  EEPROM ( %00001111, 8 )
  EEPROM ( %00110010, 8 )
  EEPROM ( %00110001, 8 )
  EEPROM ( %00110101, 8 )
  EEPROM ( %00111100, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00110001, 8 )
  EEPROM ( %00010001, 8 )
  EEPROM ( %00010100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00101010, 8 )
  EEPROM ( %00101101, 8 )
  EEPROM ( %00000101, 8 )
  EEPROM ( %00010000, 8 )
  EEPROM ( %00010011, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00000001, 8 )
  EEPROM ( %00000100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00111010, 8 )
  EEPROM ( %00111001, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111100, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %10000000, 8 )                            ' end of sequence data
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

i want to be able to loop this value as many times as i need to to get 1 min 40 seconds after a delay of 4 to 10 seconds, which ever we choose
if there are too many lines for the prop 1 i can reduce the number of lines by adding another loop and the first delay does not keep showing up. ( this part is right)

EEPROM ( %10000000, 8 ) (8 tenths of a second i think will work for the slowest items) and i can "tick" twice if i want 16 tenths of a second.

do i make sense at all.

i just checked this code, it loads. the amount of time it runs is correct now.

i can change the pre show delay and it does not start unlesss i hit the trigger a second time
  PAUSE 20                                      ' pre-show delay


sorry to bother you too much on this.

in a nut shell i would like this to have a 4 to 10 second delay ( we can change) then run 1 min 40 seconds.
end product:  delay time plus 1 min and 40 seconds

  ' =========================================================================
'
'   File...... Jack in the Box.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)   for JEFF HAMILTON
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 NOV 2008 modified for Jeff Hamilton
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ 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 ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  StepTic         = 100                   ' 0.1 sec per "tick"


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

SYMBOL  showBits        = B0
SYMBOL   playAudio      =  BIT6
SYMBOL   endOfShow      =  BIT7

SYMBOL  flags           = B1
SYMBOL   played         =  BIT8

SYMBOL  timer           = B2
SYMBOL  cycles          = B3
SYMBOL  pntr            = B4                    ' step pointer


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00111111                              ' P0..P5 are outputs

  SEROUT Sio, OT2400, ("!!!!!AP8", %00, "X")    ' kill sound if reset
  PAUSE 10000                                   ' post-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  PAUSE 20                                      ' pre-show delay
  cycles = 2                                    ' set sequence loops
  played = No                                   ' allow audio

Start_Show:
  pntr = 0

Play_Show:
  READ pntr, showBits                           ' get step

Check_Sound:
  IF playAudio = IsOff THEN Engine
    IF played = Yes THEN Engine
      SEROUT Sio, OT2400, ("!AP8", %00, "P", 0) ' start the sound
      played = Yes                              ' mark played

Engine:
  PINS = showBits & %00111111                   ' update outputs
  pntr = pntr + 1                               ' point to next step
  READ pntr, timer                              ' read step timing
  pntr = pntr + 1                               ' point to next step

  IF endofShow = IsOn THEN Check_Cycles         ' done?

Step_Delay:
  IF timer = 0 THEN Play_Show
    PAUSE StepTic
    timer = timer - 1
    GOTO Step_Delay                             ' and do next

Check_Cycles:
  IF cycles = 0 THEN Reset                      ' all cycles finished?
    cycles = cycles - 1
    GOTO Start_Show                             ' no, re-start EE sequence


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


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

Show_Data:
'           +------------ end of show bit
'           |+----------- start audio player
'           ||+---------- rocking horse air
'           |||+--------- rocking horse
'           ||||+-------- see saw air
'           |||||+------- see saw
'           ||||||+------ jack in the box air
'           |||||||+----- jack in the box
'           ||||||||
'           ||||||||  +-- timing "ticks"
'           ||||||||  |
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00111001, 8 )
  EEPROM ( %00010001, 8 )
  EEPROM ( %00010100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00101010, 8 )
  EEPROM ( %00101101, 8 )
  EEPROM ( %00000101, 8 )
  EEPROM ( %00010000, 8 )
  EEPROM ( %00010011, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00000001, 8 )
  EEPROM ( %00000100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00111010, 8 )
  EEPROM ( %00111001, 8 )
  EEPROM ( %00111101, 8 )
  EEPROM ( %00110100, 8 )
  EEPROM ( %00110101, 8 )
  EEPROM ( %00110110, 8 )
  EEPROM ( %00110001, 8 )
  EEPROM ( %00011001, 8 )
  EEPROM ( %00011100, 8 )
  EEPROM ( %00001111, 8 )
  EEPROM ( %00100001, 8 )
  EEPROM ( %00100010, 8 )
  EEPROM ( %00100101, 8 )
  EEPROM ( %00001101, 8 )
  EEPROM ( %00011000, 8 )
  EEPROM ( %00011011, 8 )
  EEPROM ( %00110101, 8 )
  EEPROM ( %00110110, 8 )
  EEPROM ( %00100001, 8 )
  EEPROM ( %00001001, 8 )
  EEPROM ( %00001100, 8 )
  EEPROM ( %00001111, 8 )
  EEPROM ( %00110010, 8 )

  EEPROM ( %10000000, 8 )   'end of show



JonnyMac

I'm really confused, Jeff -- I'm not sure what you're asking. The value set in "cycles" controls how many times the table will loop (without delays in between -- don't but delays into the table).  The post delay is in the reset section and the pre-show delay is right after the trigger section. 

The program is now back to the point where you can change the timing for each line in the table -- I used 8 because you commented on it; you'll have to go through the table now and edit it.  You can now go line-by-line through the table and edit how long each line runs (1 to 255 ticks -- a tick is 0.1 second).

You don't need to press the trigger twice; you just need to provide a clean input of 1/10th second; I've added debouncing to the input to prevent false positives so the show doesn't start when it shouldn't.
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

you are not confused. it works like i want except the startup delay did not seem too.
but if i touched the trigger again like a rear tire would it started then.
i will doule check.

i can live without the delay if i have to.

thanks for your time.

JonnyMac

Try my original version above.  Press and hold the trigger for a little longer than you normally do.  Remember that there was a 4-second delay after the trigger and before the show (this only happens once per show cycle); maybe the show had started and you were in the delay when you pressed the button a second time. 
Jon McPhalen
EFX-TEK Hollywood Office


jeffh

we are close. i still need a delay before every show. between 7 to 12 seconds
this is on a hayride. once it is triggered we are making two loops of show due to limitation on the prop1.
looping 2 times i get seconds i need
the tractor may pass every 15 to 20 minutes


the code below works like this now
1. load code, recycle power
2. the first trigger has a long delay. i have not been able to find that length. i have tested up to five minutes
3. after 10 seconds of the first trigger i can trigger again and the show starts without delay.
4. then after each show if i wait 10 seconds i  can trigger the prop1 again and get a show without delay.
5. the loop two times is working great to get the length of the show.

we want to have a delay at the begnning of  every show. we are triggering with the front tires of a tractor and trailer.
i shortened the program for time testing purposes.

' =========================================================================
'
'   File...... Jack in the Box.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)   for JEFF HAMILTON
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 NOV 2008 modified for Jeff Hamilton
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ 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 ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  StepTic         = 100                   ' 0.1 sec per "tick"


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

SYMBOL  showBits        = B0
SYMBOL   playAudio      =  BIT6
SYMBOL   endOfShow      =  BIT7

SYMBOL  flags           = B1
SYMBOL   played         =  BIT8

SYMBOL  timer           = B2
SYMBOL  cycles          = B3
SYMBOL  pntr            = B4                    ' step pointer


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00111111                              ' P0..P5 are outputs

  SEROUT Sio, OT2400, ("!!!!!AP8", %00, "X")    ' kill sound if reset
  PAUSE 10000                                   ' post-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  PAUSE 20                                      ' pre-show delay
  cycles = 2                                    ' set sequence loops
  played = No                                   ' allow audio

Start_Show:
  pntr = 0

Play_Show:
  READ pntr, showBits                           ' get step

Check_Sound:
  IF playAudio = IsOff THEN Engine
    IF played = Yes THEN Engine
      SEROUT Sio, OT2400, ("!AP8", %00, "P", 0) ' start the sound
      played = Yes                              ' mark played

Engine:
  PINS = showBits & %00111111                   ' update outputs
  pntr = pntr + 1                               ' point to next step
  READ pntr, timer                              ' read step timing
  pntr = pntr + 1                               ' point to next step

  IF endofShow = IsOn THEN Check_Cycles         ' done?

Step_Delay:
  IF timer = 0 THEN Play_Show
    PAUSE StepTic
    timer = timer - 1
    GOTO Step_Delay                             ' and do next

Check_Cycles:
  IF cycles = 0 THEN Reset                      ' all cycles finished?
    cycles = cycles - 1
    GOTO Start_Show                             ' no, re-start EE sequence


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


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

Show_Data:
'           +------------ end of show bit
'           |+----------- start audio player
'           ||+---------- rocking horse air
'           |||+--------- rocking horse
'           ||||+-------- see saw air
'           |||||+------- see saw
'           ||||||+------ jack in the box air
'           |||||||+----- jack in the box
'           ||||||||
'           ||||||||  +-- timing "ticks"
'           ||||||||  |
  EEPROM ( %00111101, 8 )
  EEPROM ( %00111110, 8 )


  EEPROM ( %10000000, 8 )   'end of show

JonnyMac

I'm confused by terms, Jeff.  What do you mean by a "show"?  I take it to mean a trigger action that runs the sequence table one or more times.  How do you define it.

Perhaps you should just tell me what you want instead of giving me partial code and partial descriptions.  I'm working at a serious disadvantage being on the other coast and not seeing the mechanics of your props setup.
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

i am sorry for the confusion. I hope this clarifies.

show = sequence on a prop

using a prop1

1st STEP: trigger the show (sequence) with pin 6

2nd STEP: DELAY for 7 or 10 seconds (a value i can change)

3rd STEP: run actions below for 1 minutes 40 seconds to 2 minutes. With the prop 1 i need this part to loop 2 times, maybe 3 if i have to change to 6 tenths or 2 tenths of a second per line.

  EEPROM ( %00111110, 8 )
  EEPROM ( %00101001, 8 )
  EEPROM ( %00000001, 8 )
  EEPROM ( %00000100, 8 )
  EEPROM ( %00000111, 8 )
  EEPROM ( %00111010, 8 )
  EEPROM ( %00111001, 8 )

4th STEP: show ends ( the delay at the end of the show is not important becase the show (sequence) lasts longer than it takes the tractor to get all wheels across  the trigger.

EEPROM ( %10000000, 8 )

jeffh

if this is not doable, can i get a prop2 sent to me real fast?

with a prop2 i would not have to worry about the loop would i? it will hold enough instructions.
we purchased two that we are using for more time and it seems to be working fine.


JonnyMac

Go online and order using overnight shipping -- if you put in your order by 12PM Pacific Time it will go out today.
Jon McPhalen
EFX-TEK Hollywood Office

jeffh

moved to the prop2 controller. the prop2 is capable of handling enough instructions.

with the help of efx-tek support, the show is running on the prop2.

thank you for all you do. ;D