PIC open-drain question - Page 1
Forum section: electronics / general

author: step_s
author_rank: Regular Contributor
timestamp: January 20, 2016, 09:41:19 pm
content: 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.

author: andre_teprom
author_rank: Regular Contributor
timestamp: January 20, 2016, 09:50:29 pm
content: You could insert an NPN transistor between the MOSFET and the uC inwith the common-emissor toology, placing this resistor there.

author: dadler
author_rank: Unknown
timestamp: January 20, 2016, 10:14:19 pm
content: I'm not familiar with PICs, but they do have protection diodes, so perhaps the following video is relevant:http://youtu.be/2yFh7Vv0Paw

author: KL27x
author_rank: Super Contributor
timestamp: January 20, 2016, 11:29:24 pm
content: ^ 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.QuoteIt's impossible tonotsink current from a higher voltage source than what the PIC is running at.

author: step_s
author_rank: Regular Contributor
timestamp: January 21, 2016, 12:41:16 pm
content: Thanks guys, I see the ESD diodes are causing the problem@andre_tepromYe, 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.

author: Daving
author_rank: Contributor
timestamp: January 26, 2016, 07:50:32 am
content: 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.

author: Howardlong
author_rank: Super Contributor
timestamp: January 26, 2016, 08:17:54 am
content: Quote from: Daving on January 26, 2016, 07:50:32 amPrecisely, 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.

author: Howardlong
author_rank: Super Contributor
timestamp: January 26, 2016, 08:43:22 am
content: Quote from: Howardlong on January 26, 2016, 08:17:54 amRight, 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.

author: Daving
author_rank: Contributor
timestamp: January 26, 2016, 04:27:03 pm
content: I just double checked the datasheet, and none of the pins are 5V tolerant. They're spec'd to Vdd +.03I 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

author: Ian.M
author_rank: Super Contributor
timestamp: January 26, 2016, 05:23:57 pm
content: 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'sTB3013for 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.

author: Howardlong
author_rank: Super Contributor
timestamp: January 26, 2016, 05:31:33 pm
content: Quote from: Daving on January 26, 2016, 04:27:03 pmThat 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.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?