AN-1130 Gandalf's Staff with GreenPAK™

Have you ever wanted to be a wizard that has a cool staff with glowing magic crystals? Sorry to break it to you but there is no such staff. There is however a way to make something fairly similar using GreenPAK.

This application note describes a project that is called “Gandalf’s Staff”. It comprises a pulsing RGB LED at the end, controlled by a SLG46620V CMIC, and a 3-axis accelerometer sensor.

Color Changing Circuit

For Gandalf’s staff an RGB LED has been used to allow the color to have 4 possible variations: red, blue, green, and white. Each of the four LEDs that are used were attached to three separate pins at their cathodes and were tied to the VDD at their common anodes. A simple state machine, made with D flip-flops and lookup tables is designed to cycle between the four colors. The A’ LUT configuration truth table is shown in Fig. 2.

Gandalf’s Staff A’ LUT truth table
Figure 1. Gandalf’s Staff Figure 2. A’ LUT truth table

The state machine is clocked by an analog comparator tied to the z axis of the accelerometer. Since there were problems being faced with the state machine cycling through multiple colors (rather than one at a time), the output of the analog comparator was de-bounced with a rising edge detector (P DLY0) and a 96.064 MS delay (CNT3/DLY3) before it went to the CLK of the D flip-flops. Refer to Fig. 3 for a view of the circuit in Green PAK Designer.

Color changing circuit design

Figure 3. Color changing circuit design

Pulse Control Circuit

The LED pulse in Gandalf’s staff is produced by a triangle wave made inside the PAK. It is controlled by FSM/counters connected to a PWM. The first FSM counts to a set number. It then clocks the second FSM via the Oscillator (OSC) and produces a longer saw-tooth wave. The saw-tooth wave is refined into a triangle wave by an inverting matrix. This inverting matrix is made with an XOR gate that takes inputs from the digital comparator, the second FSM processed by an edge detector and a toggling D flip-flop.

In order to control the pulse speed by the accelerometer, a differential input programmable gain amplifier (PGA) was used. It was able to send an analog signal to the ADC (Analog to digital converter). Since the PGA only accepts voltages up to 1V, 200kΩ trip pots were used to divide the x and y outputs of the accelerometer to values below 1V. The ADC outputs an 8-bit code to the FSM which is read as FSM data. The highest 8-bit value is sent when the staff is upright and that results in the slowest pulse.

As the staff is tilted, a lower 8-bit value is sent to the FSM which results in a faster pulsing speed until it is upside down and at its highest frequency. See Fig. 5 for a view of this circuit in Designer.

LED Output Circuit

Each of the LEDs have three cathode inputs, and assigned to each of these inputs are 3-bit NAND gates. The triangle wave output of the pulse control circuit is sent to each of the NAND gates. Each NAND gate also takes an input from its correlating output of the state machine and the enable from Pin 2. When the enable and the correlating output from the state machine is on, the LED flashes to the pulse of the pulse control circuit. A NAND gate has been used because the LED has a common anode (and separate cathodes) to determine the color to be output. To fully light up one of the colors, the cathode needs to be set to ground. The enable was included in the output circuit to allow the turning off of the LED. Refer to Fig. 4 for a view of the circuit in GreenPAK Designer.

LED output circuit design

Figure 4. LED output circuit design

Pulse control circuit design

Figure 5. Pulse control circuit design


Using a SLG46620V CMIC, a fun accessory can be made to accompany a costume for a Halloween party, Comic-Con, or whatever occasion that calls for a wizard. This way, even an engineer can prove to their friends that they too can have some fun!

About the Author

Name: Gino Castillo

Background: Gino recieved a B.S. in Bioengineering with a minor in Electrical Engineering at Santa Clara University. Presently he’s working with Configurable Mixed Signal ICs (CMICs) and their applications.




See full list of Application Notes