November 21, 2024, 10:03:42 PM

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.


pigmy pop up chase

Started by FichterFX, July 24, 2007, 07:58:06 PM

Previous topic - Next topic

FichterFX

Jon,
Could you give me a hand writing a program to chase four zombie pop ups with two movements each? I would like them to to run after another with each character having a first valve duration of 5 seconds and then another valve that runs with the first valve after a pause of 3 seconds. They are both to shutdown at the same time after the 5 seconds and the sequence is to continue for the next two valve set after a pause of 1 second. There are two valves per character.
Thanks for your help,
Gary













JonnyMac

Here's a very simple solution:

' =========================================================================
'
'   File...... Blowdart_Test.BS1
'   Purpose...
'   Author.... Jon Williams (for Gary Fichter)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 25 JUL 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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

SYMBOL  Lift1           = PIN0
SYMBOL  Blow1           = PIN1
SYMBOL  Lift2           = PIN2
SYMBOL  Blow2           = PIN3
SYMBOL  Lift3           = PIN4
SYMBOL  Blow3           = PIN5
SYMBOL  Lift4           = PIN6
SYMBOL  Blow4           = PIN7


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


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



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

Reset:
  DIRS = %11111111                              ' all pins are outputs


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

Main:
  Lift1 = IsOn
  PAUSE 3000
  Blow1 = IsOn
  PAUSE 2000
  Blow1 = IsOff
  Lift1 = IsOff

  Lift2 = IsOn
  PAUSE 3000
  Blow2 = IsOn
  PAUSE 2000
  Blow2 = IsOff
  Lift2 = IsOff

  Lift3 = IsOn
  PAUSE 3000
  Blow3 = IsOn
  PAUSE 2000
  Blow3 = IsOff
  Lift3 = IsOff

  Lift4 = IsOn
  PAUSE 3000
  Blow4 = IsOn
  PAUSE 2000
  Blow4 = IsOff
  Lift4 = IsOff

  GOTO Main


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


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



Note that after #4 does its thing #1 starts again -- you might want to add a bit of a pause before the GOTO Main line.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

For those wondering if this could have been done with a loop: yes, and here's how:

' =========================================================================
'
'   File...... Blowdart_Test_v2.BS1
'   Purpose...
'   Author.... Jon Williams (for Gary Fichter)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 25 JUL 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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


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

SYMBOL  lift            = B2
SYMBOL  blow            = B3


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

Reset:


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

Main:
  FOR lift = 0 TO 6 STEP 2                      ' 0, 2, 4, 6
    HIGH lift
    PAUSE 3000
    blow = lift + 1                             ' 1, 3, 5, 7
    HIGH blow
    PAUSE 2000
    PINS = %00000000                            ' all off
  NEXT

  GOTO Main


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


' -----[ EEPROM Data ]-----------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

How about with a table?  ;D
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

July 25, 2007, 11:30:42 AM #4 Last Edit: July 25, 2007, 11:36:29 AM by JonnyMac
Okay... but here's why I didn't do it with a table:

1) the program is very short
2) tables are not newbie friendly
3) then timing value must be used to indicate the end of sequence as all data bits are used for outputs.

This is how I'd do it if "forced" to write a table-driven program.

' =========================================================================
'
'   File...... Blowdart_Test_v3.BS1
'   Purpose...
'   Author.... Jon Williams (for Gary Fichter)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 25 JUL 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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

SYMBOL  Lift1           = PIN0
SYMBOL  Blow1           = PIN1
SYMBOL  Lift2           = PIN2
SYMBOL  Blow2           = PIN3
SYMBOL  Lift3           = PIN4
SYMBOL  Blow3           = PIN5
SYMBOL  Lift4           = PIN6
SYMBOL  Blow4           = PIN7


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  EventTime       = 100


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

SYMBOL  showBits        = B0                    ' output bits
SYMBOL  timing          = B1                    ' timing, end-of-show flag
SYMBOL  endOfShow       = BIT15                 ' 1 = stop when timer done

SYMBOL  pntr            = B2                    ' EE pointer
SYMBOL  tix             = B3                    ' timing multipler


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

Reset:
  DIRS = %00000000                              ' clear outputs
  DIRS = %11111111                              ' all pins are outputs

  pntr = 0


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

Main:
  READ pntr, showBits                           ' get step
  pntr = pntr + 1                               ' point to timing
  READ pntr, timing
  pntr = pntr + 1                               ' point to next step

  PINS = showBits                               ' no, update outputs
  tix = timing & %01111111                      ' clear OES bit

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

Next_Step:
  IF endofShow = IsOn THEN Reset                ' done?
    GOTO Main                                   ' keep going


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


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

TheShow:
  EEPROM (%00000001,  30)
  EEPROM (%00000011,  20)
  EEPROM (%00000100,  30)
  EEPROM (%00001100,  20)
  EEPROM (%00010000,  30)
  EEPROM (%00110000,  20)
  EEPROM (%01000000,  30)
  EEPROM (%11000000,  20)
  EEPROM (%00000000, 128)                       ' > 127 = end of show


Note that the timing field is now used to indicate the end of show; when bit7 of this value is set (making it 128 or larger) then program resets everything.  Note, too, that the maximum timing for any line is 127 units, or 12.7 seconds with a 100 ms EventTime value.
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Sorry. I was just kidding around. I didn't mean to actually make you do it. I will specifiy I am just joking the next time.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components