How to output 5V from 3.3V MCU?

Big picture: I want to control a LUXdrive 3023 BuckPuck LED driver (3023-D-E-1000) from a Particle Photon (essentially an ARM Cortex M3 microcontroller). The MCU runs at 3.3V. I have tried a few things but fail to get it to work.

This seems like a very trivial problem to me but even here my very basic EE knowledge seems to insufficient.

The LED driver has a control pin where a voltage of 0-5V can be applied to adjust the constant current the driver provides. At 0V it outputs 1A and at 5V it outputs nothing. The 5V can be taken from the driver's own reference pin or supplied externally, in which case a common ground between that external source and the driver's LED ground pin has to be established. According to the docs, the control pin draws less than 5mA.

On the microcontroller side I have a 3.3V PWM output at 500 Hz. The idea is to dim the LEDs by brining the PWM signal to the driver's control pin and essentially very quickly alternate between current and no current output; I could also dim the LEDs by using the microcontroller's DAC to vary the voltage at the driver's control pin, which would cause it to vary the current. But I have read somewhere that LEDs are happier with being run at their designed current rating and insteads switched on/off for dimming purposes.

Anyway, the question is how to get from the MCU's 3.3V PWM signal to the 5V needed for the driver's control pin.

What I have tried so far:

Switch the driver's reference/control pin connection with a FET Using a 2N7000 FET where the MCU's PWM output pin is connected to the gate pin, the driver's 5V reference pin to the drain pin, and the driver's control pin to the source pin.

simulate this circuit – Schematic created using CircuitLab

Nothing was being switched though. I am not sure whether I was not able to open the 2N7000's gate with the 3.3V or whether there is a conceptual problem here.

Bring the 3.3V PWM signal to 5V with an op amp I tried to increase the 3.3V signal to 5V with a LM358 op amp I had lying around. I set the gain to 1.5 with a pair of 330k Ohm and 220k Ohm resistors (giving the ratio 330k/220k = 1.5).

While this dimmed the LEDs, I was not able to fully switch them off, i.e. providing a full 5V at the driver's control pin.

Any tips or recommendations?

• I'm assuming you omitted the 3.3V regulator on your microcontroller board? – Passerby Mar 27 '16 at 19:41
• Yes, I omitted the regulator. I also omitted a switching regulator that converts the 24V to 5V for the MCU (the power supply generates 24V). – Jonas Mar 27 '16 at 20:26

It sounds like the FET may have been the incorrect type (NMOS vs. PMOS) or the 2N7000's relatively high $V_{GS(th)}$ value (at what voltage difference between G and S does it "turn on.") We'd really need a schematic of how it was connected to determine exactly why it wasn't working. But the 2N7000 datasheet states this as 2.1v typically, so there must be a potential difference of at least this much before it even begins conducting from source to drain. (Even then, it's not a linear relationship... FETs can be quite "fun" to get working the way you expect.)

The op-amp idea was a good one, which should have worked, however the LM358 is not a rail-to-rail output type, meaning that the output will never go exactly to each power rail (neither 5v nor 0v exactly.) It may go to 4.65v or something, but not 5v, which keeps the rest of the circuit "on" slightly. There may have been some issue with the resistor values chosen also (such large values can have other, unintended influences on the operation.) If it were possible to slightly increase it's supply voltage, to say 5.5v, this may "correct" the behavior, but this would technically be a hack.

Another way you could get around this, is to use a primitive logic gate, such as a 7400 series gate, as an "intermediary" between the 3.3v logic and 5v signal. If you study these devices, for something like a 74LS04 you'll see that they have an input logic-high transition voltage ($V_{IH}$) of around 2.0v. Which means, if you were to power this from 5v, and feed it the 3.3v digital output, it will happily accept this (it transitions beyond 2.0v) and output 0v and 5v respectfully. NOTE that all other inputs on a 74-series IC must be tied to either Vdd or Vss (+5v or ground) or else it will likely be destroyed. (Inputs must never be left "floating.")

That's great for a digital output, but if you wanted the PWM to be presented as an analog voltage to the LUXDrive, then the solution isn't difficult - just use a simple RC low-pass filter after this logic gate. The low-pass filter should have a very low frequency "knee", ideally the lower the better, so that it blocks as much of the 500Hz signal as possible. The output of this should be a mostly DC signal, linearly proportional to the PWM entering it.

For something like this, I'd play around with LTspice to simulate the low-pass filter and "see" what the output will actually look like. Some experimentation is in order. Then prototype it, and see what the LUXDrive does. Just make sure all voltages are within limits for each device, and always double-check all wiring before applying power.

• Just added a schematic – Jonas Mar 27 '16 at 18:38

You have the basic idea right, but your wiring is off.

simulate this circuit – Schematic created using CircuitLab

In this case, when D1 is On/High/3.3V, Ctrl is pulled down through the Transistor or Mosfet. When D1 is Off/Low/0V, Ctrl is pulled high through R1. Since Ctrl has inverted logic, where 0V = On, 5V = Off, you don't even have to invert your logic in code.

The Transistor can be any common small signal NPN or N-Channel Mosfet. The 2N7000 works, but a 2N3904 NPN might be better in my experience. It's smoother and as a current controlled and not voltage controlled device, works better with a 3.3V source. The 2N7000 should open at 3.3V as it's minimum (maximum) Gate threshold at a current draw of 1mA is 3 Volts, but that's cutting it close.

R1 can be smaller, depending on your needs. 1K to 10K. R2 should be left as 1K just to protect the N-Fet/NPN, and the MCU's pin, from excessive current draw.

• For small, logic-level MOSFETs like the 2N7000, which have a small gate capacitance, R2 is superfluous. – CL. Mar 28 '16 at 7:08
• Thanks Passerby. I will get a hold of a 2N3904 and give this a try. Will report back. – Jonas Mar 28 '16 at 12:50
• @Jonas 2n3904, 2n2222, BC337, 2N4401, etc. The specific part is non-critical, any common small signal transistor works. You're only switching 5mA after all. – Passerby Mar 28 '16 at 17:00
• @Passerby I think there may have been a misunderstanding: Ctrl does not just turn LEDs on/off at some 0/5V threshold but adjusts the output current for any Ctrl voltage between 0 and 5V. I need >=4.5V at Ctrl to fully cut the lights. According to my measurements, Ctrl behaves like a 1.5K resistor. So, with the FET open (D1 is Off/Low/0V) we have 1K and 1.5K in series, causing a 2V drop at R1, leaving just 3V at Ctrl. I need min. 4.5V at Ctrl though, i.e. a max. 0.5V drop at R1, thus max. 160 Ohm at R1. But with R1=160 and the FET closed, R1 drops all 5V, burning 156mW; not ideal for standby :/ – Jonas May 11 '16 at 9:23
• Never mind, the 156mW are only dissipated across R1 when the LEDs are on and consume several watts themselves anyway. Thanks for your help. – Jonas May 12 '16 at 22:06