November 23, 2024, 10:20:18 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.


multi-tasking

Started by Loud Bangs, December 08, 2010, 06:21:58 PM

Previous topic - Next topic

Loud Bangs

Can a prop-1 be set up to run 6 or 7 wicLEDs on a candle flicker AND serial out to a FC-4 to do a repeating 2 channel cross fade?

bsnut

December 08, 2010, 06:44:51 PM #1 Last Edit: December 08, 2010, 07:24:32 PM by bsnut
Let me answer your second part of your question first and that is yes can do a repeating 2 channel cross fade on FC-4. It how you code it.

Now, to answer your first part of your question. Yes you can, but you will need one pin for serial and maybe another pin for your trigger, leaves you with 6 pins for your wicLEDs.

Let me ask you this question. What are you trying to do? Why, I ask this, is because the Prop1(Basic1) aren't design to multitask, which means you need to coded to do multitask. I like to point you an article that Jon wrote for Nut&Volts on this whole multitasking process http://www.parallax.com/dl/docs/cols/nv/vol7/col/NV135.pdf
William Stefan
The Basic Stamp Nut

Loud Bangs

Thank you

was going to let it free run, no trigger. 6 wicleds would be fine as well.  the cross fade can be set up to fade up then down repeating as the "candles" flicker.   That is the effect I'm going for.  again THANK YOU

bsnut

I was editing my post. From what you posted I don't think I will call that multitasking and it will be easy to do Prop1.
William Stefan
The Basic Stamp Nut

JonnyMac

Loud Bangs: Do you want a cross-fade (two channels) or a fade-up/fade-down of one channel.  With a little bit of programming trickery you can do either.
Jon McPhalen
EFX-TEK Hollywood Office

Loud Bangs

What we would like to do is:     6 or 7 candles and the FC-4 cross fade 2 lamps up and down.  A black light and a white light.  Free run on power up.  No trigger is needed at this time.  I called it multi task because I'm asking for 2 different effects at the same time from the processor.
Thanks for your time, support and help.   The EZ-8 bought last year is still running strong.  12 hours a day, 7 days a week, the 6 months we are open.  GREAT product!!

JonnyMac

Here you go.  You didn't specify the cross-fade timing so I have set it to ~10 seconds.  To change this the SEROUT commands need to be modified, as well as the setting of "timer" before calling the Flicker subroutine.

This is no really multi-tasking because the cross-fade is handled by the FC-4.  Since the communication time to the FC-4 is only about 40ms and the wicks are updated immediately on entering the Flicker routine, everything should look seamless.  Just keep in mind that you MUST run the Flicker routine for the full-duration of the cross-fade as the FC-4 will ignore any new command requests until the cross-fade is complete.

I couldn't test this but I'm very confident it will be fine.


' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

SYMBOL  timer           = W4
SYMBOL  lottery         = W5

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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs


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

Main:
  ' xFade, Ch1 -> Ch4, ~10.24s
  SEROUT Sio, OT2400, ("!FC4", %00, "C", 0, 1, 4, 40)
  timer = 10500
  GOSUB Flicker

  ' xFade, Ch4 -> Ch1, ~10.24s
  SEROUT Sio, OT2400, ("!FC4", %00, "C", 0, 4, 1, 40)
  timer = 10500
  GOSUB Flicker

  GOTO Main


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

' flickers wick outputs for "timer" milliseconds

Flicker:
  FOR idx = 1 TO 3
    RANDOM lottery                              ' stir random #
  NEXT
  PINS = lottery & %00111111                    ' update wick outputs
  delay = lottery // 41 + 35                    ' 35 to 75ms
  IF timer < delay THEN Flicker_Exit
    PAUSE delay
    timer = timer - delay
    GOTO Flicker

Flicker_Exit:
  PAUSE delay
  RETURN

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


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


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

Loud Bangs

Thank you Jon,

That was awesome.  Do I read it correctly you are fading all 4 channels or 1 & 4?  If I need to change levels I can add level % after the channel number.    Like   ("!FC4", %00, "C", 0, 1, 50, 4, 127, 40)  just as a sample.  If I just need two channels change the 4 to a 2? 
Again  Thank You !!

JonnyMac

The cross-fade only works with two channels (please download the FC-4 docs for reference).  In this case the fade is from channel 1 to channel 4, then back.  I used channels 1 and 4 for wiring convenience.  The program 0 cross-fade uses the full brightness range

The program 1 cross-fade allows you to specify the start and stop levels.  Let's say you want to go from 24% to 75% and do it over a span of 10 seconds.  The code in the main loop changes to this:

Main:
  ' xFade, Ch1 (25%) -> Ch4 (75%), ~9.98s
  SEROUT Sio, OT2400, ("!FC4", %00, "C", 1, 1, 64, 4, 191, 78)
  timer = 10100
  GOSUB Flicker

  ' xFade, Ch4 (75%) -> Ch1 (25%), ~9.98s
  SEROUT Sio, OT2400, ("!FC4", %00, "C", 1, 4, 191, 1, 64, 78)
  timer = 10100
  GOSUB Flicker

  GOTO Main


Note that the levels have to be specified in lighting units which go from 0 to 255, hence 25% is 64, and 75% is 191.  There is a span of 128 units between these levels so 78 milliseconds per level gives a fade of about 10 seconds.
Jon McPhalen
EFX-TEK Hollywood Office