Interfacing a PIC w/ high-side mosfet  - Page 1
Forum section: electronics / general

author: dcel
author_rank: Regular Contributor
timestamp: February 03, 2012, 05:47:25 pm
content: Here is what I am trying to figure out.A pic uC connected to a stop/turn/tail LED light for a truck. The grounds are tied at the light and that means high-side switching only. If my searches would have resulted in anything conclusive or usable, I would not have posted this question here.So far, what I have deduced is I need a logic-level P-channel MOSFET capable of twice the current that I need. It needs to be driven low to turn on the fet. But, some data that I have read states that I need a mosfet driver, another n-channel mosfet or bjt transistor to drive the larger p-channel mosfet. I have also found that there is a capacitive element to the p-ch mosfet that I have to compensate for to prevent latch-up. The bright and higher current "brake light" portion is 2.1A and the "tail" is 500mA, all at 12-16Vdc. As in any truck, the two sections need to be independently controlled.Now you may see the confusion as I have found no straight forward answer. I'm not looking for someone to do it for me, just point me to some relevant reading on the subject or let me know how you did something similar and I can spin it into something I can use. ( Then again, If you want to help that would be great!)Thanks for some guidance....Chris

author: Rufus
author_rank: Super Contributor
timestamp: February 03, 2012, 07:07:16 pm
content: Quote from: dcel on February 03, 2012, 05:47:25 pmFind ITS724G or ITS711.

author: dcel
author_rank: Regular Contributor
timestamp: February 04, 2012, 03:50:54 am
content: Thank you, Rufus, that PROFET® ITS724G is one smart chip, well actually two smart chips in one case! Pricey at 4.02 USD for quan. ten, but much easier and probably cheaper than trying to do this project with all discrete components.ChrisEdit grammer.

author: Psi
author_rank: Super Contributor
timestamp: February 04, 2012, 05:01:29 am
content: Yeah, you need to pull the gate of the P type fet low to switch it on.The voltage difference between the 12v rail and the gate pin has to be larger than the fets turn-on voltage.So, for example if a p type fet has a 6V turn on voltage and your battery was 12v you would need to pull the gate down to 8V or less to turn it on.If you connected the gate to a microcontroller output direct then you could only vary the gate voltage between 0 and 5V (micro vcc).Which would mean the fet would stay on all the time and you couldn't switch it off, (since you need more than 8V and the micro is only 5v).Youcan'teven set the pin to input mode and rely on a pullup to +12V because a mcu pin can never be driven outside it's supply range or power will feed backwards onto the power rail.So you need to add an N type transistor/fet to pull the gate to ground. Then you can control that from the microcontroller without issue.eg (diagram here)http://electronics-diy.com/electronic_schematic.php?id=1012

author: dcel
author_rank: Regular Contributor
timestamp: February 04, 2012, 08:37:40 am
content: Thank you Psi. That's even more help for me in the "I understand now" department.What I really did not understand before your post was the fact that the gate needs to be pulled low with respect to the voltage on the source, not ground. That is why the "negative" voltages with the p-mosfets. I think I get this enough now that I 'could' do it with discretes, thanks.Could a non-logic level p-chan mosfet be used if driven by a smaller n-ch mosfet? So, replace the bjt in the link you sent me with a 2n7000 and use any 'jelly bean' p-ch fet?Thanks again...ChrisEdit grammer.

author: Psi
author_rank: Super Contributor
timestamp: February 04, 2012, 11:01:33 am
content: Quote from: dcel on February 04, 2012, 08:37:40 amCorrectQuote from: dcel on February 04, 2012, 08:37:40 amYep, if you use a fet though, change the 'micro -> 2n7000' resistor to 400R.

author: dcel
author_rank: Regular Contributor
timestamp: February 05, 2012, 01:41:23 pm
content: Thanks again Psi.I wish I would have found these pic mcu's 20 years ago and I would not have to be playing catch-up.I did some more searching and found some good reading in getting the pic connected to the real world. The links you gave just made it easier to understand, not that I'm thick headed or anything.I really appreciate the help guys, it makes getting back into the field a bit easier.Chris

author: dcel
author_rank: Regular Contributor
timestamp: February 18, 2012, 01:21:19 am
content: Well, my mosfets just showed up today, just in time for the weekend. I bought extras just in case the magic smoke escapes from any.Wish me luck...Chris

author: dcel
author_rank: Regular Contributor
timestamp: February 18, 2012, 04:13:49 am
content: From what I have read here and other places is that to do high-side switching, p-chan mosfet and a driver from the mcu. I was not aware that a n-mosfet could be used in high side switching. Is it used backward? What I am doing is a pic micro to a 2n7002 n-mosfet driving a IRFR9014 P-mosfet to power the load, both sourced cheap from ebay, so blowing a few up is no sweat.My background is audio recording and sound reinforcement so this microcontroller to realworld stuff is a learning process. I work two jobs and on call 24-7, so not much time for experimenting is left after sleep. So, any advice from anyone here is really appreciated, instead of just me stumbling around in the dark.Thanks...Chris

author: Rufus
author_rank: Super Contributor
timestamp: February 18, 2012, 04:40:26 am
content: Quote from: dcel on February 18, 2012, 04:13:49 amI don't think Mechatrommer understands 'high side'.You need an additional supply to allow the gate to be raised above the supply voltage to drive high side with an N channel MOSFET. N channel MOSFETs perform significantly better than P channel so the additional complication can be worthwhile.A 2N7002 driving the gate of an IRFR9014 with a pull up resistor will work okish. Remember the gate of the IRF9014 sees the whole supply voltage unless you add a zener clamp or something so the supply + any surge or spikes is limited to the 20v VGS maximum rating. Consider the PIC pin floats in reset so the 2N7002 gate floats and your output might glitch on during power up. Also consider the RDSon of that MOSFET is 0.5 ohms which means 2.2W dissipation and loosing a volt at the 2.1A you mentioned in the 1st post.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 18, 2012, 04:48:23 am
content: Quote from: Mechatrommer on February 18, 2012, 01:51:16 amok that was a silly suggestion. deleted.

author: dcel
author_rank: Regular Contributor
timestamp: February 18, 2012, 05:57:06 am
content: Quote from: Rufus on February 18, 2012, 04:40:26 amOK, let see if I understand this...I will have two regulators in this build, one for 12v to protect the whole works and the 5v reg for the mcu, that should insure that the Vgs remains less than 20vdc. A pull down res on the pic output should work for the off/reset state. The 2.1A is the max value that I could find for the light that I'm using, I think its less, I have not measured that yet and there is no real datasheet available to refer to. I will grab the light from my toolbox at work tonight to bring home and measure, I just got called in again. That light is only going to be pulsed on 200ms every two seconds, not that much on time so power dissipation shouldn't be a problem.Am I even close to understanding this yet...?Thanks for the help guys, this is a pet project that I always wanted to figure a way to do but never could, till I found the microcontroller, which making some lights blink seems trivial now. If I could only get the lab up and running...Gotta goto work...ChrisOn edit: Thanks Mech for trying to help...

author: Rufus
author_rank: Super Contributor
timestamp: February 18, 2012, 06:25:12 am
content: Quote from: dcel on February 18, 2012, 05:57:06 amWhat you said make sense.I got the impression from you first post this is running from a vehicle supply which is potentially nasty with spikes and surges. If you are using a regulator then it has to deal with the spikes and surges.

author: Zero999
author_rank: Super Contributor
timestamp: February 18, 2012, 07:15:08 pm
content: Just one thing: don't forget the fuse, otherwise there'll be smoke if there's a short circuit.

author: dcel
author_rank: Regular Contributor
timestamp: February 18, 2012, 09:53:44 pm
content: Quote from: Rufus on February 18, 2012, 06:25:12 amGreat! That means I am ready to do some smoke testing! You are correct that its running on a vehicle (my truck) with some nasty power, but I already figured I would have to protect it.Your right Hero, definitely fuses.I have some chores to do around the house but I may get to it later tonight.Thanks guys, I'll let you know if it works...Chris

author: dcel
author_rank: Regular Contributor
timestamp: February 22, 2012, 11:47:17 pm
content: OK, this is what I have been working on. I haven't had time, in the not yet together lab, to breadboard this up, and my power supply wont get here 'til friday evening. My heathkit trainer doesn't supply enough current to test this out.The fets modeled are the through hole parts that I plan to test/prototype with. So far, I know more about fets than I have ever known, after about two hours with the simulator, and thanks to Daves videos and the help here on the the forum, thanks guys!Any questions or comments are welcome...ChrisOn edit: I thought I'd give a rundown on the circiut for those who need it, so here it goes....V1 is the high current 12v supplyV2 is the output from the MCUJ1 is the switch that lets me simulate the MCU high and open outputU2 and U4 are voltage and current to the gate of Q2R3 is the pull-down resistor for the gate of Q2R1 is the pull-up resistor for the gate of Q1Q2 is 2N7000 N chan mosfet used as inverter/driver for Q1Q1 is MTP20P06 P chan power mosfet 20a 60vR2 is the simulated load that is high side powered from Q1U1 and U3 are voltage and current across the load R2I hope that will help someone on here.

author: sile
author_rank: Contributor
timestamp: February 23, 2012, 06:27:45 am
content: I'm working on a similar project to give some control to some older car lighting. I ended up getting this p channel mosfet AOD4185. People have mentioned to me to also watch out for the high initial current draw of incandescent lighting. Until it warms up the filament has very little resistance. This is the main reason I over sized the mosfet so much. I'm planning on only 3Amps steady state. Also, you can use PWM on your micro to slowly power on the light.Your circuit looks good to me though.

author: dcel
author_rank: Regular Contributor
timestamp: February 23, 2012, 07:08:50 am
content: QuoteThanks, I have learned a lot just being on here.I hope to have this little project complete by the weedend and start another.I am using LEDs for the flasher I'm building, they flash faster and are brighter. Now they are cheap enough too @ $16usd each.Incandecents are really high current until warm, that is why most new stage lighting dimmer packs keep the filament warm for faster flash rate and to keep the lamps from burning out due to inrush current.Is your project something that you can use LED lighting? Is your project something that could be done with automotive relays that are controlled by the MCU? I am a huge fan of relays in the accessories that are required on the trucks at work, switches last longer and I can shut off everything via relay when the Ign key is removed.It saves a lot of dead batteries.Those relays are cheap and can switch quite fast, I considered using the relays, but switching is not quite fast enough for me.30-40 Amp contacts and I have never had to change out a bad one that I have installed. Factory ones on the other hand go bad all the time, if I even suspect a stock relay it gets replaced, been burnt by them a couple times, never again.Good luck...Chris

author: andersendr
author_rank: Regular Contributor
timestamp: February 23, 2012, 08:43:04 am
content: For automotive lighting, I am all about using the smart fet's. Very low on resistance, 50mOhms about. The pins in the connectors get hotter than the device. High current, 10amp cont. with 40amp max. They are pretty simple to operate, just send a command to them. They can detect and report short circuits/faults in the system. Here are a few linksInfineon -http://www.infineon.com/cms/en/product/automotive-ics/smart-high-and-low-side-switches/profet%E2%84%A2-smart-high-side-switches/channel.html?channel=ff80808112ab681d0112ab69e2d40357Freescale -http://www.freescale.com/webapp/sps/site/taxonomy.jsp?nodeId=01435979968459There are others these are just the ones I have used. Go to any manufacture and click on their automitive solutions page somewhere and you can see if they offer such a thing.

author: dcel
author_rank: Regular Contributor
timestamp: February 23, 2012, 10:09:07 am
content: Quote from: andersendr on February 23, 2012, 08:43:04 amYes, thanks! Rufus pointed those devices out to me also. They're great but expensive, and if I would have went that route, I wouldn't have learned how to use fets in the real world. If I were using incandescents, that would have been the chip I would use, or just a simple relay.The newer cars and trucks use these to report lamp out and if there is more current draw than there should be. A real hassle for me at work adding the aux lights for plows and such. I end up isolating everything with relays because the computers can't detect the extra load of the relay, but will shut down the circuit if I try to add just one turn signal, marker lamp. What a pain.Perhaps Sile may find them useful for his project...ThanksChris

author: sile
author_rank: Contributor
timestamp: February 26, 2012, 10:01:09 pm
content: very useful...

author: dcel
author_rank: Regular Contributor
timestamp: February 26, 2012, 10:53:22 pm
content: Quote from: sile on February 26, 2012, 10:01:09 pmAnd probably a whole lot easier for you with the incandescents.Well, my power supply showed up non-functional, so I spent the weekend fixing that and at work.And I found out that the LED lights that I am using are only 500mA each on maximum. That will work well for putting multiple lights on each channel. Still working out how I want to program them to flash.Can't wait to get this prototyped up...Chris

author: dcel
author_rank: Regular Contributor
timestamp: March 22, 2012, 11:43:15 am
content: well its up and running... It LIVES!Programmed my first pic16f616 and it worked perfectly at power up. These thing program so fast that I though I did something wrong and grabbed another and uploaded again, blink and it was done.I acuallyhadmade time to proto two projects this weekend.I will post pics and video later tonight if i'm not too tired.Off to work for the day...Chris

author: Skibane
author_rank: Contributor
timestamp: April 08, 2012, 05:32:06 am
content: I'm a little late to this party, but here'sanother option...

author: dcel
author_rank: Regular Contributor
timestamp: April 08, 2012, 11:08:27 am
content: Thanks Skibane and welcome to the blog. I just read through the data sheet and the coolest thing about this chip is it can be high or low side drive. I will consider it if I were using incandescents. Its always helpful to know that there is another solution out there. Others have suggested all-in-one solutions and I would have went that route if I wasnt trying to learn how to engineer with mosfets.Thanks...Chris