Author Topic: Interfacing a PIC w/ high-side mosfet  (Read 15337 times)

0 Members and 1 Guest are viewing this topic.

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Interfacing a PIC w/ high-side mosfet
« on: February 03, 2012, 05:47:25 pm »
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
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Interfacing a PIC w/ high-side mosfet
« Reply #1 on: February 03, 2012, 07:07:16 pm »
Thanks for some guidance....

Find ITS724G or ITS711.
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #2 on: February 04, 2012, 03:50:54 am »
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.

Chris


Edit grammer.
« Last Edit: February 04, 2012, 08:15:26 am by dcel »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9951
  • Country: nz
Re: Interfacing a PIC w/ high-side mosfet
« Reply #3 on: February 04, 2012, 05:01:29 am »
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).
You can't even 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
« Last Edit: February 04, 2012, 05:09:39 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #4 on: February 04, 2012, 08:37:40 am »
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...

Chris

Edit grammer.
« Last Edit: February 04, 2012, 08:55:11 am by dcel »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9951
  • Country: nz
Re: Interfacing a PIC w/ high-side mosfet
« Reply #5 on: February 04, 2012, 11:01:33 am »
Could a non-logic level p-chan mosfet be used if driven by a smaller n-ch mosfet?

Correct

So, replace the bjt in the link you sent me with a 2n7000 and use any 'jelly bean' p-ch fet?

Yep, if you use a fet though, change the 'micro -> 2n7000' resistor to 400R.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #6 on: February 05, 2012, 01:41:23 pm »
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
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #7 on: February 18, 2012, 01:21:19 am »
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
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #8 on: February 18, 2012, 04:13:49 am »
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

 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Interfacing a PIC w/ high-side mosfet
« Reply #9 on: February 18, 2012, 04:40:26 am »
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.

I 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.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11642
  • Country: my
  • reassessing directives...
Re: Interfacing a PIC w/ high-side mosfet
« Reply #10 on: February 18, 2012, 04:48:23 am »
why dont you use n-channel mosfet for high side switching? so you wont have any issue with 12V range with a micro and wont need any driver, just direct connection micro -> n-mosfet, 0V off, 5V on?
ok that was a silly suggestion. deleted.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #11 on: February 18, 2012, 05:57:06 am »
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.

OK, 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...
Chris

On edit: Thanks Mech for trying to help...
« Last Edit: February 18, 2012, 05:58:52 am by dcel »
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Interfacing a PIC w/ high-side mosfet
« Reply #12 on: February 18, 2012, 06:25:12 am »
Am I even close to understanding this yet...?

What 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.

 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19524
  • Country: gb
  • 0999
Re: Interfacing a PIC w/ high-side mosfet
« Reply #13 on: February 18, 2012, 07:15:08 pm »
Just one thing: don't forget the fuse, otherwise there'll be smoke if there's a short circuit.
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #14 on: February 18, 2012, 09:53:44 pm »
What you said make sense.

Great! 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
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #15 on: February 22, 2012, 11:47:17 pm »
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...

Chris

On 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 supply
V2 is the output from the MCU
J1 is the switch that lets me simulate the MCU high and open output
U2 and U4 are voltage and current to the gate of Q2
R3 is the pull-down resistor for the gate of Q2
R1 is the pull-up resistor for the gate of Q1
Q2 is 2N7000 N chan mosfet used as inverter/driver for Q1
Q1 is MTP20P06 P chan power mosfet 20a 60v
R2 is the simulated load that is high side powered from Q1
U1 and U3 are voltage and current across the load R2

I hope that will help someone on here.

 
« Last Edit: February 23, 2012, 05:55:17 am by dcel »
 

Offline sile

  • Contributor
  • Posts: 15
Re: Interfacing a PIC w/ high-side mosfet
« Reply #16 on: February 23, 2012, 06:27:45 am »
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.

 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #17 on: February 23, 2012, 07:08:50 am »
Quote
Your circuit looks good to me though.

Thanks, 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
 

Offline andersendr

  • Regular Contributor
  • *
  • Posts: 56
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #18 on: February 23, 2012, 08:43:04 am »
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 links

Infineon -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=ff80808112ab681d0112ab69e2d40357
Freescale -http://www.freescale.com/webapp/sps/site/taxonomy.jsp?nodeId=01435979968459

There 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. 
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #19 on: February 23, 2012, 10:09:07 am »
For automotive lighting, I am all about using the smart fet's.   

Yes, 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...

Thanks

Chris
 

Offline sile

  • Contributor
  • Posts: 15
Re: Interfacing a PIC w/ high-side mosfet
« Reply #20 on: February 26, 2012, 10:01:09 pm »
very useful...
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #21 on: February 26, 2012, 10:53:22 pm »
very useful...

And 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
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #22 on: March 22, 2012, 11:43:15 am »
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 acually had made 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
 

Offline Skibane

  • Contributor
  • Posts: 13
Re: Interfacing a PIC w/ high-side mosfet
« Reply #23 on: April 08, 2012, 05:32:06 am »
I'm a little late to this party, but here's another option...
 

Offline dcelTopic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
Re: Interfacing a PIC w/ high-side mosfet
« Reply #24 on: April 08, 2012, 11:08:27 am »
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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf