Gandalf's Staff With GreenPAK™

by GreenPAK™ in Living > Toys & Games

12 Views, 0 Favorites, 0 Comments

Gandalf's Staff With GreenPAK™

cover.png

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 Instructable describes a project that is called “Gandalf’s Staff”. It comprises a pulsing RGB LED at the end, controlled by an SLG46620V CMIC, and a 3-axis accelerometer sensor.

Below we described steps needed to understand how the solution has been programmed to create Gandalf's staff. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to design the device.

Color Changing Circuit

1.png
2.png
3.png

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 was 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.

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 GreenPAK Designer.

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

4.png
5.png

Each of the LEDs has 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 the 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.

Conclusion

Using an 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!