It looks like you're new here. If you want to get involved, click one of these buttons!
Japanese language support (日本語)
IDE & Tools
Feature Requests & Bug Reports
high side LED drive from microcontroller
i just stumbled upon this website. i would like to learn how to switch high side of leds out of a PIC microcontroller using mosfets/transistors. 2 output of uC has 4 leads connected to each which need driven separately. Any input is appreciated!
This is the Imp Forums. Maybe you would be interested in getting an Imp and experimenting? But to answer your question, can you give us a link to the place where the LED is sold, or has a spec sheet on the LEDs? There are so many different kinds, and different current requirements.
If you stumbled here and are not familiar with the Imp, it's a microcontroller that is WiFi connected to the Imp Cloud. All of the programming is done online from anywhere in the world, and you download directly to the Imp, which can be located anywhere as long as it has a WiFi connection to the internet.
For a newbie on a budget, this is a good place to start with the Imp:
You get a developer imp account, which is free.
You get an imp.
You get the free "blink-up" app for ios or android and install on your smartphone.
You power-up the imp at your house.
You select your wifi ID on the app, enter your wifi password and hold your phone next to the imp's input LED. The app blinks-in the wifi data and you're on.
You login to your imp account and do all of your programming on the Imp's IDE.
That's it. No IP programming, no router modifications, no headaches. You never need to connect your PC or laptop to your imp ... the USB port on the imp is just for 5V power, not programming.
If you try to connect your PIC microcontroller to the internet, let us know how it goes.
got it! but i guess my question still relates to the electronics regardless of which uC i use.. i havent picked out led yet but i am looking at methods to drive it on its high side. 1 method im thinking is using an n-mosfet to drive a p-mos which inturn is in series to the leds's high side. but how to choose the FETs?
i'm potentially looking at cree's xpl-red color. but for prototype im using ust breadboard type leds
edited March 24
Although this is not for PIC, have you looked here:
There would be plenty of these type of questions posted here. If you post you should get a response as its pretty active. Another option could also be:
just did, thanks!
edited March 24
Do you already have a power supply picked out?
It looks like they are 3.3VDC, but the current requirement is high.
The power supply selected would be 120V (mains powered)?
What are the requirements for physical control box size?
So you would purchase the LED's and a power supply and make them work together before you get into the switching by a uC. You would have the ability to test the functioning of the LED's all together as needed in the final build and measure the current too. Then you could determine selection of switching components (FET's) based on requirements. Physical aspects such as length of cable runs, wire sizing, desired lumens, etc. would be part of the equations. The actual connection of uC to FET's would be the last thing you work out ... as well as the programming.
I question doing this uC on a breadboard with FET's and "plain LED's". The uC part will be the easy part of it. Your Cree LED's are not "plain", so the power supply and switching will be the harder part. Just thinking out loud.
I'm looking at this information:
i am designing a trail light with leds. i am using a PIC microcontroller for the turn & brake lights logic and the output needs to drive the high side of the LEDS via 2 uC output pins (one for left turn/brake and second for right turn/brake). The LEDs are all tied to common ground (cathode) so im stuck with driving the leds on their high side. One idea i read was to drive an n-channel mosfet from the uC's output and use the n-channel to drive a P-channel mosfet, which inturn drives the LEDs? Would this work? can i do this to both output pins of the uC? How do i choose the mosfets? Since it is for a trail light kit, i'll be using high intensity red LEDs, havent chosen yet. Any advise or input is appreciated. If any of you have worked on this before, please share!
I'll be using a LM317 IC to generate 3.3v as inputs to uC. As for the leds, they need 12v
edited March 25
Yes, a high side driver is essentially a P channel FET between the supply and the load. The gate of the fet is pulled up with a resistor to the supply, which turns it off.
As this gate will have a high voltage when off, you can't connect it to the micro directly, so you use an N channel FET to pull this down.
If you look at the impExplorer schematics here:
...you'll see Q1A/B and Q3A/B are high side driver circuits, here used to switch the 5v going to the LED and the 3v3 going to the gated connectors. Why use a high side driver for a 3v3 switch? Here it's because we want to keep the ground (vs doing a low side switch) and the drive signal needs to be active high.
Pick the PFET by checking its current and voltage rating. eg if a device has 120mohm on resistance (Rds(on)), and you're passing 3A through it, then it will burn I*I*R, ie 3*3*0.120 = 1.08W - you need to ensure the package it's in can dissipate the power, so do that calculation as well as looking at the current rating. The Vdss rating needs to be high enough (well, low enough) to deal with the voltage you're switching - a FET with a Vdss of -20V is good for up to 20v of drain-source voltage differential when off. The Vgs needs to be lower than the voltage you're switching - essentially you're connecting gate to source (off) and gate to ground (on). This is almost never an issue with a high side switch as by definition you're moving the gate the entire range of the input.
eg the DMG2307L is a meaty PFET (30v, 3.8A, with Rds(on) of 0.090 ohms at -10V Vgs), so you'd see that or better when switching 10v load. If you're doing a 3A LED then it's 3*3*0.09=810mW when it's on, which is higher than the rated power dissipation (Pd) of 0.76W, but not by much and if you're flashing something then it won't be on all the time.
The NFET passes very little current - the gate pullup on the PFET can be very large (eg 100k) so in the case of switching 12v with the PFET, the NFET being on will pass I=V/R=12/100000 = 120uA... you just need to ensure that Vds is big enough - as big as the voltage you're passing through the PFET - and Vgs (the point at which it turns on) is low enough to be able to be successfully driven by your microcontroller's IO.
Lots of NFETs are marketed as "logic compatible" which tends to mean Vgs of <2.5v. The 2N7002 is the one we use a lot, it's dirt cheap - I think it's the cheapest on digikey.
...and yes, you should try an imp, but maybe not for a bike. You know that these turn and brake lights are going to be absolutely obscenely bright, right?
Hugo thanks a lot for the explanation! I think I have a better understanding now. I'll draw up a circuit and send post it later today. Hope you are around this weekend to check it out and throw any further input back at me.
So looks like to accommodate the power dissipation, I need to pick a PFET with low Rdson in order to have a higher power capability.
Can this nfet-often combine done for two outputs out of uC? One for left turn and another for right turn.
Also I'm planning on using 4 total leds per output (2 in parallel with each other). I'm looking at Cree's xpl-red color with high intensity type
You can replicate the circuit for each light, but you will need a separate PFET and NFET for each independently switched output.
I would not plan on things like the XPL-RED for a bike until you actually try one at full power. These things will literally burn your retinas out - they're not used in indicators, they're more often used in things like stadium displays.
Oh ok! Hats a useful piece of advise. I'm also actually looking di suggestion on which led to use? I have not picked one yet. I tried googling but didn't get much hits. Any recommendation on what's typically used in turn/stop light? I'll post a link to the amazon one I'm trying to mimic.
Partsam (1) Red 15" 11 LED Light Bar Stop Turn Tail 3rd brake Light Truck Trailer Identification ID Bar Waterproof on amazon
Any reason you don't just buy that bar and use it?
Normally, they will just be using cheap high intensity red LEDs. eg something like this:
...this is a 20,000mcd (millicandela) red LED, which is only taking 30mA. It's also only $0.61. I'd buy a few of those and see if they're bright enough. Doing a low side drive on that would be very easy - Vf is 1.7v, so if you're running from 3.3v, you need a (3.3-1.7)/0.030 = 53 ohm series resistor to get 30mA, or a (3.3-1.7)/0.020 = 80 ohm series resistor to get 20mA.
True, and I am! I keep going back and forth between buying and making but it doesn't seem to be too expensive. I am going to buy a trail light like the one I sent and make an"flasher module" for it wth the FETs. I was trying to find the led specification used in trail light kits in general so that I know how to size the FETs
Hugo, the one you sent on digikey is a thro-hole type.
I'm thinking of buying this trail light strip from amazon and build a flasher circuit with nmos-pmos combo to feed into the this light strip. so to size up the mosfets, ill need the current draw/led type thats used in this light strip. Would you or anyone here have any idea of what the current draw might be or what type of LEDs are used here? if you have a general idea of what led is used in a trail lights, would be a big help! it has 11 smd leds. I couldnt find the LED part# from the description..
i just tried the nmos-pmos circuit and i tried 10k, 47K and 100kohm for pull-up resistor and the lights are staying on regardless of the uC's output & after giving uC output, the lights do not blink per my code, they stay solid lit! i am using FQP27P06 for p-MOS (-60v -27A 70mohm) and RFD14N05L for n-mos(50V 14A 100mohm). please see attached schematic for 1 output pin.
2448 x 3264
I'd just buy one and measure the current usage. I gave a through-hole example because I thought you were hand-building this.
The chinese end products will have unknown and variable LED dies in them - whatever's cheapest at the time, often. Just measure it.
Can't see your schematic. Sounds like your PFET is upside down, check source is going to the supply and drain is going to the anode of your LEDs. If it's upside-down then the body diode will just be conducting and you won't be able to control it.
©2014 Electric Imp