November 21, 2024, 03:51:33 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.


program help

Started by robbob, July 15, 2007, 01:30:50 PM

Previous topic - Next topic

robbob

Hello, In need of a new program update it's for eletric chair i've been running in our haunt. My plan to update with lights on-off ever quater second, to trigger prop with pir sensor, pin 0 to run pneumatic. All lights will be 12v . this is my old program.
' {$ STAMP BS1}
' {$ PBASIC 1.0}
SYMBOL rep = 0
SYMBOL valve = 0
OUTPUT valve
start :
FOR reps = 1 to5
HIGH valve
PAUSE 225
LOW valve
PAUSE 225
NEXT
FOR reps = 1 to 5
HIGH valve
PAUSE 300
LOW valve
PAUSE 300
NEXT
GOTO start

JonnyMac

Do you want the lights to be flashing while the pneumatic is pulsating?  How long is the entire cycle?  We have a little experience with electric chair code, especially since building our "Chuckie Fries" prop.

And... just because you have 12v light doesn't mean you can use them with the Prop-1; lights take a lot of energy and if your lamp draws more that 250 mA at 12v then you won't be able to use it; what you can do is switch the light with an transistor (like the TIP120) which can handle up to 5 amps.
Jon McPhalen
EFX-TEK Hollywood Office

robbob


Jon,,
Yes i would like the lights to flash in random if possible. The program to run for 12 seconds total time.
For 12v lights could i run the RC4 , for this way i could run a large power supply. I would like more
info on the transistor ( TIP 120 ) and how it would be used?





JonnyMac

Okay, I just need a few more details.  Do me a favor: explain what the viewer will see when the prop operates and I'll write the code from there.  Doing random things is easy with the Prop-1 (with the RANDOM instruction).  What I really want to understand is the interaction between the lights and the "victim" movement -- especially if the two are operating "randomly" at the same time.  Once we get the program sorted I'll draw you a schematic for controlling the TIP120.
Jon McPhalen
EFX-TEK Hollywood Office

robbob

Here is how it will happen when you walk into room PIR sensor starts program, the body in chair starts thrashing back and forth,there is a total of 12 lights on a control
panel to flash off and on , there is no order to lights , the control panel is next to the chair it's just for show . total show 12 seconds.
I hope this is what your looking for .

JonnyMac

Okay, here you go.  This program has a PIR input (on P7), light outputs on P1 - P6, and the cylinder output is on P0.  The Reset section clears everything and then waits 30 seconds; this lets the PIR warm-up in the beginning and provides an inter-show delay.  At Main the PIR is scanned and once we see that it's really on (1/4 signal) the program starts.  The Shake_It loop just stirs the random number and outputs it directly to the cylinder and light ports.  A 25 to 250 millisecond delay is created for each cycle and that delay gets added into an accumulator; this is you can control the timing of random cycles.

Let me suggest that you use LEDs instead of 12v lamps.  Incandescent lamps take an enormous amount of current (most of which is wasted in heat) and you may end up popping the ULN2803.  The schematic below shows you you can connect four LEDs per light pin (gives you 24 lights total lights) and not have any concern for overloading the ULN.  This circuit assumes that you're using LEDs with forward voltage of about 1.5 volts (which is typical), and with a 220-ohm resistor you'll get about 27 mA through the LEDs when on which should make them nice and bright, especially on a dimly-lit set.



Just make sure you randomly space your LEDs -- don't put them into a line (like in the schematic) as all of the LEDs connected to any pin light at the same time.


And here's the code.

' =========================================================================
'
'   File...... Chair.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 17 JUL 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PIR             = PIN7                  ' SETUP = DN
SYMBOL  Light6          = PIN6
SYMBOL  Light5          = PIN5
SYMBOL  Light4          = PIN4
SYMBOL  Light3          = PIN3
SYMBOL  Light2          = PIN2
SYMBOL  Light1          = PIN1
SYMBOL  Cylinder        = PIN0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


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

SYMBOL  pirTimer        = B2
SYMBOL  idx             = B3                    ' loop controller
SYMBOL  delay           = B4                    ' for lights/cylinder
SYMBOL  runTimer        = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear all pins
  DIRS = %01111111                              ' make outputs

  PAUSE 30000                                   ' PIR warm-up/restart delay
  pirTimer = 0                                  ' reset PIR timer


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10
  pirTimer = pirTimer + 10 * PIR                ' update timer
  IF pirTimer < 250 THEN Main                   ' ensure valid signal

  runTimer = 0                                  ' clear run timer

Shake_It:
  FOR idx = 1 TO 3
    RANDOM lottery
  NEXT
  PINS = lottery & %01111111                    ' update cylinder & lights
  delay = lottery // 226 + 25                   ' 25 to 250 ms
  PAUSE delay

  runTimer = runTimer + delay                   ' update run timer
  IF runTimer < 12000 THEN Shake_It             ' continue if less than 12s
    GOTO Reset


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


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


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

robbob

Hey Jon,

                thanks for all your help, The prop worked great with the new program and the new control looks great together.
                                   

JonnyMac

You're welcome; it's always our pleasure to help out.
Jon McPhalen
EFX-TEK Hollywood Office