November 27, 2024, 03:26:30 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Simple prop/scene control HC-8+

Started by Laytonk, February 10, 2015, 05:52:05 PM

Previous topic - Next topic

Laytonk

Simple prop/scene control HC-8+, Hi guys looking for some programming help, I know that I can use vixen and an HC-8+ for this but would like to dig deeper and learn spin coding.
Hardware:
HC-8+
AP-16
FC-4
4 spots
1 strobe
2 valves
1 fog machine with hacked remote (would like to move it to DMX control in the future).


Scene #1
Main
Ambient sound track from AP-16
Light ch 1 FC-4 at 60 (0 - 255)
Light ch 2 FC-4 at 60 (0 - 255)
Lights 3 & 4 GC-4 off or 10 (0 - 255)
Trigger IN0 (mat switch or photo beam)
Then
Lights ch 1 & 2 fade to 10 (0-255) in 2 seconds
Light ch 3 ramps up to 100 (0 - 255) in 3 seconds
Light ch 4 ramps up to 60 (0-255) in 3 seconds
Valve OUT 0 | high (prop moves)
Strobe OUT 2 | high (strobe on prop)
Sound play file AP-16
Fog OUT 3 | high
Valve OUT1 | high (prop spits water)
Wait 5 seconds
Fog OUT 3 | low
Valve OUT 1 | low
Wait 3 seconds
Lights ch 3 & 4 FC-4 fade to 10 (0-255) in 1 second
Strobe OUT 2 | low
Valve OUT 0 | low
Stop sound AP-16
Wait 2 seconds
Light ch 1 FC-4 ramp up to 60 (0-266)
Wait for trigger 2 (IN1)
Resets to main

I am not sure if I should run each AP-16, FC-4 and Fog in its own cog, as for the fog I could use that cog just like a fog timer and as for the FC-4 I could make better use of cross fades.
Thanks for all your help. 

JackMan

Not trying to talk you out of learning Spin but I'm pretty sure you can accomplish this with a Prop-1 in place of the HC-8+.

Laytonk

I have been using both Prop1 and 2's for a while  but I found myself in a position where I have to replace them. I know how to program the prop1/2 but since I have to replace them why not learn something new.

JonnyMac

I'm happy to write the program for you.  Please understand:

-- I don't know what this means: Light ch 1 FC-4 at 60 (0 - 255)
    * 60 seconds, 60 minutes, level 60?
    * the root of specification is specific
-- We need more details; "ramp up" means nothing without a time element
-- The program will look bigger than you think

Here's the deal; the BASIC Stamp made things simple because it was very limited in what it could do. The HC-8+ allows us to build on language concepts and create a lot of re-usable code -- minimized cut and paste.

Spin is a little more involved, but not difficult to learn, and it provides you with a HUGE horespower boost with the Propeller over what we can do with controllers like the BASIC Stamp and Arduino.
Jon McPhalen
EFX-TEK Hollywood Office

Laytonk

Thanks Jon, I'm eager to learn, but don't want to go down the wrong path and get frustrated, just looking at a simple model to work from and explore. I think I have corrected the issues from above.

cene #1
Main
Ambient sound track from AP-16 wav file at 50% volume
Light ch 1 FC-4 at 60 (0 - 255) or 24%
Light ch 2 FC-4 at 60 (0 - 255) or 24%
Lights 3 & 4 FC-4 at 0 (0 - 255) or 0%
Trigger IN0 (mat switch or photo beam)
Then
Lights ch 1 & 2 fade to 0 (0-255) or 0%  in 2 seconds
Light ch 3 fade up to 100 (0 - 255) or 39% in 3 seconds
Light ch 4 ramps up to 60 (0-255) or 24% in 3 seconds
Valve OUT 0 | high (prop moves)
Strobe OUT 2 | high (strobe on prop)
Sound play file AP-16 wav file at 100% volume
Fog OUT 3 | high
Valve OUT1 | high (prop spits water)
Wait 5 seconds
Fog OUT 3 | low
Valve OUT 1 | low
Wait 3 seconds
Lights ch 3 & 4 FC-4 fade down to 0 (0-255) or 0% in 1 second
Strobe OUT 2 | low
Valve OUT 0 | low
Stop sound AP-16
Wait 2 seconds
Light ch 1 FC-4 fade up to 60 (0-266) or 24% in 1 second
Wait for trigger 2 (IN1)
Resets to main

Thanks

JonnyMac

No worries, the devil is always in the details -- and the spec side is always the hardest part (when you're not writing your own code). The effort is worth it, though; once there is a spec that you and I both understand, I can write you a program that matches it. This will provide a great guide for exploring updates and enhancements on your own.

When you say FC-4 you really mean FC-4+, correct? The original FC-4 does not have the horsepower to do simultaneous fades, the FC-4+. The reason I ask is this section:

Lights ch 1 & 2 fade to 0 (0-255) or 0%  in 2 seconds
Light ch 3 fade up to 100 (0 - 255) or 39% in 3 seconds
Light ch 4 ramps up to 60 (0-255) or 24% in 3 seconds

I think you want these fades to happen at the same time, right? With the FC-4+ we use one of the processors as a fade control engine which allows it to simultaneous fades -- you can have different fades happening on every channel at the same time! As I told you in our off-line conversation, we have a small review to do on the FC-4+ before putting it into production. We've built several units and all work fine so we don't expect any trouble.

Jon McPhalen
EFX-TEK Hollywood Office

livinlowe

Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

February 11, 2015, 04:29:02 PM #7 Last Edit: February 11, 2015, 04:31:20 PM by JonnyMac
It's a fun feature, and something that we have always had in the production software of the HC-8+ which is capable of doing eight simultaneous fades -- all at difference levels and speeds. The "fade manager" is used in the FC-4+ as well, though we only need half of its capability.

Funny, not many people use the HC-8+ as a DC lighting controller, but that was its original intent (replace DC-16). The fade manager code is available to everyone; it's in our code base and probably posted several places in the forums.
Jon McPhalen
EFX-TEK Hollywood Office

Laytonk

Yes we will be using the new FC4+ when it's available .

Thanks

JonnyMac

February 11, 2015, 11:54:30 PM #9 Last Edit: February 12, 2015, 10:11:11 AM by JonnyMac
I still thin there may be some missing details, but here's a start. This is what the main routine of the Spin code looks like. As you can see, it's very readable.

Instead of HIGH 0 you write outs.high(0). The reason for this is that the outs library is advanced and can allow you to set your basic outputs to any level between 0 and 255. This syntax is called dot notation. the name of the library comes first, then a dot, then the method (subroutine -- usually with parameters). The file that supports the outs code can be used with any project that needs those features.

pub main 

  setup_io                                                       ' configure HC-8+ io pins
  setup_objects                                                  ' configure objects used

  repeat { main loop }
    ap16_volume(%00, 50, 50)                                     ' set volume to 50%
    ap16_sfx(%00, 0, 0)                                          ' play SFX00 (ambient for prop) in loop
    fc4_reset(%00)                                               ' reset FC-4+
    fc4_level(%00, 0, 60)                                        ' ch0 to 24%
    fc4_level(%00, 1, 60)                                        ' ch1 to 24%

    repeat                                                       ' wait for trigger on IN0
      if (ttl_pin == 0)
        quit 

    fc4_fade(%00, 0, 60,  0, 2000)                               ' fade out ch0 in 2s
    fc4_fade(%00, 1, 60,  0, 2000)                               ' fade out ch1 in 2s
    fc4_fade(%00, 2,  0, 60, 2000)                               ' fade up ch3 in 2s
    fc4_fade(%00, 3,  0, 60, 2000)                               ' fade up ch4 in 2s

    outs.high(0)                                                 ' prop moves
    outs.high(2)                                                 ' strobe on
     
    ap16_volume(%00, 100, 100)   
    ap16_sfx(%00, 1, 0)                                          ' play SFX01

    outs.high(3)                                                 ' fog on
    outs.high(1)                                                 ' spitter on
    time.pause(5000)                                             ' wait 5s

    outs.low(3)                                                  ' fog off
    outs.low(1)                                                  ' spitter off
    time.pause(3000)                                             ' wait 3s

    fc4_fade(%00, 2, 60,  0, 1000)                               ' fade out in 1s
    fc4_fade(%00, 3, 60,  0, 1000)

    outs.low(0)                                                  ' prop stop
    outs.low(2)                                                  ' strobe off

    ap16_reset(%00)                                              ' stop AP-16+
    time.pause(2000)

    fc4_fade(%00, 1,  0, 60, 2000)

    repeat                                                       ' wait for IN1
      if (ttl_pin == 1)
        quit   



Something very important to note: Spin uses white space to define code blocks (like under repeat) -- you must be clean about your formatting. This is a good habit in any language.

Note, too, that there are no GOTOs or GOSUBs. GOTO is not required. Everything else is an implicit GOSUB.

Finally... this program is only using 3 of the Propeller's 8 cogs:
-- main Spin cog
-- pwm driver for HC-8+ outputs
-- serial driver for coms with AP-16+ and FC-4+

You could easily add DMX or other features.
Jon McPhalen
EFX-TEK Hollywood Office

Laytonk

Thanks this looks like a great starting point for learning.