November 22, 2024, 10:25:56 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.


Animated Column

Started by Lotus, October 15, 2013, 04:44:30 PM

Previous topic - Next topic

Lotus

Just got back into haunting and writing code, I was wondering if you could give this code a look over and help me with one part of it. I want to make the corpse thrash and have the strobe led strobe while the corpse is thrashing but can't figure out how to get that to work.  Any suggestion? http://www.youtube.com/watch?v=E0tn6Vxw3Cg here is a video of the prop in action in case my  Program Description is hard to follow

Lotus/Joe

' =========================================================================
'   File...... Right Column
'   Purpose...
'   Author.... Joe Lajoie & Steve O'Connor
'   E-mail....
'   Started... 9/11/2009
'   Updated... 10/9/2013
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================

' -----[ Program Description ]---------------------------------------------
' Right Column: the prop remains in standby until triggered. Once triggered a double action cylinder is activated and lowers the drop panel
' "door". While this is happening a strobing effect "strobe" happens until door is dropped. Then Eyes turn on "Blue_light" and Corpse Thrashes
' "Corpse" and Audio "Audio" Begins. The Corpse will thrash for 12.5 seconds then "Blue_Light", "Corpse", will turn off and door will activate
' and close and go back into standby for 5 minutes and not be able to be triggered until 5 minutes is up.  Mailbox subroutine is only active if
' the column is not active and the 2 minute timer is up the mailbox will continue you trigger every 2 minutes until the columns are activated.
' -----[ I/O Definitions ]-------------------------------------------------

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

SYMBOL strobe                 = 0
SYMBOL blue_light             = 1
SYMBOL door                   = 2
SYMBOL corpse                 = 3
SYMBOL mail_light             = 4
SYMBOL mail_door              = 5
SYMBOL Audio                  = 7
SYMBOL Trigger                = PIN6


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

SYMBOL corpse_strobe_cycle    = B2
SYMBOL mail_thrash_cycle      = B3
SYMBOL mailbox_timer          = W0
SYMBOL trigger_timer          = B5
SYMBOL corpse_thrash_cycle    = B6

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

Reset:
mailbox_timer = 20000
trigger_timer = 3


Idle_routine:
  mailbox_timer = mailbox_timer - 1
  IF mailbox_timer < 1 THEN mailbox_routine
  IF Trigger = 1 THEN Trigger_Check      'Pressure Pad stepped on
GOTO Idle_routine

Trigger_Check:
  trigger_timer = trigger_timer -1
  DEBUG trigger_timer, CR
  IF trigger_timer < 1 THEN Corpse_Action
  IF Trigger = 1 THEN Trigger_Check
GOTO Reset

Corpse_Action:
  DEBUG "Action", CR
    HIGH blue_light
    HIGH door
    HIGH Audio

  FOR corpse_strobe_cycle = 1 TO 10
    HIGH strobe
    PAUSE 100
    LOW strobe
    PAUSE 100
  NEXT

  HIGH strobe
  LOW Audio

FOR corpse_thrash_cycle = 1 TO 11
    HIGH corpse
    PAUSE 600
    LOW corpse
    PAUSE 500
  NEXT

    LOW strobe
    LOW blue_light
    LOW door

    PAUSE 50000
  DEBUG "Armed", CR
GOTO Reset

' -----[ Subroutines ]-----------------------------------------------------
mailbox_routine:

  HIGH mail_light

  FOR mail_thrash_cycle = 1 TO 15

    HIGH mail_door
    PAUSE 120
    LOW mail_door
    PAUSE 110
  NEXT

    LOW mail_light
  DEBUG "MAILBOX", CR
GOTO Reset


JonnyMac

If I understand your description and request... you'd like the column action (corpse) to be able to run and then have a 5-minute lock-out before it can be triggered again. While locked-out or not triggered, the mailbox action should run every 2 minutes.

You also want a strobing action when the corpse is doing its thing.

Right?

Okay, here's what I came up with. I started from scratch because I have a very particular programming style that I'm comfortable with. I believe the program does as you request, with the added bonus of randomized movement. The corpse and mailbox actions were very mechanical; I added randomized timing to give them a more organic feel.

The challenge is adding the strobe light in the middle of the corpse action. I noticed that you used a 100ms on/off time for the strobe so I stuck with this, making the resolution of the corpse movement 100ms. This allows me to toggle the strobe pin at the same rate as the intro strobe. Notice that the corpse loop runs a specific amount of time, but the movement is randomized; this should make it look more herky-jerky than mechanical -- this tends to look better as an effect.

Let us know how this works out.

' =========================================================================
'
'   File...... corpse_column.bs1
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 15 OCT 2013
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' (I) SETUP = DN
SYMBOL  Audio           = PIN6                  ' (O) SETUP = DN
SYMBOL  MailDoor        = PIN5                  ' (O)
SYMBOL  MailLight       = PIN4                  ' (O)
SYMBOL  Corpse          = PIN3                  ' (O)
SYMBOL  Door            = PIN2                  ' (O)
SYMBOL  BlueLight       = PIN1                  ' (O)
SYMBOL  Strobe          = PIN0                  ' (O)


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

SYMBOL  YES             = 1
SYMBOL  NO              = 0

SYMBOL  IS_ON           = 1                     ' active-high I/O
SYMBOL  IS_OFF          = 0


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

SYMBOL  idx             = B0                    ' control loop index

SYMBOL  delay           = W1
SYMBOL  mbtimer         = W2                    ' mailbox timer
SYMBOL  holdoff         = W3                    ' hold-off timer for corpse
SYMBOL  timer           = W4                    ' gen purpose timing
SYMBOL  lottery         = W5                    ' random #


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

Power_Up:
  lottery = 1031                                ' seed random #

Reset:
  PINS = %00000000                              ' all off
  DIRS = %01111111                              ' P6..P0 are outputs

  holdoff = 0                                   ' reset timers
  mbtimer = 0


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

Main:
  timer = 0                                     ' reset
  FOR idx = 1 TO 10                             ' debounce 100ms
    RANDOM lottery                              ' stir random #
    PAUSE 10
    timer = timer + 10 * Trigger
  NEXT

Update_Timers:
  holdoff = holdoff + 1 MAX 3000                ' corpse holdoff
  mbtimer = mbtimer + 1 MAX 1200

Check_Column:
  IF holdoff < 3000 THEN Check_Mailbox          ' 3000 x 100ms = 5mins
    IF timer < 100 THEN Check_Mailbox           ' valid trigger?
      GOTO Corpse_Action

Check_Mailbox:
  IF mbtimer < 1200 THEN Main                   ' 1200 x 100ms = 2mins
    GOTO Mailbox_Action

  GOTO Main


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

Corpse_Action:
  BlueLight = IS_ON
  Door = IS_ON
  Audio = IS_ON

  FOR idx = 1 TO 20                             ' flash strobe
    Strobe = 1 - Strobe                         ' toggle
    PAUSE 100
  NEXT

  Audio = IS_OFF

  timer = 125                                   ' timing x 100ms

Corpse_Thrash:
  Corpse = 1 - Corpse                           ' toggle corpse
  RANDOM lottery                                ' stir random #
  delay = lottery // 4 + 3 MAX timer            ' 3 to 6 ( x 100ms )
  FOR idx = 1 TO delay
    Strobe = 1 - Strobe                         ' toggle strobe
    PAUSE 100
  NEXT
  timer = timer - delay
  IF timer > 0 THEN Corpse_Thrash

Thrash_Done:
  GOTO Reset                                    ' clear everything


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

Mailbox_Action:
  MailLight = IS_ON

MB_Thrash:
  FOR idx = 1 TO 15
    MailDoor = 1 - MailDoor                     ' toggle door
    RANDOM lottery                              ' stir random #
    delay = lottery // 76 + 75                  ' 75 to 150ms
    PAUSE delay
  NEXT

  MailDoor = IS_OFF
  MailLight = IS_OFF

  mbtimer = 0                                   ' reset timer
  GOTO Main


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


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


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

Lotus

Awesome thank you so much, can't wait to try it out this weekend  :D

Lotus

October 21, 2013, 05:12:09 PM #3 Last Edit: October 21, 2013, 05:15:29 PM by Lotus
I can't seem to get it to trigger with a pressure mat, any ideas? tested it on a prop 1 trainer and actual prop's prop 1

bsnut

October 21, 2013, 06:30:22 PM #4 Last Edit: October 21, 2013, 07:44:41 PM by bsnut
The big question is, how far is the pressure mat from the Prop-1? If the pressure mat is too far from the Prop-1, the 5VDC supplied from the Prop-1 will not be able to make it back to the Prop-1 I/O pin.

Another question is, do you have the one of the wires from the pressure mat connected to P7.W and the other wire from the mat to P7.R and also do you have the setup jumper set in the down position. Also check to see if you have continuity using your meter when you have something heavy or you are on the mat.   
William Stefan
The Basic Stamp Nut

JackMan

Do you have the Step Mat on P7? Your original program had the trigger on P6 and the Audio on P7, Jon's program has them reversed. If this doesn't do it, check the trigger with a N.O. switch in place of the step mat to see if it works.

Lotus

Quote from: bsnut on October 21, 2013, 06:30:22 PM
The big question is, how far is the pressure mat from the Prop-1?

Another question is, do you have the one of the wires from the pressure mat connected to P7.W and the other wire from the mat to P7.R

also do you have the setup jumper set in the down position.

The mats wire is about 7 inches away
I have it plugged into P7.W and P7.R
Yes I have to setup jumper set in the down position
Quote from: JackMan on October 21, 2013, 07:23:56 PM
Do you have the Step Mat on P7? Your original program had the trigger on P6 and the Audio on P7, Jon's program has them reversed. If this doesn't do it, check the trigger with a N.O. switch in place of the step mat to see if it works.
Yup I got the mat on pin 7, right now i checking each wire.

Lotus

Got it to work on the prop 1 trainer with the pressure mat

JonnyMac

Remember to move the power switch to position 2 -- this is required to provide power to your valves.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Like I said ealier, try using just a N.O. button in place of the step mat, leave everything else the same. If it doesn't work, then you have just eliminated the step mat as the potential problem. The best way to approach the problem is to start with the obvious and work your way deeper into the problem one step at a time until you find the culprit. If you change more than one element at a time, you don't know where the gremlin is.  ;)

Lotus

Its working!!!!! checked wire by wire until I found the problem Thanks for All the help guys