May 04, 2024, 07:28:57 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.


HC-8+ Programming Template -- Updated January 7, 2016

Started by JonnyMac, June 17, 2011, 03:46:45 PM

Previous topic - Next topic

JonnyMac

June 17, 2011, 03:46:45 PM Last Edit: January 07, 2016, 10:22:36 AM by JonnyMac
Attached is our latest programming template for the HC-8+, unified for all HC-8+ boards  We suggest you start with this when developing custom applications for the HC-8+.

Important Note: The attached template is in Spin, the official language of the Propeller, and is the only language that we use and support. In the future we may support other languages (C, BASIC), but those are not native to the Propeller, hence not as easy to use.

Updated: January 7, 2016

This is JonnyMac's starting template -- it should be yours! <grin>

Note... despite rumors to the contrary, I am human. If you find a problem, post it here and I'll jump right on it. I use the HC-8+ all the time so I'm constantly modifying this template. This version has updated control routines for the AP-16+, HC-8+, and FC-4+.

This unified template works for older (Rev E and lower) boards, as well as the new Rev F boards. You must set the revision letter at the top of the program for the template to behave properly with your board.

Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

April 06, 2012, 09:59:51 AM #1 Last Edit: April 06, 2012, 10:01:41 AM by JonnyMac
With the HC-8+ shipping we're looking forward to working with our customers to show them how to use the HC-8+ as a general-purpose SUPER-CONTROLLER!  ;D

While working on a little demo for someone I added a new method called option_inputs that will return a 4-bit value from the OPTION switch.  You may be wondering why it wasn't there from the jump.  Well, the HC-8+ template we've provided is the routines we use in the operational HC-8+ code -- good news for you is that every method is fully vetted.

In the HC-8+ we don't use the option inputs as a single value.  On start-up we check the SM switch to see if the user is wanting EFX-TEK (SM = OFF) or DMX (SM = ON) mode.  If this switch is on the HC-8+ loads the DMX receiver and proceeds to the DMX operational code.  If the SM switch is off the HC-8+ loads a standard serial driver in single-wire mode and sets the baud rate based on the BR switch and runs the EFX-TEK operational code.  In the command parser the A1 and A0 switches are used to check the address bits.

As ever, details are important.  What we want to convey is that the HC-8+ gives you the computing/processing horsepower to do the kinds of things that you've wanted to do with some of your advanced props.

Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

April 19, 2013, 03:35:11 PM #2 Last Edit: October 19, 2015, 02:31:30 PM by JonnyMac
(NOTE: Latest code is attached to the first post in this thread)


When we came out with the EZ-8 a few years ago customers were thrilled at its ease-of-use and simple interface that provided a lot of information through a bi-color LED that could be of, red, green, yellow, or flash. Since that point we have put a bicolor LED on every "smart" product.

While working on the EZ-8+ code I created a background cog that debounces all the inputs and handles the LED -- just like I used to do in the interrupt of the original SX code. The difference is that with the Propeller, it's easier to code and I can flash between colors in the background; that's right: set and forget LED control.

In the attached template/demo you'll see that the set_rgled() method requires four parameters now. This lets it flash between two colors if desired. For solid colors, use the same color in both color slots. For flashing, make them different. Each color gets its own timing in milliseconds so you can flash the LED any way you want, and other than the call to set_rgled(), this doesn't take any energy away from your foreground program.

Enjoy!

Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Interesting twist to the programming template Jon.

I just noticed this twist or better a coding trick of listing the variables.

pri led_switches |  {
}  t, ledphase, phasetimer, rgtimer,                            {
}  digins, ttllast, ttlms, dmxlast, dmxms,                      {
}  optlast, optms, check                                        { end of local vars }

I knew there was another way to list the variables other than the normal way by listing them one after another on one line when you have a bunch of variables and you are showing it without me even asking. Thanks for sharing :)
William Stefan
The Basic Stamp Nut

JonnyMac

April 20, 2013, 07:26:53 AM #4 Last Edit: October 19, 2015, 02:30:21 PM by JonnyMac
Using bracketed comments like that is really handy -- it allows you to insert comments in the middle of code, too.

One usually doesn't have that many local variables. This code, though, is specific to the HC-8+ hardware hence it didn't make sense to pull it out as a separate object -- though that could be done, too. In the latter case the variables would be global to the object only, and method calls would be required for each of the elements.

As my acting coach, the late Cliff Osmond, used to remind us: there are many roads that lead to Rome.


Update 19 OCT 2015 -- I have modified that section of the code to minimize local variables as this reduces stack size requirements for the background cog.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Latest update is taken from our Rev F production code and has been tested on Rev E ad Rev F boards.

Do not ignore the PCB_REV setting -- if you leave it at "F" on an "E" PCB, the outputs will not operate.
Jon McPhalen
EFX-TEK Hollywood Office