Electrical – How to output 5V from 3.3V MCU

3.3v5vled-driverlogic-levelmicrocontroller

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.

schematic

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?

Best Answer

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.

Related Topic