November 23, 2024, 05:54:05 AM

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.


Lightning pause

Started by Horndog, May 07, 2009, 08:47:16 PM

Previous topic - Next topic

Horndog

1st off it was nice to talk to you in Milwaukee, I forcast me buying my fair share of equipment from you. I'm glad I got the prop-1, my son is trying harder than I but anyways... I have this lightning thasher I'm working on from your random post. I'll post what I have so far. What I need is... 1st for the lightning to pause for 2-5 seconds then the random lightning for 1-3 seconds. Also I want it to output to 2 pins, the thunder soundtrack will be played by an outside source.

' {$STAMP BS1}
  SYMBOL  Thrasher        = 0

SYMBOL  msDelay         = B4
SYMBOL  lottery         = W5

Reset:
  LOW Thrasher

Main:
  RANDOM lottery
  msDelay = lottery // 1000 + 5000
  TOGGLE Thrasher
  PAUSE msdelay
  GOTO Main

JonnyMac

We're sure you'll have fun with the Prop-1 -- especially working with your son doing projects.

I'm not sure I understand what you want.  Are you wanting a 2- to 5-second delay between lightning strikes that are 1- to 3-seconds long?  What are the two outputs?  I imagine one is the light -- is the other triggering some sort of sound device? 

The more details you provide, the better.

Just a note about your code: B4 is a byte variable that can hold values from 0 to 255; this means that your calculation of msDelay won't work because you're trying to put a number between 5000 and 5999 into it.
Jon McPhalen
EFX-TEK Hollywood Office

Horndog

Thanks for getting back to me Jon. I'm after something fairly simple...I think.  I want to run 2 separate Chauvet ST-2000 strobes (like the ones you showed me at Hauntcon) No music just lights for now. I figure this is a good place to start. It will run continuously. The lightning simulation is the tough part. The delay you mentioned would be correct. To reiterate, I want 2 strobes having 1 to 3 second bursts of lightning and a 2 to 5 second delay between each burst. Or whatever lightning looks like. Thanks a bunch! By the way where do I find more info on the byte variable?

JonnyMac

Okay... that's a horse of a different color.  You are, in essence, running two props (lightning simulators) from one controller -- possible, but makes the programming somewhat tricky.  Having spent about 17 years of my life in the golf industry I know something about lightning; each flash one sees is comprised of one or more strokes (this gives the flash its pulsating look).  I'm going to write the program such that it does the delays between two outputs and when an output is active it will send one to five strokes; I think -- especially using a strobe -- that this will give a more realistic simulation.

Let me stew on this a while; I should be able to come up with something today.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

The wonders of Starbucks!  After downing a big cup of coffee I started code and, boo-ya!, this program came right out.  Run it on your on Prop-1 trainer to make adjustments.  And yes, there is just enough variable and code space to add one more bolt control output.

Notes: With multi-tasking programs like this on the Prop-1 and Prop-2 you cannot get 1-millisecond resolution so I use 0.1 seconds as the time base -- this is easy to remember; 10 units = 1 second.  After watching it I set the delay between flash events to 2 to 7 seconds.  After the stroke count is randomized it must be doubled to account for the on/off action of that part of the code.  That said, I added a bit of a safety feature in the Lx_Reset sections to ensure the bolt output is off when the flashing is supposed to be done.

Enjoy.

' =========================================================================
'
'   File...... Lightning_Sim_2x.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 08 MAY 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Bolt2           = PIN1
SYMBOL  Bolt1           = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  state1          = B2
SYMBOL  timer1          = B3
SYMBOL  strokes1        = B4

SYMBOL  state2          = B5
SYMBOL  timer2          = B6
SYMBOL  strokes2        = B7

SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000011                              ' set output pins

  timer1 = 1
  timer2 = 25

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

Main:
  PAUSE 95                                      ' pad for ~100ms loop
  RANDOM lottery


Update1:
  IF timer1 = 0 THEN Update2                    ' prevent roll-under
    timer1 = timer1 - 1

Update2:
  IF timer2 = 0 THEN Lightning1
    timer2 = timer2 - 1


' ------------
' Lightning #1
' ------------

Lightning1:
  BRANCH state1, (L1_Wait, L1_Flash)

L1_Wait:
  IF timer1 > 0 THEN L1_Exit
    state1 = 1
    RANDOM lottery
    strokes1 = lottery // 5 + 1 * 2             ' 1 to 5 (x2 for on/off)
    GOTO L1_Exit

L1_Flash:
  IF strokes1 = 0 THEN L1_Reset
    PINS = PINS ^ %00000001                     ' toggle P0 output
    strokes1 = strokes1 - 1
    GOTO L1_Exit

L1_Reset:
  Bolt1 = IsOff
  RANDOM lottery
  timer1 = lottery // 51 + 20                   ' 2 to 7 seconds (random)
  state1 = 0

L1_Exit:


' ------------
' Lightning #2
' ------------

Lightning2:
  BRANCH state2, (L2_Wait, L2_Flash)

L2_Wait:
  IF timer2 > 0 THEN L2_Exit
    state2 = 1
    RANDOM lottery
    strokes2 = lottery // 5 + 1 * 2             ' 1 to 5 (x2 for on/off)
    GOTO L2_Exit

L2_Flash:
  IF strokes2 = 0 THEN L2_Reset
    PINS = PINS ^ %00000010                     ' toggle P1 output
    strokes2 = strokes2 - 1
    GOTO L2_Exit

L2_Reset:
  Bolt2 = IsOff
  RANDOM lottery
  timer2 = lottery // 51 + 20                   ' 2 to 7 seconds (random)
  state2 = 0

L2_Exit:
  GOTO Main


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


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


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

JonnyMac

For those interested, I've attached the 3-bolt version to this post.
Jon McPhalen
EFX-TEK Hollywood Office

Horndog

Jon, It's Beautiful! Ya know when we first talked you said you would be there to answers questions, etc... Well I of course did not belive you completely, you are of course trying to sell a product. But my friend you have proven me wrong. You are a man of your word! I am very impressed with you and your company. Thank you, Thank you, Thank you!   Ben Horn

JonnyMac

EFX-TEK rules!!!  ;D

Have fun with the program and do post video if you can.  I'm actually thinking about using it in our booth at MHC -- will put 1w white LEDs in the corners and let them randomly flash like lightning.  I'm pretty happy with the simulation in code and am glad it works for you, Ben.
Jon McPhalen
EFX-TEK Hollywood Office

EricTheMannn

I just got another prop-1 not to long ago, this time i got the starter kit, for the trainer. That thing comes in handy, the lightning simulator looked great on it. i was wondering, I've got a few more orders coming soon!

-Eric
WooHoo

JonnyMac

What were you wondering?....

BTW, once we went into high-volume production of the Trainer the cost came down and we passed that savings along to our customers.  If you need a trainer without the other stuff, they are available.
Jon McPhalen
EFX-TEK Hollywood Office

EricTheMannn

 That was a type-o sorry, i just read it thinking "What was i talking about?"

Thanks for the info, but i figured I'd get the starter kit, i needed a trainer (its come in handy so far), a prop-1 and the ac adapter, might as well get the kit and get the whole shaabang.

-Eric







WooHoo