PWM control of 1w led

Hi All,

Im new to the forum and pretty new to arduino. I'm stuggelig with figuring out how to properly do PWM from a NodeMCU on a small led driver i purchased. Notice that the PWM is inversed so high is off.

It's this product: 1W LED Driver 350mA - ArduinoTech

I tried a few things:

  • I connected 1 1w LED to the LED driver (350ma)
  • First I powered the LED driver with a 12v/2a adapter and the LED lights up fine
  • Next with the NodeMCU powered via USB I tried connecting one of the GPIO pins to the PWM pin on the LED driver and ran a small blink program - this did not do anything
  • I measured the GPIO pin and confirmed that it was switching between 0 and 3,3v using a multimeter (maybe i messed something up here - more below)
  • I than tried splitting the 12v power to also run a breadboard power supply at 3,3v.
  • If I connect the 3,3v from the breadboard to the PWM pin the LED goes out - so far so good
  • I than set up a little circuit with a tip120 transistor. Initially this also didn't work.
  • In the end it turned out that by connecting the ground from the NodeMCU to the ground on the breadboard it actually does work. I was also able to do analogWrite to the pin and dim the led.

However in the process I'm pretty sure I managed to fry something. Because now the NodeMCU gets extremely hot and is having problems flashing. I did get it back working a little bit by shorting the GPIO15 pin directly on the Node while resetting to put it into flash mode. But it quickly overheats and stops working at all.

In the end I'm left scratching my head:

  • Why does the ground on the NodeMCU need to go to the breadboard?
  • What am I missing in terms of just running the PWM signal straight from the NodeMCU to the LED driver?
  • What part of this setup could have caused my NodeMCU to get fried? Could it just be me stupidly measuring the GPIO output by shorting the pin to ground with the multimeter? Or could it somehow be the LED driver PWM drawing too much current?

Hopefully someone can shed some light - any input is much appreciated! :slight_smile:

Best,
Olav

That could be it.

See this:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

There is a lot more to driving a laser than you think. See:-
http://www.repairfaq.org/sam/laserdps.htm

This question shows that you completely forgot school physics. In order for current to flow, the circuit must be closed. On the wire connecting the pin and the driver, the current flows in one direction, on the wire connecting the GND - it returns back

It could be both. You can not short the pin to ground if you turn on the high level. Most microcontrollers do not have any short circuit protection and can burn out.
To understand if the driver current could exceed the allowable pin current, you need a datasheet for the driver. And it would be right if you looked into the datasheet BEFORE connecting the driver to the board

Hey, it's not a laser - just a 1w LED diode (3,3v / 350ma)..

Sorry, my bad.

Thank you for the reply.

I forgot to put that the NodeMCU is connected to the computer / powered via USB.

So the LED and the breadboard power supply i powered by the 12v which has a ground. The NodeMCU by the computer USB port which has a ground. Just what I'm not understanding is why there also needed to be a connection from the NodeMCU ground to the ground on the breadboard?

Im sorry if you already answered this - but if you would elaborate a bit that would be fantastic!

Because "ground" is a basically meaningless concept. It only gains meaning when you give it one. Make sense? :slight_smile:

The reason you need to connect the "grounds" together is because the driver and the Node need a common reference point for current to return to. That reference point is usually called "ground." Now, it's entirely likely that it will work without you making this connection because, as you noted, the power supply is grounded and so is the PC. Those "grounds" may find a common point that's close enough to work. I have a similar situation on my workbench where circuits will work even before I connect the power supply ground to the circuit. But don't count on it: ground the Node to your driver to ensure that the "ground" reference is what you expect it to be, or stuff can magically stop working when you least expect it to.

Did you actual read the first link I posted in reply #2 ?
It had diagrams and everything, showing the current path.

I mostly agree with that, but it's also important for creating a reference or zero point. If you have two systems communicating and they rely on voltages rising or falling beyond a certain threshold, without the zero/ground/common tied together, those reference voltages can potentially be all over the place. The zero of one system can float or have a higher zero than the other and your reference can get messed up. In this case specifically, the PWM signal may rely on a voltage that will or won't be reached based on the relative voltage of either system.

Isn't that exactly what I said?

common reference point

No. You stated it was just for current flow, which is not the case. Voltage potential difference is a very specific but important reason for tying them together which you didn't mention at all. Voltage and current are not the same thing.

Hey,

Thank you for all of the replies. It's very helpful. And I'm sorry if I didn't read properly through everything. Also I feel a bit silly now. I went back to a previous project with LED strips (12v and PWM'ed via TIP120) and ofc in that case the ground of the Node is also connected to the 12v ground.

I tried a few more times to make the PWM pin on the LED driver work but the only thing i managed to do was fry another Node. I'm kind of surprised that a PWM pin would cause that much damage.

In any case, now I'm just doing the PWM on the 12v side exactly as with the LED strip and that seems to work well.

Kind of annoying since it adds complexity to the design. Optimal would be just running the PWM pin on the LED driver directly from the Node but Im not really in the mood to loose further hardware.

If anyone has some idea of how to figure out that PWM pin I would be super interested. Unfortunately there doesn't seem to be a proper data sheet for the driver. And if not, thank you all for the help!

Best,
Olav

Can you show us a picture of your setup?

I wonder if the PWM circuit on your driver limits the current in any way. I would put at least a 1k resistor going from the IO pin to the driver board.

First I'd check these two contacts though.
image
Are either of them tied to ground or do either of them produce a voltage? I wonder if it's an NPN system and putting 12 volts to your Node.

Hey,

Thank you! I will do that!

I'm using the one labeled PWM to input the signal.

I'm sorry for asking dumb questions but just to be clear.. the 1k resister is in case the PWM circuit does not limit the current right? To protect the arduino? Im sorry it's a lot to wrap my head around as a beginner - I hope you dont mind the extra questions.

If I wanted to measure if the PWM pin outputs a voltage, where would you suggest measuring between?

As far as other tests on the PWM pin, if I supply 3,3 to it, it does turn off the LED. I did pick up from a youtube video that the PWM is inversed so that makes sense..

The second pin is actually labeled GND on my board so I would assume it connects to ground. I suppose theres a fair chance that that is where the ground connection should go and Im extra supid for not looking more closely. Just from the video I watch the guy described the second pin as an analog input so I didn't pay much attention to it.

In the mean time I also figured out another issue with my current setup of modulating the 12v input to the driver. At very low dim values (the led needs to go pretty low for any visible dimming effect) the driver starts to have a very slight hum. Im assuming thats probably not good.

I will add a photo shortly!

Best,
Olav

Exactly.

Each pad against the VIN- terminal.

It could be an NPN instead of a PNP, so funky things could be happening. Take a look at how the different circuits operate and try to get a little familiarity.

Look up coil whine. You could be getting a choke into an audible resonance. Might not be anything to worry about.

Hey,

Thank you so much! I will have a look at PNP vs NPN.

Edit: I measured the voltage between the PWM and each of the VIN pins. It gives 11.7v to the 12v input vin and 3.15 to the 3.3v side (LED side).

Edit 2: I added the 1k resistor and now it works! Thank you so much for both your help and patience!!

I rewatched the video Review: 1W 350mA LED Driver with the elusive 6200 Chip - YouTube and the guy actually does use a 1k resistor.

Below is a photo of my test setup. I hope it's not too egregious. Also photo is a bit dim since it's dark here but it should be possible to make everything out.

The led is off to the left (not in frame). Red wires are positive and black are ground (except the one from ground to the TIP120 i just notice). White one is the PWM signal. The green wire coming off the LED driver is the one i soldered to the PWM. 12v is connected via the barrel jack on the left. Node is powered via USB (3.3v not used for anything as is here but ofc will be when its not on USB).

I also included a closeup of the driver - please disregard the soldering - it does work believe it or not :slight_smile:

Best,
Olav

Study the PT4115 datasheet. Most LED driver chips are build according to that principle.

That connector goes directly to an input of the chip, don't see why you need a resistor.
The input is very weekly internally pulled up to 5volt (200k).
Can be controlled with a (100k) pot as variable resistor, or DC-dimmed with 0-2.5volt, or PWM-ed with 3.3 or 5volt logic.
Leo..

You would think so but trying that killed two Node's.. i just now added a 1k resister and i works. Though i think inverting the PWM signal would make it smoother... next challenge :slight_smile:

Normally I agree. Something funky going on with this one though.

I checked on the back of the driver and it does look like the PWM pin is just wired straight to a pin on the IC.. weird..

An additional oddity is that the PWM levels seem very inconsistent. I suppose it could just be because the PWM signal is not properly inverted (i'm just doing equivalent of analogWrite(255-brightness) ). But the result is that for instance 252 is noticeably dimmer than 253 (should be other way around).