Introduction: Wizard Staff With GreenPAK & LEDs
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 how to create a wizard staff that changes colors when it is hit to the ground and blinks at different speeds at it is rotated. It comprises a pulsing RGB LED at the end, controlled by a SLG46620VCMIC, and a 3-axis accelerometer sensor.
You can go through all steps to understand how the GreenPAK chip has been programmed to to control the staff. However, if you just want to easily create the staff without understanding all the inner circuitry, download GreenPAK software to view the already completed Wizard Staff GreenPAK design file. Plug your computer to the GreenPAK Development Kit and hit program to create the custom IC to control your Wizard Staff. Once the IC is created, you can skip to Step 4.
The next steps will discuss the logic that is inside the GreenPAK Wizard Staff GreenPAK design file for those that are interested in understand the internal circuitry.
Step 1: Step 1: 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. 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.
Step 2: Step 2: 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 the GreenPAK Designer.
Step 3: Step 3: 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
Step 4: Step 4: Assemble the Staff
Get a PVC pipe that is the height of the staff you want to create. Wrap masking tape around it to create some bumps and texture to the staff. Wrap more masking tape at the top of the staff so that it can hold the main bulb. The IC should be connected to this accelerometer board a battery and LED. You can use the detachable GreenPAK socket for easy access to the chip pins if you do not want to make a separate PCB. Put the LEDs into clear Christmas ornament and glue it to the top of the staff. The GreenPAK IC and batteries can be masking taped to the side of the staff so that it is concealed and is securely set close to the LEDs that it is controlling.
And you're done! Move the staff around and tap it on the ground. Spray paint the masking tape if you'd prefer it to be a different color. This wizard staff is a fun accessory to make and can 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!
For more complete instructions on making this staff with additional design considerations, download the Wizard's Staff App Note.
We have a be nice policy.
Please be positive and constructive.