May 18, 2024, 06:04:20 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Timing issues with FC-4

Started by Caretaker.CCI, January 03, 2008, 10:23:19 AM

Previous topic - Next topic

Caretaker.CCI

Hi Jon:

My name is Greg Lewis, I am the ?Caretaker? for our show called ?The Cemetery at Cross and Ide? (CCI for short). We have spoken with each other before but this time I decided to register on the Forum and become a ?legitimate? member.

The show I created for Halloween was the most technologically challenging show I have attempted. I am in the process of editing some raw video into a viewable format, I can show that to you when it is ready (if it would help). For this show, I was using a Prop1 as a ?Master? and several ?Slave? Prop1?s to control other aspects of the show. There were some problems I encountered but the one that is relevant for this post has to do with timing. Unfortunately, I was unable to resolve the problem so I changed that part of the show and decided to come back to the issue when I had more time. I thought I had saved the program that was causing the problem but alas? It was probably over-written in the heat of battle.

Here?s the scene:

Virgil (he?s my animatronic and the narrator of the show) says, ?? the spirits are getting restless?. At that point, several things all begin to happen.

1. Ambient lights go out (RC-4)
2. Spot light on the spinning wheel fades on (FC-4)
3. Wheel on spinning wheel starts to spin (AC motor, RC-4)
4. Motor for FCG begins to spin (RC-4)
5. Spot light on FCG fades on for Pepper?s Ghost effect (FC-4)
6. Activate ?Moan? for FCG (AP-8)
7. Pause (let audience take in the sights)
8. Spot light on FCG fades out (FC-4)
9. Stop motor for FCG (RC-4)
10. Spinning wheel stops (RC-4)
11. Spot light on spinning wheel fades out (FC-4)
12. Turn on ambient lights (RC-4)
13. Return control to Virgil to continue monologue

The problem I was having was in step 11. Everything else worked but the spot light on the spinning wheel would never fade off. There are (perhaps) a number of different problems that could exist but it would seem to me that there is a timing issue here. In another post for the AP-8 you suggested the following snippet of code to make the program wait until the monologue was finished:


Let_AP8_Finish:
  SEROUT Sio, Baud, ("!AP8", %00, "G")         ' get status
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Let_AP8_Finish
  RETURN

Could the ?G? command be used on the FC-4 in the same manner? I calculated the duration of the fade (as per the documentation) but since timing was so critical, anything is possible. Unless there is something else (always a possibility), it seems to me that I need to make my program (Master) wait until certain events have been completed. Do you have another source code that you (or someone else) wrote that shows this? Any other suggestions would also be appreciated.

The show for 2007 has been dismantled but I?m sure that next year will present similar challenges. Now is the time to learn how to deal with those problems. Thanks so much for your time and some truly fantastic tools to work with.

The Caretaker, CCI

JonnyMac

January 03, 2008, 11:12:30 AM #1 Last Edit: January 03, 2008, 11:48:31 AM by JonnyMac
Greg,

The present FC-4 firmware does not support reporting levels when it's in the middle of a dynamic process (e.g., fade) -- but I am working on an update that will allow that, as well as additional features.  For example, what we're going for is the ability to have all four channels fading at the same time if you want that to happen, and you could ask the FC-4 for the state of things at any time.  Now, this is tricky code and I've got some things to work out.  The FC-4 is field-upgradeable and we will make the firmware available for anyone who wants it.

That doesn't help you with your immediate problem.  That said, did a lighting project with the FC-4 for a friend's museum.  Checkout this thread:

-- http://www.efx-tek.com/php/smf/index.php?topic=356.0

Once the base code was written I ran it several times to fine-tune.  Sometimes we have to work though these things empirically, especially with a slow micro like the Prop-1.

One thing that you may need to consider is the length of time required to send a message: at 2400 baud it is 4.17 milliseconds per byte.  If you're cutting things very close this timing could make a difference.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's a program that matches your description; it will, of course, require fine-tuning on your end.

' =========================================================================
'
'   File...... Caretaker_1.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 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; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

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


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

SYMBOL  rc4Outs         = B0
SYMBOL   ambient        =  BIT0
SYMBOL   wheel          =  BIT1
SYMBOL   fcg            =  BIT2

SYMBOL  timer           = W5


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

Reset:
  rc4Outs = %0001                               ' ambient on only
  GOSUB Update_RC4


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

Main:
  timer = 0

Check_Trigger:
  PAUSE 5
  timer = timer + 5 * Trigger
  IF timer < 200 THEN Check_Trigger

  ' 1. Ambient lights go out (RC-4)
  '
  ambient = IsOff
  GOSUB Update_RC4

  ' 2. Spot light on the spinning wheel fades on (FC-4.1)
  ' -- 1.024 seconds, after ~42 ms delay for command
  '
  SEROUT Sio, OT2400, ("!FC4", %00, "F", 1, 0, 255, 4)

  ' 3. Wheel on spinning wheel starts to spin (AC motor, RC-4)
  '
  wheel = IsOn
  GOSUB Update_RC4
  PAUSE 1000

  ' 4. Motor for FCG begins to spin (RC-4)
  '
  fcg = IsOn
  GOSUB Update_RC4

  ' 5. Spot light on FCG fades on for Pepper?s Ghost effect (FC-4.2)
  '
  SEROUT Sio, OT2400, ("!FC4", %00, "F", 2, 0, 255, 4)

  ' 6. Activate "Moan" for FCG (AP-8)
  '
  SEROUT Sio, OT2400, ("!FC4", %00, "P", 0)

  ' 7. PAUSE (let audience take in the sights)
  '
  PAUSE 10000

  ' 8. Spot light on FCG fades out (FC-4)
  '
  SEROUT Sio, OT2400, ("!FC4", %00, "F", 2, 255, 0, 4)

  ' 9. Stop motor FOR FCG (RC-4)
  '
  fcg = IsOff
  GOSUB Update_RC4

  ' 10. Spinning wheel stops (RC-4)
  '
  wheel = IsOff
  GOSUB Update_RC4

  ' 11. Spot light on spinning wheel fades out (FC-4.1)
  ' -- 0.512 seconds, after ~42 ms delay for command
  '
  SEROUT Sio, OT2400, ("!FC4", %00, "F", 1, 0, 255, 2)
  PAUSE 512

  ' 12. Turn on ambient lights (RC-4)
  '
  GOTO Reset


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

' Update RC-4 outputs
' -- takes ~25 milliseconds to send command

Update_RC4:
  SEROUT Sio, OT2400, ("!RC4", %00, rc4Outs)
  RETURN

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


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


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

Caretaker.CCI

Wow! I wasn't expecting all that! I didn't mean for you to write a complete program for me. Thank You!

I will have to take some time to digest the code you created and then test it. The problem is not "immediate". I have until next season to work with this and learn all that I can. In the mean time, where should I keep an eye out for the updated code for the FC-4? I have 4-more FC-4's coming my way that I can create an enclosure for while I am waiting. Thanks for the help.

BTW, I created 2-other 120VAC light fading control mechanisms. One based on the article by R. Turley (mentioned by Scarry Terry) and another that uses PWM commands to change the intensity of an LED that is aimed at a light dependent resistor. All three worked well last season.

Greg

JonnyMac

When we release updates we'll post a message here.  To upgrade the device at home you'll need an SX-Blitz to reprogram the board (this will work with any SX-based product we create).
Jon McPhalen
EFX-TEK Hollywood Office

Caretaker.CCI

OK? I see how the program works. Very nice! I like the way you control the individual bits of BO with aliases. It makes it easier to follow what is going on in the code. I also noticed you ?debounced? the trigger. That was also a problem I had, fortunately I found the technique for debouncing a switch somewhere else in the forums right before the show was to open.  If PIN6 is high long enough for the code to pass through

Check_Trigger:
  PAUSE 5
  timer = timer + 5 * Trigger
  IF timer < 200 THEN Check_Trigger

more than 4-times then control of the program is passed to step 1. Do I have this right?

I did not account for the amount of time it takes to send the information. That was probably my undoing.

I noticed you did not use a subroutine(s) for fading the FC-4. Is there a specific reason for this? One of the problems I had was the size of the programs entered on some of the Prop1 microcontrollers.

Again? thanks for the help.


JonnyMac

The debounce routine forces the trigger input to be solid for 0.2 seconds to make sure an electrical glitch/noise in the environment doesn't cause a false trigger.  We saw a lot of false trigger problems this past season when users weren't debouncing simple digital inputs we recommend it all the time now.  Since a haunt can have a lot going on electrically, and our trigger wires sometimes have to snake through the environment so debouncing is a good idea.

There is a trick to the code.  The alias called Trigger is mapped int PIN6 so it can only have a value of 0 or 1.  When the trigger is not closed it will be zero and the value in timer will be cleared as anything multiplied by zero is zero.  When the trigger is active the value is one and the value of timer is not modified.  The "+5" matches the PAUSE 5 statement in the loop so the comparison (< 200) matches the actual debounce timing.

Before I posted the program above I actually did have a version that put the fading in a loop -- this cause the code space used to jump from 59% to 65%.  Why?  Well, every fade requires four variables and reloading these variables for every call of the subroutine used more program space than using the inline SEROUT statements with constants.
Jon McPhalen
EFX-TEK Hollywood Office