In part 1 of this LED saber series, we talked about the project's goals, schematics, components, and safety. In part 2, we'll assemble most of the electronics sub-systems: the power harness, power converter, and speaker system for audio output.
I chose the Zippy battery pack because I’ve used them before, they were on special, and the listed dimensions indicated it would just fit inside the PVC tube. (It was actually 0.5mm too big and I had to score out some tracks in the container tube, but it did fit eventually.)
A fairly standard "quadcopter" battery with XT-60 connector and balance leads.
Remember that batteries wear out, so expect to collect them over time.
Feel free to substitute another brand or shape, but try to maintain the overall specs, which is a 3-cell (11.1 V) pack at about one Amp-hour (1000mAh) and 15C discharge rating. You could also go with 850mAh, but much less than that and you'll have disappointingly short run times. Too big and it gets heavy and hard to fit.
A full-blast white 1m LED strip pulls 43 W, but the software limits the total power to 40% of the maimum to prevent the blade melting. At 11.1 V, that’s about 1.5 A just for the LED strip, and when we factor in the other sources of power consumption, we can expect about 30 minutes of run time from the Zippy.
It’s possible to go down to a 2-cell (7.4V) battery, but remember the current draw will increase so you will need a higher-C-rated (heavier wired) pack and the converter efficiency will drop. And you have to modify the code to change the safety cutout. Not worth it if you ask me.
I'm also assuming you have an appropriate charger. If not, I'd recommend this one from Hobbyking, which will do exactly and only what we need in this case: balance charge a 1000mAh LiPo at under 1.5C.
DC-4S charger, $10 from Hobbyking. Simple, foolproof, and matched to the recommended battery. Also a cell tester. Image courtesy of Hobbyking.
Another option is the Turnigy Accucell-6 50W charger. This one is more versatile, and it can work off lower-voltage DC input.
Keep in mind that you need a DC power source for these chargers; they don't just plug into a wall outlet. You want 14-16V, to make sure that you can give the LiPo a full 12.6V charge.
We need to get power out of the battery and into the DC converter. That can be as simple as a plug and two wires or as complicated as my build, which includes a power switch and a voltage readout.
I’d recommend adding the switch because being able to guarantee a fast and sure power-off is a good idea around LiPos in case the controller crashes. You don’t want an unplugged battery connector flopping around in the hilt either, where it can short on many things which it will instantly destroy. But it’s up to you—your battery might be really easy to remove and switches are bulky.
These parts can be pre-assembled and then inserted into the case through the hole for the switch.
Note well that you'll need a heavy-duty switch (preferably rated 10 Amps) because, while the voltage is low, there’s a lot of current. I used a reclaimed mains toggle switch from an old desktop PC power supply and cut down the pins to fit better. AV switches also look cool and some have 12V lights built in. Just don’t use a small-signal switch or it will burn, literally. (This is the reason switches are omitted from most multirotors.)
Go nuts on the heatshrink tubing here. You want every part of the connector and switch terminals insulated. There should be no possibility of anything shorting against them with aggressive use. Use a bit of silicone sealant or hot glue if you like.
I used bullet connectors between the harness and the power converter but, again, that was mostly because I had them on hand. You can use whatever works and fits through the switch hole. I may explore using XT-30 connectors in future builds.
The basic concept here is as follows: Random battery power comes in and clean 5V power comes out, plus a microcontroller-safe voltage sense signal.
For the main power conversion job, we use the Hobbyking YEP-20 (also known as the MTTEC KETO HV BEC V2) which can provide a constant 10Amps at 5V with no extra heatsinking or airflow. This provides a good margin over what the blade can consume and a little spare capacity if we want to fit a longer blade later on.
The Hobbyking YEP-20 SBEC—compact and powerful
In my tests, it took a 30-minute run before the converter started getting warm on the 1-meter strip. Remember that the “20 Amps” figure is only considered a burst rating, but this little unit is pretty nicely made.
If you can’t get this particular part, look for any SBEC (Switch-mode Battery Eliminator Circuit) with the same approximate ratings—at least 10-15 Amps at 5V. Be sure the output voltage is below 5.5V; some SBECs are intended for driving high-current servos that prefer 6V, but we don't want 6V. That would kill the LED strip.
I stripped the heatshrink tubing back from the ends of the YEP-20 and soldered new wires to the board, which also gave me an opportunity to remove the voltage selector jumper pins and permanently set it to 5V by bridging the pads with solder.
Converter voltage output permanently set to 5V and pointy pins removed.
I did that in order to save an extra centimeter of length and to prevent the possibility of those pointy pins jabbing into the sound module somehow—but I’m paranoid about that kind of thing. I’ve learned you can always use the extra space.
I added bullet connectors at the other end in much the same way to match the power harness
Battery Voltage Sensor
Next, we need to add the voltage sense circuit. I used the pre-made FrSky Battery Voltage Sensor (check out its manual here) but a pair of resistors will do the same job. If you’re already buying the rest of the parts from HobbyKing, you might as well get this for a couple of dollars (if it's in stock) and save yourself some trouble. It's compact and it comes with extra heatshrink, nice wire, and a servo connector.
FrSky battery voltage sensor. Image courtesy of Aloft Hobbies.
Connect the “GND” and “4S” inputs to the main power inputs from the battery. The “Vin” port is labeled from the perspective of the telemetry receiver we don't have—it’s actually the sense voltage output.
If you can't get hold of this particular item, it's really just a 5:1 resistor divider network. A 10kΩ and 2kΩ resistor pair will do the job, as will any similar ratio that sums to between, say, 5kΩ and 100kΩ. The crux is that it just needs to divide the maximum possible battery voltage to less than 5V for the Arduino analog-to-digital input. (And it shouldn't shunt too much current, so do your math!)
Don't forget that a 6:1 sensor ratio requires a 5:1 resistor ratio. You'll need to recalibrate the firmware if your ratio is any different.
Example of a voltage divider circuit that can replace the FrSky module. A 6:1 sensor ratio requires a 5:1 resistor ratio.
I tapped the incoming battery voltage from the +Vin solder pad and got GND from the other leg of the large capacitor that straddles that end of the board.
Note that it’s very easy to bridge these connections (I did. There’s no solder mask over the edge!) and that would be BAD, so do continuity checks and a visual inspection before powering up again.
Take one of the servo extension cables and cut it about half-way. We want the larger receptacle with the pins inside, not the smaller ‘plug’ that fits inside it. But save that for later!
Strip, tin, and connect the black and red wires to the GND and VCC output of the SBEC respectively. Now connect the final white wire to the output of the voltage sensor.
Voltage sensor taps legs of main input capacitor. Power and sense signal come out on standard servo connector.
Blade Power Cable
We also need to run power to the blade. The LED strip should come with matching high-current connectors for both ends. So we can steal the "socket" end and connect that to the converter output using some extension wires made from good thick 20AWG (or better) silicone-insulated wire.
Use enough wire so that the extended cable is about as long as your entire hilt—probably about 45 centimeters. Assume it will need to reach all the way from the pommel and barely hang out the 'emitter' end so the blade can be connected and then inserted. The same 10cm slack will allow the hilt to be 'opened' once the blade is inserted. Don't worry, it isn't too hard to tuck into a corner.
Use a hook-and-twist splice. Make little hooks from the wire ends, hook them together like links in a chain, and then twist the splice. It should be mechanically strong before soldering. Remember how much current will be running through this cable: we want reliable, neat connections here.
More solder doesn't add mechanical strength or conductivity to a joint, just weight. Depend on it as little as possible.
Do not add any other connectors along this path or substitute lesser-rated parts. I originally tried servo connectors and they melted. There was a smell.
I've even made the special LED connector warm at the full rated power of the strip, despite the high surface-area and broad flat pins they have.
The remaining "data" wire from the LED connector goes to a servo plug of about the same length, such as the one that came off the voltage sensor. Both the servo connectors will go to the controller module we'll build in part 3.
Power also goes directly to the high-current LED strip connector where it is joined by the data stream
Test the Power Converter
Use a spare servo plug to wire up your multimeter to the converter for some testing. Be VERY careful that nothing shorts during tests. You’ve got 20 Amps of power available on those wires. Respect that.
Double check everything. Continuity test for shorts on input and output rails. Verify the location of your fire extinguisher.
Make sure your meter is in voltage mode because anything else would be bad. Now connect the battery to the converter via the harness, throw ze switch, and see if the magic smoke comes out.
You should be getting a nice steady 5.2V from the red wire and about 2.1V from the 'sensor' white wire. Black is ground, of course. Everything should remain stone cold.
Keep a record of this voltage sensor measurement and also take a voltage reading from the battery pack at the same time. For example, my readings were 2.16V / 12.6V on a freshly charged battery, giving a 1:5.8 ratio. If your ratio is significantly different from the default 1:6 you will definitely need to modify the firmware before upload.
If that’s all good, our power converter is done. I heatshrinked and then zip-tied the voltage sensor to the side of the YEP-20 and then used liberal amounts of electrical tape to make sure nothing was exposed. The result should be a solid little brick we can put aside for now.
Completed power converter module with bullet connectors added to match the power harness.
The aim of this subsystem is to take the almost-megahertz PWM signal coming out of the Arduino on pin 10 (and none other) and turn it into the movement of the speaker cone. There are a couple of ways of getting there, but I chose to use a class D mono audio amplifier specifically designed for small 8Ω speakers up to a couple of watts.
The completed audio module with the low-pass filter mounted on the amplifier
A “class D” amp is a PWM-based circuit that allows the drive transistors to operate in full conduction or full cutoff; this provides high efficiency in the same way that a switch-mode DC/DC converter is more efficient than a linear regulator. The wires to the speaker should be as short as possible, which is why I mounted the amp directly on the back.
Double-sided automotive tape was used to secure the amplifier to the back of the speaker.
It says "wires as short as possible" in the manual.
Bad things happen if you connect a PWM audio signal to a PWM class D amplifier. Harsh, awful-sounding things because weird aliasing artifacts occur as the two non-synchronized PWM systems interact. We need to smooth the first PWM train out into a nice analog signal level and feed that to the amp to chop up again.
We can do this with three passive components—two resistors and a capacitor—with a classic RC low-pass filter. This is the only required from-scratch electronics in the design. I put the three components on a tiny rectangle of veroboard from Radio Shack (a non-renewable resource now) and then mounted it straight on top of the amp with a pair of connector pins.
The digital PWM audio is smoothed by a low-pass filter before going into the amplifier. The 150Ω resistor improves the interaction between the filter and the amplifier's input circuitry.
In theory, the Arduino output ranges 0-5V (which is far too high for an audio signal) but the audio amp with the volume potentiometer attached seems to divide this down into the correct range by itself. If you use a different amp, you might need a voltage divider on the output of the filter by adding another 150Ω resistor to ground or using a potentiometer.
This amp has differential inputs, but we have a single-ended audio signal, so we hook the negative input to ground and the positive to the output of the filter.
Some already have them, but the breakout board I used needed a 10kΩ potentiometer for setting the maximum volume. (A 4.7kΩ potentiometer will also work.) A small trimmer pot is fine here since, once set, we’ll never have to change it—the software has volume control.
Silicone sealant goo was added to insulate the back of the low-pass filter board, and provide some strain relief. Later, hot glue was added under the potentiometer.
For the speaker, I re-used the 40mm diameter speaker that came in my old (broken) Hasbro lightsaber. It seemed appropriate.
There are smaller 28mm ‘bass boost’ speakers which look great (the Custom Saber Shop has them) and replacement laptop speakers are interesting because they have some unusual rectangular shapes that might fit slimmer builds and go further up the hilt.
The 40mm speaker cone was perfect in that it just fit into the 32mm PVC end-cap "pommel" and was held firmly in place by the equal-sized pipe. (If that sounds strange, yeah. PVC pipe sizes are more historical than dimensional.)
While various other ways are possible, one common method of driving speakers I do not recommend in this case is the simple “direct transistor drive” that effectively turns the Arduino, itself, into a class D amp. Perhaps you can get away with this, but you won't have the safety features and improved sound quality provided by a more professional solution. Find a nice audio amp—it's what they do.
We're half-way done! And it gets easier from here. We've just got the controller and the blade to go.