Monday, July 23, 2012

Super RGBW Light



I bought this awesome triple-emitter monster light when I was in China at the SEG market in Shenzen. I think it’s a TrustFire TR-500. I couldn’t leave it in its stock “500 lumen” configuration (which is definitely a lie – I measured emitter current at 700mA, which, from the XR-E datasheet, should come out to 3 x 1.70 x 87.4 = 446lm for Q2 parts, and that’s just emitter lumens. Probably around 300 out the front). The first thing was to up the drive current. The stock driver is a boost converter to run 3 series emitters (~9.3V) from 2 18650 cells (~8V). Luckily the main FET still had its markings intact, so I could look it up. It was a surprisingly oversized part with a 50A rating, so I just replaced the current sense resistor with one calculated to hit 1.5A, and it worked. I used 3 T6-binned XM-Ls in cool white, which should give me 551x3 = 1653lm, and probably around 1200 out the front.


I wasn’t happy with the modes that the stock driver had, so I poked around with the scope until I found the pin on the (unmarked) microcontroller that was doing the PWM. They put a big 8-pin micro on there, so I didn’t want to just remove it in case it had some functions other than the modes, so I just cut the PWM pin. From there I just steal 5V from its power pins and run my own PWM into the previously-connected pad on the board.

Plain white light isn’t quite awesome enough, so I needed to add red, green, and blue. I wasn’t willing to give up one of my XM-Ls for a color multi-die emitter, so I milled spots for the extra emitters in the gaps around the edge of the reflector piece, and drilled wire conduits down to the back of the reflector. There wasn’t enough room to put any kind of optic in there. I had to cut out some tiny circular star boards from full-sized ones.

 There was enough room inside the driver cavity to add my own board above the stock driver. I used one of my simple flashlight boards that has an 8-pin micro (PIC12F615), 4 FETs, and 4 current-limiting resistors. For this light I only use three of the FETs and route PWM from one of my micro pins down to the driver board to run the white LEDs.


The color LEDs are a royal blue XT-E and red and green XP-Es. There was a ton of wiring coming out of the back of the reflector but I managed to fit it. I wrapped my added board with electrical tape to prevent shorts. I had all kinds of problems with shorts on the XM-Ls that I fixed with a bunch of carefully cut kapton tape on the underside of the reflector.

The finished product came out great. The code is a modification of my flashlight driver code that I use with color MC-Es, so some of the modes are hilarious with the white so much brighter than the colors. Mode selection is done with a half-press on the switch, and it times out after about 4 seconds and reverts to the first mode. Here are the modes:


High white – the 3 XM-Ls run at 1.5A
Low white – 3 XM-Ls at 10% duty
Low red – the red at 25% duty
RGB stunner – my imitation of the DHS Dazzler. Strobes R, G, B, and combinations at randomized time intervals
Color shift – gradually fades through colors made from combinations of R, G, and B
Color freeze – pauses on a color selected in color shift mode
Firelight – mixes white, red, and green to create light that flickers and imitates fire light
Red –
Green –
Blue –
Police – alternating strobing white and blue
Red beacon – briefly blinks red about twice a second
All on –

Here’s the code. A side note on software: This uses a neat trick I developed for flashlight drivers—instead of the normal means of detecting power loss to cycle modes (with a diode and a big cap), I use RAM retention. When each mode is entered, a RAM location is written with a value that will send the light to the next mode. When power is lost, the micro stops running when its cap drains below 1.8V. RAM is retained until 1.0V, and the power draw is miniscule once the oscillator stops, so this RAM location stays valid for quite a while. When the micro boots up as power is restored, it checks the RAM location for the direction to go to the next mode. If power is left off for a while, the RAM location gets wiped and the micro starts back at mode 0.

Thursday, July 19, 2012

Unnamed Buggy Project: Part 1, RC


I came across this amazing buggy kit made by Tamiya and got one on eBay for about $20 shipped. It has turned into a project without any specific goal beyond doing something cool with the buggy. I think I may do something robotic with it down the line, but the first thing I did was turn it into an RC car. The kit comes with all the mechanics including the drive motor and gearing, but nothing else, so I did the steering actuation and all the electronics from scratch. Here’s the assembled kit (minus the battery holder):



I made some PCBs a while back for random RC projects, so I had this remote control board that takes a standard joystick (the ones used in game controllers) and a Nordic 2.4GHz radio board, all run by a PIC16F1823:

The whole remote assembly worked out really well with a CR123A holder glued on the bottom. I kept the code on this side generic so I can use the remote with different vehicles (I have some helicopter and airplane projects in the queue). The remote just transmits a byte each for the x and y position of the stick, 4 times a second. 

I designed the receiver board for any simple vehicle with one drive motor and one steering servo. It has a PIC16F1823, a connector for the radio board, an H-bridge to run the drive motor, and a servo connector. There’s also a FET that can switch on a load for some other simple function if the vehicle needs one.


The board on the receiving end does all the handling of the joystick inputs specific to the vehicle. In this case it puts the joystick’s y position directly into the variable that runs the H-bridge. This part of the code is ported from the UAV code; it uses timer interrupts to create a PWM signal on two separate pins from a pitch variable, scheduling interrupts instead of using delays so it doesn’t tie up processor cycles. A second timer interrupt generates servo control pulses which are set by the joystick's x position.


That huge electrolytic cap is one of many modifications I had to do to make things work with the big drive motor. It turns out everything goes to hell when you try to run big DC motors on a system with sensitive digital parts. I kept having the whole board lock up when I throttled up the drive motor. The scope showed me I was getting huge spikes on the 3V supply when the brushes in the motor disconnect. To make things work I had to up the capacitance, add a TVS, and put a blocking diode in the connection between the battery and the top side of the H-bridge. Finally things worked:

Back to mechanics. The buggy kit came with this great steering & suspension linkage for the front wheels. It wasn’t so straightforward to add a servo to actuate the steering because of the suspension—the link bar travels up and down as the suspension moves. After sleeping on the issue, I realized that I could make the servo rotate up and down on the same axis that the suspension does.  This also eliminates the need to slot the servo horn because now the servo can ride up and down to account for the change in link length (it’s no longer a slider crank). Shapelock made quick work of this:




The last part is a piece of music wire to link the bar to the servo horn. 



The steering worked out great, plenty of control resolution and a full range of motion on the wheels.



The drive motor didn’t work out so well. After all the modifications to take care of the electrical spikes, the system still just barely worked. I took measurements of the motor and found that it has a ridiculously low coil resistance and relies on the internal resistance of alkaline batteries to operate. I was definitely torturing my little SMD FETs and the lithium polymer battery. Down the line I’ll have to make a specialized motor driver with bigger FETs, current limiting, and a starting capacitor to kick it into motion.

Instead of wait until I find time for all of that, I decided I just wanted to drive it today, so I cut the connection that feeds the top of the H-bridge and ran the drive motor from a separate alkaline battery pack. This certainly isn’t permanent, but I got to have fun driving it around:



I have all kinds of ideas to put into this down the line, so this post is just part 1. Here’s code for the transmitter and the receiver

Sunday, July 8, 2012

Remote Chairer


This is a fun little prank I threw together last week at work. Here’s the back story: our group at work has a little game where we try to covertly hit the lever that raises/lowers the chair while the other guy is sitting in it. This is called “chairing” someone. I decided it was time to take it to the next level, so I made this little device to pull the lever under remote control.

The actuator is a little winch made from one of these awesome little geared motors I found on eBay. A plastic tube from a pen is the spool, and a frame made from music wire takes the force off of the gearbox bearing. The line is 30lb Spectra cord.

The control board is something I threw on my last PCB order as a space filler, with no specific plans for using it. It has an H-bridge, an 8-pin microcontroller, and a spot that fits a three-pin IR receiver. I populated it with a PIC12F615 and an IR receiver that was taken from one of my helicopters’ original control board. The whole thing was powered by a little lithium polymer foil pack.

The code is really simple, it just watches for a simple IR signal with a specific on/off time and then actuates the motor in one direction.

I quickly taped and zip-tied the pieces onto my coworker’s chair when he got up for a minute, and then dropped his chair with the remote while still sitting at my desk. Hilarious and worth it. I didn’t get a video of him getting pranked, but here’s a video of it actuating the lever:

Here’s the code for the receiver and the transmitter