November 23, 2024, 07:45:22 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.


I coud use some help

Started by matwel, October 03, 2010, 07:10:10 PM

Previous topic - Next topic

matwel

Here is the program I am running.  I need to put a second switch in that will delay everything for 10 seconds,  if trigger before first switch
' {$STAMP BS1}



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

' Coffin:
' PIR sensor trips, (fog machine, on 5 sec.), coffin lid opens via
' pneumatics for 5 sec. and strobe light, after 2 sec. delay, corpus
' pops up via pneumatics, after initial 5 sec. everything closes and
' shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN

SYMBOL  Corpse          = PIN3                  ' valve to V+/OUT3
SYMBOL  Strobe          = PIN2                  ' relay to V+/OUT2
SYMBOL  light           = PIN1                  ' valve to V+/OUT1
SYMBOL  Back           = PIN0                  ' relay to V+/OUT0


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0


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

SYMBOL  timer           = B2                    ' for PIR debounce


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00001111                              ' set output pins (P0..P3)

  PAUSE 00000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                     ' wait for valid signal

  Light = IsOn

  PAUSE 200
  Light = Isoff
  PAUSE 100
  light = Ison
  PAUSE 150
  Light = Isoff

  PAUSE 150
  Light = Ison
  PAUSE 150
  Light = Isoff
  PAUSE 250





  light = Isoff

  Back = IsOFF
  Strobe = IsOn
  Corpse = IsUp

  PAUSE 3000

  Back = Ison
  Strobe = IsOff
  PAUSE 3000                                    ' let corpse retract
  Back = Isoff



Long_Delay:
  PAUSE 6000                                   ' one minute
  PAUSE 00000                                   ' forty seconds

  GOTO Reset


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


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


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

JonnyMac

October 03, 2010, 07:16:24 PM #1 Last Edit: October 03, 2010, 07:23:24 PM by JonnyMac
Two Three things:

1) "I could use some help" is not a good Subject line -- gives those searching for information nothing to go on.
    -- see guideline #2: http://www.efx-tek.com/php/smf/index.php?topic=266.0

2) Where should the delay occur?  Under what conditions?  Programming is tough enough with all the details, without them it's darned near impossible.  ;D

Edit -- third item:

3) When a program is not behaving as you desire, or you want to add a feature to it, please post a clear, detailed explanation of the entire program -- not just the broken part or new feature.  Fixes and features can be handled in many ways, and having a clear understanding of the end game often dictates what/how various strategies are implemented.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

October 03, 2010, 08:17:04 PM #2 Last Edit: October 03, 2010, 08:20:08 PM by bsnut
I was looking a your program and found some problems

1. First problem is here under Long_Delay
 PAUSE 6000                                   ' one minute


In order to pause for one minute it needs to look like this  
 PAUSE 60000                                   ' one minute


2. The next problem is still under the Long_Delay and this is wrong and will not work
 
 PAUSE 00000                                 ' forty seconds


And needs to like this in order to work at all
 
 PAUSE 40000                                 ' forty seconds


3. This maybe your other problem and that is with the timing of the light for the coffin. The timing that you have may be to short.
 
 Light = IsOn
 PAUSE 200
 Light = Isoff
 PAUSE 100
 light = Ison
 PAUSE 150
 Light = Isoff

 PAUSE 150
 Light = Ison
 PAUSE 150
 Light = Isoff
 PAUSE 250


As Jon pointed out you need more detail in order for your program to work the way you would like it to.
William Stefan
The Basic Stamp Nut

matwel

Program works fine as it is does everything i want it to.  just wanted to add a second swicth that if it is triggered before  the first switch that it has a 10 second delay then resets progarm.
Thank You

JonnyMac

' {$STAMP BS1}



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

' Coffin:
' PIR sensor trips, (fog machine, on 5 sec.), coffin lid opens via
' pneumatics for 5 sec. and strobe light, after 2 sec. delay, corpus
' pops up via pneumatics, after initial 5 sec. everything closes and
' shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  DelaySw         = PIN7                  ' SETUP = DN
SYMBOL  PIR             = PIN6                  ' SETUP = DN

SYMBOL  Corpse          = PIN3                  ' valve to V+/OUT3
SYMBOL  Strobe          = PIN2                  ' relay to V+/OUT2
SYMBOL  Light           = PIN1                  ' valve to V+/OUT1
SYMBOL  Back            = PIN0                  ' relay to V+/OUT0


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0


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

SYMBOL  timer           = B2                    ' for PIR debounce


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00001111                              ' set output pins (P0..P3)

  PAUSE 30000                                   ' warm-up delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 250 THEN Check_Trigger             ' wait for 0.25 sec input

  IF DelaySw = IsOff THEN Start_Show            ' if open, skip delay
    PAUSE 10000                                 ' 10 secs

Start_Show:
  Light = IsOn

  PAUSE 200
  Light = Isoff
  PAUSE 100
  light = Ison
  PAUSE 150
  Light = Isoff

  PAUSE 150
  Light = Ison
  PAUSE 150
  Light = Isoff
  PAUSE 250

  Light = Isoff

  Back = IsOFF
  Strobe = IsOn
  Corpse = IsUp

  PAUSE 3000

  Back = Ison
  Strobe = IsOff
  PAUSE 3000                                    ' let corpse retract
  Back = Isoff


Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Main


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


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


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