Step 4: Firmware Functions

Besides the obvious - animating the LEDs, Wave JT firmware does a few things (as of version 1.0).

Regulate Joule Thief output voltage (microcontroller supply voltage)
Firmware monitors the supply voltage by using the A/D converter - instead of connecting one of the input pins to the supply voltage, A/D converter samples built in fixed reference voltage using the supply voltage as the A/D reference voltage. The result is the inverse number of the supply voltage. The A/D result works out to be: 512/supply_voltage. Comparing this number against predetermined threshold to turn on/off the Joule Thief circuit effectively regulates the supply voltage. This voltage is set slightly below the Zener diode voltage of 5.1V to avoid letting the Zener diode shunt the voltage - wasting energy.

Check If the Button Switch is Pushed
The firmware also routinely check to see if the button is pushed. Since the button switch is multiplexed with the pin that controls the Joule Thief, the job is a bit tricky.

The firmware first changes the pin from output to input mode. Which means that the pin becomes high impedance. Put it another way, Joule Thief circuit gets turned off. At this point, the pin voltage should go low, unless the button switch is closed. So the firmware simply reads the pin status, and turns the pin back to output mode. This happens roughly every 8 milliseconds or 125 times/second.

Now the button state is checked against the timer to see if it's held long enough. If too short, the button push is ignored as a noise. If the push is long enough, a counter is incremented to check for single or double taps. Firmware waits for a predetermined period for another button tap. When it times out, an event is created as to single/double tap, or button held down.

Animate the LEDs
Now the most important function of all - animate the LEDs! I use the word animate because Wave JT doesn't just "blink" the LEDs, but changes LED brightness smoothly up and down in full 8 bit levels.

The animation engine works in a parametric manner. It takes a few parameters to specify; base update rate (speed), the direction of the movement (left/right), threshold level that one LED triggers the adjacent LED to start changing brightness level among other things. By changing these parameters you can create endless patterns of animation.
<p>Could you please the dimensions of the assembled unit (with battery)? <br>Thanks.</p>
Dimensions are:<br>L: 55mm<br>W: 20mm<br>H: 24mm<br>
<p>My son is thinking of being Darth Vader for Halloween. How difficult would it be to reprogram this device to smoothly illuminate a string of LED's from one end when a button is pressed, that matches the speed of the effect in the movie, then when the button is pressed again to reverse the animation? Thanks.</p>
<p>Great tutorial.....!! i was practising in stimulation software...but unable to figure out ICSP in schematics ..? </p>
<p>ICSP - In Circuit Serial Programming. This allows you to connect a PIC programmer such as PICKit2/3 to program the PIC microcontroller without removing the IC.</p>
<p>I have the same question. Can I use another 16 pin chip?</p>
<p>I only know PIC16F1824 or PIC16F1823 would work, but there might be another PIC that's similar enough to work...</p>
<p>can you help me how to modify the code for other pic? as i didnt find the pic chip mentioned here. </p>
What does it do? What function does it serve? What action is this device completing that those leds are indicating?
Wave JT creates beautiful movements of light that you can look at forever, while being compact and energy efficient. <br>It's therapeutic and enchanting. But if that's not enough, you can find practical uses such as bike light or Xmas ornament. <br>It's up to your imagination.
Ah ok, thats what I was wondering. It seemed like somewhat of an over complex design to just blink led's. I love the design. Defiantly the most attractive battery discharger I've seen in a long time.
Coolest thing ever!!!!!!!!!
Would it work if instead of using the Joule Thief system (for more power) to just use a USB (5V)?
Would it be possible to get the un-compiled code for the pic? I would like to see how you are ramping up and down the brightness, and I would like to use a different pic controller since I have an over abundance of several others, just not the 1824 or 1823.
I've uploaded the source file. <br>
Damn that's impressive. How do you figure out how to program these?
I'm just learning about joule thief's and I want to power a microcontroller with one. Does your circuit self oscillate because of C1 charging in series(which I don't think is the case)? what does that transistor network exactly do? <br> <br>But my biggest question is, if you are starting and stopping the current through the inductor with the uC pwd, what waveform are you using? PWM, clear timer on compare? <br>
The voltage booster circuit oscillates by itself when SW1 is closed or enough voltage is applied to PWR pin. This&nbsp;circuit is a variation of popular Joule Thief circuit, which uses one transistor and a two winding inductor (much like a transformer) to do the job. My circuit uses two transistors to make use of an easy to find single winding inductor. (The exact workings of the circuit takes way too long to explain - please google Joule Thief...)<br> <br> The microcontroller simply turn the PWR pin on and off to keep the voltage within target. No PWM. I'm using the A/D converter to read the supply voltage of the microcontroller, and turning the PWR pin accordingly.<br> <br>
Can I know which exact model number of the Schottky Diode is being used for this project? Thank you.
It's&nbsp;BAT85 or SD103 type. Sorry I forgot to post that information - now it's added to the instructable.<br> <br> Aki
The power supply now uses the 5.1V zener as a shunt regulator, where the excess power is wasted in the zener. This is wasteful of precious battery current. My wish list would change the zener so it turns on a transistor which then reduces the bias to Q1, regulating the maximum voltage.&nbsp; One of my DC to DC converters <a href="http://watsonspics.blogspot.com/2009/12/v-converter-3v-9v-21gif.html" rel="nofollow">can be found here</a>. But really only one additional transistor is needed.
This is one of the exciting aspect of microcontroller projects. You can simplify the circuit and let the microcontroller take over some of the analog functions.<br> <br> With this project, the Zener diode only comes in to play when the switch SW1 is closed. Microcontroller turns of the base current to Q2 when the voltage is high enough, but lower than 5.1V. This effectively regulates the output voltage of the Joule Thief without letting the Zener to conduct. (Explained in the above chapter.)<br> <br> This method not only saves a few parts, but is also more energy efficient - since there's no current wasted by Joule Thief when there's enough voltage.<br> Thank you for posting your circuit though. Other people looking to use Joule Thief as a standalone DC power supply will benefit from your circuit.<br> <br> Aki
I'm not clear on the electrolytic and the inductor - are those just ranges of acceptable values? I suspect the cap is, but I'm not familiar enough with inductors to be certain.
Yes the values are the range that should work.<br> For inductor I recommend to stay within 47 to 100 uH, but higher values would work ok. Capacitor C2 also can be larger, but larger ones are also physically larger - not good for this project...<br> <br> Aki
Cool work..<br> Referred you to a Question and voted ;-)
Thanks!<br> What question?
<a href="http://www.instructables.com/answers/How-to-switch-between-2-outputs/" rel="nofollow">Here</a> you are<br> <br> A
Your work is, as always, beautiful
Thanks! <br>
Where download the HEX file?
Oops. Will be uploaded shortly.<br> <br>
This look great!!! I will love one (or many) of this, did you sell this? where?, thanks I love all this led thingies too!!!
Thanks!<br> You can purchase the kits and PCBs at theLEDart.com.&nbsp;<br> <br> http://www.theledart.com/blog/wave-jt-kit<br> <br> <br>
As usual, absolutely awesome. Video is fun, and the instructable is precise and educational. Thanks for being a great electronic/microcontroller engineer
Another home run. Very nice work.

About This Instructable


108 favorites


Bio: I am an electronic artist living in Brooklyn, NY. I work with LEDs and microcontrollers to create beautiful objects.
More by ledartist: T962A SMD Reflow Oven Fix/Hack Color Organ Triple Deluxe II Aurora 48 - 48 RGB LED Sequencer
Add instructable to: