Skip to main content
46 events
when toggle format what by license comment
Mar 1, 2018 at 4:58 comment added Chi Good question. It's probably the huge turn-off time of BJTs (remember a darlington pair is just 2 BJTs) that's giving you trouble. Note that while the BJTs are turning off, they are going through the linear region, which means your LEDs are still emitting light. BJTs are not really that good for switching loads, MOSFETs and IGBTs are the way to go. I suggest you try to get a proper gate driver, like the ISO5500 or the simpler to use ADUM3123, and use it together with a properly rated MOSFET for your LEDs.
Feb 26, 2018 at 3:24 comment added piojo @Chi Wow, that is a revelation. Thank you! But it doesn't fully explain the excessive brightness I saw when I ran the LED strip with 1/65535 duty, since I was using a TIP101 darlington transistor for that test. I was driving it directly from the Arduino, with a 1K resistor on the transistor base. (I tested other resistor values.) It may not have had a pulldown, but I thought it didn't need one since the Arduino pin would pull it down when off. Could it be a slow response just because it's a Darlington chip? (And if I can't use a Darlington and I can't use a MOSFET, must I use a PWM chip?)
Feb 26, 2018 at 2:51 comment added Chi @piojo The problem you are having is that the MOSFET is not turning on and off properly. In fact, I doubt it's even turning off when it should. The MOSFET's gate basically behaves as a capacitor: when charged, the MOSFET is ON, when discharged, the MOSFET is OFF. Your 10K resistor slows down the charging of this capacitor and limits the output current of your microcontroller, and this is the reason why you haven't fried it yet. A proper MOSFET gate driver IC is able to supply peak currents of 2A or even more to rapidly charge and discharge the gate cap, and some don't even use gate resistors.
Feb 26, 2018 at 2:45 comment added Chi @piojo So you're driving the MOSFET directly with a microcontroller... so yeah, your problem is definitely not the PWM, nor the ammount of steps it has. Also, a LPF before the MOSFET is a terrible idea as you saw from the responses, FETs nowadays are not built to handle the linear region.
Feb 23, 2018 at 11:29 comment added piojo @NeinDochOah If you meant using a filter to smooth the current through the transistor, that's a really interesting thought. REALLY interesting. I bet a filter or capacitor could do all sorts of things to the shape and duration of the pulse.
Feb 23, 2018 at 11:17 comment added piojo @NeinDochOah Thanks for the comments. With 65535 steps (yes, this is possible on timer 1), the frequency/flicker is bad, and the dimmest level is brighter than it should be logically. (I know what 1/65535 power looks like from another test.) With 255 steps, the dimmest level is horribly bright enough to read a book. As for a low pass filter behind the MOSFET, that is the subject of this post! The result is great, but apparently it may burn out the MOSFET. And for the same reason, an external DAC won't help, unless I switch to a transistor that likes being driven that way. Which I may do.
Feb 23, 2018 at 9:55 comment added NeinDochOah @piojo Last but not least, you could buy an external 16 bit DAC with SPI or similar interface and just use the Arduino to configure the DAC. (sorry for the 3 comments, that's due to the time limit on comment editing comments)
Feb 23, 2018 at 9:53 comment added NeinDochOah @piojo Also did you try a low pass filter behind your MOSFET to reduce the flicker? You could also try to reduce the 10k Ohm resistor between your gate and pin, but I highly doubt, that the switching speed of the MOSFET is relevant.
Feb 23, 2018 at 9:44 comment added NeinDochOah @piojo "So as I tweak it to have lower duty (such as 1/65535), the period of the signal must increase: 16 MHz/65535 is 244 Hz. " For me this implies that you have 65536 steps for your PWM, if you had only 256 steps, you should end up with 16Mhz/256 = 244*256Hz.
Feb 23, 2018 at 6:01 comment added user371366 @piojo a cool thing about the atmega32u4 is that it has a PLL configurable to 24, 48, or 96 MHz to drive the USB interface, that can also be used as a clock source for some of the PWMs onboard :D
Feb 23, 2018 at 1:43 comment added piojo @Chi I'm using a clone of the Arduino Uno rev 3, and I'm currently driving the MOSFET with analogWrite and a 10K ohm resistor. I can't remember whether the pure PWM test circuit used a pulldown resistor, but I don't think it needs one, since when PWM is in the 'off' phase, it should be pulled down to ground when being driven directly. I know for a fact that digitalWrite(pin, LOW) pulls down a pin, and can even act as ground for the purpose of accepting small amounts of current.
Feb 23, 2018 at 0:33 comment added piojo @τεκ That is potentially the most correct solution so far. I had thought of using a BJT in series with the MOSFET to achieve two levels of gradation (255*255 in total, with the MOSFET using PWM and the BJT not), but having parallel transistors would mean the BJT only needs to handle 1/255 of the total current. (1/255 is the maximum "error" in the power of the larger current source due to its granularity.)
Feb 23, 2018 at 0:29 comment added piojo @Chi I've never heard of problems switching a MOSFET from a microcontroller. Can you give any more info about that, or a term I can look up? Regarding frequency, there's an inverse relationship between gradation of duty cycle and frequency. So as I tweak it to have lower duty (such as 1/65535), the period of the signal must increase: 16 MHz/65535 is 244 Hz.
Feb 23, 2018 at 0:24 comment added piojo @Chi As for brightness required, it's a strip of 100 decently bright LEDs, and all I can say is try it or trust me. The low brightness needs to be something like 0.5% of the lowest untweaked PWM level (1/255). It has to be unnoticeable when eyes are closed. The human eye has a truly amazing sensitivity.
Feb 23, 2018 at 0:21 comment added piojo @immibis Yep, this was way more interesting than I anticipated!
Feb 22, 2018 at 22:35 comment added Criticizing Israel not allowed @piojo Well, I didn't know about any of the thermal runaway effects explained in these answers, so it's a good thing you asked! (But, I would also just try it and see, if I can afford to blow up a MOSFET)
Feb 22, 2018 at 22:01 comment added τεκ @piojo You could use a MOSFET to PWM with 256 levels, in parallel with a small linear current source circuit with a range of 0.8% or so to get flicker-free low brightness. Since the current source would only be handling a few mA it wouldn't really matter how it was made.
Feb 22, 2018 at 21:16 comment added Chi @piojo 255 levels means that the lowest level you can achieve is about 0.4% of the LED's maximum brightness (assuming linear relationship between applied voltage and brightness). I mean, that's not even half a percent. Unless you have super powerfull LED, I don't see why 255 levels aren't enough. Also, what's the deal with the low switching frequencies? I'm pretty sure you can easily get frequencies in the kHz range with AVRs. Which Arduino are you using? Also, how are you driving the MOSFET? Don't try to switch a FET using a microcontroller, you will eventually fry both of them.
Feb 22, 2018 at 19:16 comment added bobflux What is the Vds or Vbe voltage of the transistor? Also, its max current, please.
Feb 22, 2018 at 18:33 comment added piojo @ChrisH Indicentally, I have one of those Philips lamps, and that sudden spike of orange glow is why I decided to build a better one. The Philips lamp is unusable, but what I build already works fairly well.
Feb 22, 2018 at 18:31 comment added piojo @ChrisH About filtering the PWM, that's a great idea, but it's not only too choppy at 1/65536 duty, but too bright. I think the MOSFET isn't shutting off quickly enough, and I don't think cheap scopes would do a good job on such a short signal. I don't know the theory well enough to explain it, but I believe a short pulse requires far more bandwidth than a nicer shaped wave.
Feb 22, 2018 at 18:22 history edited piojo CC BY-SA 3.0
added 7 characters in body
Feb 22, 2018 at 14:07 comment added Chris H Incidentally, having had one of those lamps in my house at some point (with a daylight incandescent bulb) there was a distinct step from black to dim orange light when it turned on.
Feb 22, 2018 at 14:01 comment added Chris H How about filtering the PWM to avoid flicker? ANyway for this sort of thing a pocket scope is good (Adafruit, mine was even cheaper) or you can use the soundcard of your PC (you could probably just hook up a photodiode to the line-in and get away with it; a red LED will do well as the photodiode)
Feb 22, 2018 at 12:46 answer added bobflux timeline score: 4
Feb 22, 2018 at 10:24 comment added Andy aka Multiple or single MOSFET hot-spotting (thermal runaway) problem
Feb 22, 2018 at 9:59 comment added piojo @jms I'm not hearing anything about donating me an oscilloscope. :D But on a serious note, Wikipedia says that 3 kHz is the recommended frequency to avoid all biological effects. A 244 Hz strobe is EASY to see. Try it yourself with a bright LED at ~10-30% duty cycle. Reference: en.wikipedia.org/wiki/Flicker_fusion_threshold
Feb 22, 2018 at 9:51 comment added jms How is 244 Hz (16 MHz / 2^16) "noticeable" at some duty cycles? At that rate you should only be able to notice it if it moves trough your field of view while on. If you don't want that, consider making a switching mode converter that feeds nice clean DC to the LED: no flicker, yet good efficiency.
Feb 22, 2018 at 9:39 history edited piojo CC BY-SA 3.0
added 104 characters in body
Feb 22, 2018 at 9:07 answer added anon timeline score: 1
Feb 22, 2018 at 8:32 history edited piojo CC BY-SA 3.0
added 14 characters in body
Feb 22, 2018 at 8:00 answer added Neil_UK timeline score: 21
Feb 22, 2018 at 7:57 history edited piojo CC BY-SA 3.0
added 1001 characters in body
Feb 22, 2018 at 7:45 answer added Jeroen3 timeline score: 2
Feb 22, 2018 at 7:37 comment added piojo @dn3s Since the Arduino frequency is fixed at 16 MHz, to get a higher frequency, you get a lower duty cycle divisions (and vice versa). After testing, I don't believe I can get an acceptable result without blinking, and without the lowest duty cycle being too powerful. Perhaps I could do it with a faster switching MOSFET, but I can't debug the problem without a real oscilloscope--no sound card o-scope software would help me analyze a 62 nanosecond pulse. Besides, the math/logic is inelegant, since at 244 Hz some duty cycle may look fine, but other duties will blink visibly.
Feb 22, 2018 at 7:29 comment added user371366 @pioji most of the chips used in Arduinos do support higher resolution PWM, but it will require somewhat more involved code than the built-in AnalogWrite() function. There may be libraries, otherwise it could be a fun challenge to figure out what needs to be written to which registers to get enhanced PWM mode working. I once had to do this to get a higher PWM frequency (~100kHz) on an ATmega32u4 (leonardo, pro micro, etc).
Feb 22, 2018 at 7:15 comment added piojo The workaround is to compensate for the LED strip with a single LED, which can be used to balance the error--the exact output which can't be accomplished with only 255 levels. It's an inelegant solution that introduces other trade-offs.
Feb 22, 2018 at 7:13 comment added piojo @Chi Thanks, but 255 levels PWM aren't enough. I'm using Arduino, and to accomplish exponential output with an acceptable degree of granularity, I need more like 65535 output levels, and that also fails (due to the frequency being slow enough to observe blinking, and the transistor's turn-off time seems to be too slow). The important point is that the lowest PWM level is far too bright to be acceptable.
Feb 22, 2018 at 6:56 history tweeted twitter.com/StackElectronix/status/966567257521442816
Feb 22, 2018 at 6:07 comment added Chi Well, this doesn't really answer your question, but regarding the PWM vs Variable Voltage control, you could increment your PWM's duty cycle exponentially to get the same effect. It also would seriously increase efficiency since using the MOSFET in the ohmic region means that the MOSFET is just dissipating the energy that you "don't want", as opposed to PWM control where, ideally (i.e. instant turn-on and off, zero RDSon etc), no energy is dissipated.
Feb 22, 2018 at 5:26 answer added Zekhariah timeline score: 6
Feb 22, 2018 at 5:24 answer added τεκ timeline score: 14
Feb 22, 2018 at 5:08 history edited piojo CC BY-SA 3.0
added 19 characters in body
Feb 22, 2018 at 5:07 comment added piojo @immibis Thanks! You're saying it's harmless if I stay within the parameters in the datasheet? You could make that an answer and I'll accept it. This was an extremely simple question, so an extremely simple answer is appropriate. :)
Feb 22, 2018 at 5:05 comment added Criticizing Israel not allowed Yes, they can dissipate power. As always the ratings will be in the datasheet. I'd check it thoroughly if I was going to dissipate significant power, to make sure my circuit doesn't exceed the parameters of the MOSFET.
Feb 22, 2018 at 4:41 history asked piojo CC BY-SA 3.0