![]() |
Forum Index : Microcontroller and PC projects : GPIO voltage protection
Author | Message | ||||
helltek Newbie ![]() Joined: 04/02/2015 Location: United StatesPosts: 29 |
Hi, What do you guys use for voltage protection on bi-directional gpio pin? On single direction low speed I would use optocoupler. What should I use on bi-directional 5 - 16 VDC I/O ? |
||||
panky![]() Guru ![]() Joined: 02/10/2012 Location: AustraliaPosts: 1114 |
Hi helltek, For common ground referenced digital input in the range 5VDC to 16VDC, a simple 3.3V zener clamp would protect the input. If you need to go digital out to a 5VDC to 16VDC load, then a transistor or MOSFET driver would do the job. If the input or output is to be a floating source/load, then an opto isolator would be required. panky ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
G'Day both. I think we need more detail about what is required. Opto isolation is very good for input and there are devices available to drive all sorts of outputs. Matherp has been flogging a nice sounding chip for that sort of thing but if you want to be able to control direction using software it will get messy. But nothing is impossible. Peter |
||||
helltek Newbie ![]() Joined: 04/02/2015 Location: United StatesPosts: 29 |
The problem I see is that using transistor or optocoupler (which is transistor) I would create infinite loop. The input voltage would turn on the output transistor and never release it, probably shorting the peripheral and burning it out when it tries to switch low to high. |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
If you connect a 330 ohm resistor from a micro output pin to an external circuit the external circuit can be an input or an output. If the micro is set as output and the external circuit is an input it will work. If the micro is set as input and the external circuit is an output it will also work. That is however, not real good. It can be improved by adding diodes to prevent the micro from being over-voltaged but it is still far from ideal. Is that something like what you are looking for? Peter Edited 2020-03-12 20:12 by PeterB |
||||
helltek Newbie ![]() Joined: 04/02/2015 Location: United StatesPosts: 29 |
330 ohm would limit current to about 10mA which is quite high. Safe current for TTL logic is about 2-3mA and that would be to low to pull the output down to zero volts. It would hang somewhere in between 0 and 3.3V, not being recognized as either 1 or 0. Take as an example Maxim Dallas 1-wire communication. It works because the micro has 5V tolerant pin. If the signal was 12V, that would require voltage level converter like serial RS-232 to TTL and two pins (input pin and output pin). I'm not sure if there is any way to make it work reliably. |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
Sorry helltek but I don't think I can contribute anything of use. Perhaps some of our smarter members can help. Peter |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
Dear Helltek, There are 2 common type of opto couplers, and some less common types. The common types are : LED-Phototransistor optocouplers (i.e. TIL111). These optocouplers are cheap, and over a large range exhibit a analog behaviour. Main parameter involved is the CTR (current transfer ratio). This is the gain (in current) of the opto coupler. If you drive the LED with 2mA, and have a CTR=100(%), the phototransistor will draw 2mA. If you drive 10mA, the phototransistor will draw 10mA. Check the datasheet of your optocoupler to find the CTR (or CTR range). Sometimes it is 50%...200%, in which case you should calculate with 50%.. just to make sure. To drive 2mA from a 3.3V digital output you need a series resistance of roughly 800 ohms. To make sure the output of the optocoupler has a logic output (well saturated) at 2mA, -- note ..this assumes a CTR of 100%) design the pullup resistor for 25% of the 2mA (0.5mA). Using 5V logic, the resistor should be (5/0.0005 = 10k). The list of optocouplers of this type is endless. They are the most common. Differences are in: 1/ CTR 2/ isolation voltage (i.e. 3750V) 3/ immunity (CMRI) i.e. 5000V/uSec) 4/ Package (SMT/TH) 5/ minimum LED current 6/ max voltage for output transistor 7/ isolated base of output transistor / base connected to pin LED-digital optocouplers These optocouplers have build in schmitt triggers (comparator). These have fixed analog bias and threshold. Therefore you must drive the LED of these optocouplers exactly as described in the datasheet. These optocouplers have logic outputs. The classical digital optocouplers (i.e. 6N136) require quite a bit of LED drive (i.e. 10mA). But the more modern ones (i.e. TLP2745) require only 2mA and can be driven directly from logic. Other optocouplers: - MOSFET output optocouplers (directly drive a FET, no isolated power supply is needed). Typically these MOSFET's optocouplers are not fast or powerfull. - Ananlog optocouplers (2 or 3 identical optocouplers designed for analog isolation in combination with an external opamp). Then there are digital isolators These are typically used for isolating high speed signals. Multiple channels per package. They use capacitive or inductive coupling (not optic) and use modulators/demodulators in each channel. I hope this helps Volhout PicomiteVGA PETSCII ROBOTS |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |