Author Topic: PIC open-drain question  (Read 6158 times)

0 Members and 1 Guest are viewing this topic.

Offline step_sTopic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: dk
PIC open-drain question
« on: January 20, 2016, 09:41:19 pm »
Hi EEVblog.
Just wanted to ask a quick question about the open-drain feature on the PIC16F18324 (or any PIC in general).
What I have tried is to make the pin pull the gate from a P channel MOSFET low, when the PIC is running 3.3v and the MOSFET is running 5v.
The problem I'm getting is that the pull-up resistor will pull the gate to 5v (including the pin), and turn the MOSFET off. Current will start to flow in to the pin, even when it's suppose to be open, and that kind of defeats the purpose :/
Is it impossible to sink current from a higher voltage source than what the PIC is running at, or am I doing something wrong?

Hope you can help me.
 

Offline andre_teprom

  • Regular Contributor
  • *
  • Posts: 71
  • Country: br
    • Aluis-Rcastro
Re: PIC open-drain question
« Reply #1 on: January 20, 2016, 09:50:29 pm »
You could insert an NPN transistor between the MOSFET and the uC inwith the common-emissor toology, placing this resistor there.
"Part of the world that you live in, You are the part that you're giving" ( Renaissance )
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: PIC open-drain question
« Reply #2 on: January 20, 2016, 10:14:19 pm »
I'm not familiar with PICs, but they do have protection diodes, so perhaps the following video is relevant:

http://youtu.be/2yFh7Vv0Paw
« Last Edit: January 20, 2016, 10:36:19 pm by dadler »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4103
  • Country: us
Re: PIC open-drain question
« Reply #3 on: January 20, 2016, 11:29:24 pm »
^ yes. Short answer, ESD protection diode.

Consider there's a shottky diode between Vdd and each pin of the micro. Anode on the pin, cathode on Vdd. So any voltage greater than Vdd + 0.3V on the pin will be shorted to the Vdd rail.

There's also a shottky between the ground rail and each pin. Anode on ground rail and cathode on the pin. So any negative voltage applied to the pin that is less than -0.3V will be shorted the ground rail.

If your PIC can run on 5V, of if there's a 5V version, problem would be solved.

Quote
Is it impossible to sink current from a higher voltage source than what the PIC is running at, or am I doing something wrong?
It's impossible to not sink current from a higher voltage source than what the PIC is running at.
« Last Edit: January 20, 2016, 11:39:35 pm by KL27x »
 

Offline step_sTopic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: dk
Re: PIC open-drain question
« Reply #4 on: January 21, 2016, 12:41:16 pm »
Thanks guys, I see the ESD diodes are causing the problem :)

@andre_teprom
Ye, that seems like the only option. The issue here is that it's going to controlled by a PWM, so i might need 2 transistors for a push-pull system or use an op-amp, since the frequency is around 1MHz in a buck converter.
 

Offline Daving

  • Contributor
  • Posts: 34
Re: PIC open-drain question
« Reply #5 on: January 26, 2016, 07:50:32 am »
There may be some 5v tolerant pins on the device.  They'll usually be marked on the pin diagram near the beginning of the datasheet.  If you plan to connect 5V directly to the pin, then you should use those.

Otherwise there's a number of level shifting circuit designs out there.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: PIC open-drain question
« Reply #6 on: January 26, 2016, 08:17:54 am »
There may be some 5v tolerant pins on the device.  They'll usually be marked on the pin diagram near the beginning of the datasheet.  If you plan to connect 5V directly to the pin, then you should use those.

Otherwise there's a number of level shifting circuit designs out there.

Precisely, there's no point in having 5V tolerant pins if, well, they're not.

I'll give it a go later today if this is still a problem, I have some 18313s and 18325s which are pretty much the same device with either a different package or memory config.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: PIC open-drain question
« Reply #7 on: January 26, 2016, 08:43:22 am »
There may be some 5v tolerant pins on the device.  They'll usually be marked on the pin diagram near the beginning of the datasheet.  If you plan to connect 5V directly to the pin, then you should use those.

Otherwise there's a number of level shifting circuit designs out there.

Precisely, there's no point in having 5V tolerant pins if, well, they're not.

I'll give it a go later today if this is still a problem, I have some 18313s and 18325s which are pretty much the same device with either a different package or memory config.

Right, I just tried this. The pins aren't actually "5V tolerant" like many 3.3V or below PIC devices. They will go to Vdd, and do open drain, but no, despite the open drain they will not go to 5V because as others have stated, there's an ESD diode to Vdd. I measured it on the scope, if I use a 3.3V Vdd and a 10k pullup on the OD output to 5V, it stops at 3.9V, essentially Vdd + Vdiode.
 

Offline Daving

  • Contributor
  • Posts: 34
Re: PIC open-drain question
« Reply #8 on: January 26, 2016, 04:27:03 pm »
I just double checked the datasheet, and none of the pins are 5V tolerant.  They're spec'd to Vdd +.03

I attached a picture showing an example of what I was talking about.

Anyway, spark fun shows a schematic of how to do bi-directional level shifting if that's what you need.
https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: PIC open-drain question
« Reply #9 on: January 26, 2016, 05:23:57 pm »
Bidirectional level shifters generally have sh*tty risetimes due to the use of passive pullups + the MOSFET gate capacitance.  If its a unidirectional signal they are best avoided.    Either use a dedicated unidirectional level shifter, or, on the cheap, for 5V =>3.3V a resistor divider (or series resistor if the ESD diode can safely handle the clamping current with no side effects), possibly with a few pF of speedup capacitance across the upper or series resistor.  Going 3.3V to 5V, if a dedicated level shifter cant be justified, its hard to beat HCT logic powered from the 5V rail.

DO *NOT* take any analog capable PIC pin outside the supply rails by more than 0.3V. See Microchip's TB3013 for reasons why.  Its not just a theoretical issue - problems reported on the Microchip forums from ignoring this, apart from general misbehaviour on oter analog channels have ranged from 60% oscillator speed errors to false BOR resets.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: PIC open-drain question
« Reply #10 on: January 26, 2016, 05:31:33 pm »
I just double checked the datasheet, and none of the pins are 5V tolerant.  They're spec'd to Vdd +.03

I attached a picture showing an example of what I was talking about.

Anyway, spark fun shows a schematic of how to do bi-directional level shifting if that's what you need.
https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide

That was exactly what I had in my mind too. I've been working extensively with these PIC16F183xx devices over the past ten days or so too.  :P

Generally 5V tolerant is only on 3.3V-only sub families it would appear, and sub families with 5V variants don't have them.

Is there a reason that the OP needs to run the 5V PIC on 3.3V while the MOSFET is on 5V?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf