November 21, 2024, 10:38:17 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.


Help with first program.......

Started by john@thedevils-den, August 24, 2007, 08:02:17 PM

Previous topic - Next topic

john@thedevils-den

August 24, 2007, 08:02:17 PM Last Edit: August 24, 2007, 08:10:15 PM by john@thedevils-den
Essentially this is what I am trying to do.

Manually trigger routine:
Room lighting on for  30 seconds(110 vac through relay)
Room lighting goes out for remainder of routine
When room lighting goes out,spot lighting comes on(12vdc), prop twitches once very quicly then pauses for 1 second
twitches again then pauses for 2 seconds, twitches a 3rd time and pauses for 4 seconds then extends all the way up and screams for
30 seconds , then drops back down spot lighting goes off and room lighting comes back on.. I am using a prop1 and an AP-8 along with a 12vdc pneumatic valve. As this is my first program, I am wanting to learn how to do it myself but I dont know where to start. I have read the pdf files and I have also read the help section in the BS editor. I guess I need to figure out when and where to use the "program commands"  PLease help if you can. Thanks in advance for your time.

JonnyMac

That's actually a little sophisticated to start with -- you should checkout our programming basics PDF and get LED blinking under control first, because if you can deliberately blink an LED you can do about anything.  I can write this program for you if you'd like -- it will only take me a few minutes.  You can see how your requirements translate to code by a veteran programmer.  You, too, can become a veteran, but you should probably give yourself a few weeks....  ;D
Jon McPhalen
EFX-TEK Hollywood Office

john@thedevils-den

Jon,

If you don't mind helping me with(writing) this program, I would really appreciate it. I assumed that this might be difficult for me as a first program. I will go learn the blinking LED program right now. Thanks again.


-John

JonnyMac

Okay, please define "twitch."  If it's just a quick output, how long is it?
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Just clarify... the room light is on until the trigger is detected, right?  I'm not sure about the 30-second timing (or is there a 30-second delay on the room light after the trigger?)
Jon McPhalen
EFX-TEK Hollywood Office

john@thedevils-den

 The twitch im looking for is just maybe less than 1 second. Just enough to lift the prop up enough to just detect movement without it fully sitting up.....not sure on exact timing. I would say the time it takes to manually turn a switch on and off would be the time Im looking for. As far as the room lighting goes. I want the 110 vac lights to be on when the patrons walk into the room,give them all enough time to get in and settled, then the routine would be triggered manually,  as soon as the routine starts I want the lights to go out and at the exact same time, the LED spotlights to come on. Then once the twitching is stopped and the prop actuates (which takes about a second) I want the audio to kick in...............Just as a side bar, I was playing with the trainer and I wrote a few different LED lighting programs and I got the hang of that.....I can see where you need to have the program written out prior to starting the input into BS editor. I am a little confused on the whole timing thing. I will keep practicing.....thanks again Jon

-John

JonnyMac

Give this a look -- and a try.  Note that the X command for the AP-8 in the reset section is there to reset the AP-8 in the event of a random reset.  Please study the code and refer to the PBASIC guide; it will make sense in no time at all.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; use ULN2003
SYMBOL  Trigger         = PIN6
SYMBOL  Lifter          = PIN2
SYMBOL  PinSpot         = PIN1
SYMBOL  RoomLight       = PIN0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


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

SYMBOL  twitches        = B2                    ' loop counter
SYMBOL  delay           = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000001                              ' room light only
  DIRS = %00000111                              ' set outputs

  SEROUT Sio, OT2400, ("!!!!!!!AP8", %00, "X")  ' kill audio
  RoomLight = IsOn                              ' allow patrons to enter


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

Main:
  RANDOM lottery                                ' stir random value
  IF Trigger = IsOff THEN Main                  ' wait for trigger

  RoomLight = IsOff                             ' switch lighting
  PinSpot = IsOn

  FOR twitches = 0 TO 2                         ' three twitches
    RANDOM lottery                              ' re-stir
    delay = lottery // 51 + 50                  ' 50 to 100 ms
    Lifter = IsOn
    PAUSE delay
    Lifter = IsOff
    LOOKUP twitches, (1000, 2000, 4000), delay
    PAUSE delay
  NEXT

  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)     ' start audio
  Lifter = IsOn
  PAUSE 30000                                   ' let audio finish
  Lifter = IsOff

  GOTO Reset


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


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


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

john@thedevils-den

Jon,

I wanted to say thanks for your help on this one. I will work on the next one and post it here for your review.
I think with a little more time, I will get the hang of this.  As far as this program goes, it works just like I want it to.
Great Support site you've got here.

-John

JonnyMac

You're welcome.  We're always happy to be of service.
Jon McPhalen
EFX-TEK Hollywood Office