How do you select optoisolator current?  Does it affect switching speed? - Page 1
Forum section: electronics / beginners

author: mr_darker
author_rank: Contributor
timestamp: December 29, 2018, 05:27:40 am
content: This is a bit embarrassing but I have a device that is essentially just an optical isolator hooked up to a UART port, and I don't know how to figure it out xD I want to know for sure rather than wing it.Using this isolator:https://www.digikey.com/product-detail/en/lite-on-inc/LTV-826S/160-1363-5-ND/385833I have a protocol that operates on 9600 Baud communication, meaning 104 microseconds per bit.This isolator has a maximum rise and fall time of 18 microseconds, almost 20% on each end! I don't know if this is consistent and just ends up offsetting the whole data dealio, or if it ends up distorting the bits. Also, the protocol requires a minimum/maximum of 15mA on the TX/RX lines, paired with a minimum 50% current transfer ratio, I need to have at least 30mA on the input of an isolator to guarantee 15mA on the other end, but the input can handle an absolute maximum of 50mA. SO, how do you go about mathematically selecting the single best current to send through this (a value between 30 and 50? If you go higher or lower, does it affect the switching time? Or is it all irrelevant and do you just go off of the minimum current you can use?I ask because I've tried a while back, and may have set the resistors wrong, maybe not, but the switching time was so slow that even at 9600 baud, you had bits bleeding about halfway into the next ones.

author: spec
author_rank: Frequent Contributor
timestamp: December 29, 2018, 11:21:15 am
content: Hi mr_darker,That optocoupler is a touch slow for 9600 baud (104us), although it could probably be made to work. But we would need to see a schematic of the interface and a specification and also a description of the application to take this any further.

author: nsrmagazin
author_rank: Regular Contributor
timestamp: December 29, 2018, 02:13:03 pm
content: Otherwise all we can tell you is that normally the voltage counts for this interface, the current is very small and you can ignore it(set it at 1ma to 5mA).

author: mr_darker
author_rank: Contributor
timestamp: January 02, 2019, 04:51:47 pm
content: Ranges really bug me, like I need to know an exact & single most correct answer or I get anxiety about it like I made the less-right decision. xDI've included a schematic, and am trying to write out the formula to use, to get the resistor values. I'm writing a tutorial (which is why I'm trying to make sure I'm right first), so giving a formula where people can plug in the values associated with their device is easiest. It could be a 5 volt device or a 3.3 volt device (I managed to get a 3.3 volt one working using optoisolators). Also each device is going to have current limits on the I/O pins which factor into it.The isolator used is the LTV-826https://media.digikey.com/pdf/Data%20Sheets/Lite-On%20PDFs/LTV-816_826_846.pdfAlso I want to include the LTV-816 as that's the isolator I originally used. It'd really be cool to have values from the datasheet in the formula so you can just use any isolator and plug values into the formula to see if it will work.From what I know, factors are:VoltagesCurrent Limits of both the device/peripheral, the isolators (50mA)The VMC's requirement that its RX line be sunk with at least 15mA, and the specification that it will source a maximum of 15mA on its TX lineForward LED voltagePossibly switching times, but it seems like it'd just delay the data as long as it rises/falls at the same speed & within 104 microseconds.It's a vending machine connecting to a MDB/ICP (Multi Drop Bus/Internal Communication Protocol) device.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 02, 2019, 05:23:43 pm
content: The speed of optocouplers tend to go up a little with high LED current. The specs are for something like 5 mA and 20 mA LED current. The 20 mA, maybe 15 mA seem to be a good value. Going to close to the absolute maximum of 50 mA may cause more aging.As the specs seem only guarantee 15 mA souring more current is not a real option. It's more like limiting the current to some 15 mA, even if the source is stronger.However the worst case CTR at 50% is not sufficient. So at the worst case CTR it would need at least 30 mA to the 15 mA out. This may still work, but not really far from absolute limits. So one may have to look at a different OK.The speed also depends quite a lot on the loading the the opto-coupler. They get slower of they go deep in to saturation (e.g. turning on the transistor hard). Also cable capacitance at the output can be a factor. Just 9600 baud should still work even with saturation however.The switching times give a delay, but the delay can be different for turn on and turn off, with the tendency for turn on to be faster.

author: mr_darker
author_rank: Contributor
timestamp: January 02, 2019, 05:58:35 pm
content: Odd, I remember looking things up quite a bit but I easily find much more suitable alternatives now. I don't quite remember how I was looking things up, but I find one that's smaller, and has a better current transfer ratio, as well as much faster rise and fall times. I remember back then the 18 or so microsecond rise/fall times were the fastest suitable ones I could find. Must have messed up somehow.First one I find is much better: TLP290My original question I think you've answered though. Higher LED current switches it on faster, and also makes it switch off slower? (switching off is the part I couldn't just imagine). So it's almost never going to be even unless setting it up to be that way, and then it'd just be by chance whether or not the voltage/current settings that this occurs with, works in the circuit i'm makingSo in short, just find one with a bigger transfer ratio and shorter switching times.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 02, 2019, 07:31:36 pm
content: The TLP290 is marked not recommended for new designs and the worst case CRT is also 50%.From my experience 9600 baud usually work with standard OK, unless the loading side is too high in impedance. So it's mainly about finding some with a CTR of >100 % worst case.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 02, 2019, 09:22:03 pm
content: Right, not only is it slow to begin with, but take careful note of the drive current, load resistor and output voltage!You aren't going to get full logic levels out of this, not very cleanly.What to do? A phototransistor (3 terminals, including base) can be sped up by removing spare charge from the base region -- the base junction is a solar panel and that's what turns on the transistor when illuminated, but it also has a lot of capacitance. By shunting it to emitter with a resistor, that capacitor discharges more quickly. Downside, this also reduces CTR, particularly at low drive currents. But it can be a worthwhile trade.The biggest downside is, few datasheets tell you what values of B-E resistor are acceptable, for some minimum CTR you need to design around.A phototransistor can also be used in a transimpedance amplifier. I've ran a 4N35 at over 600kbps this way; the output was analog (needs a comparator to get logic level output), and the circuit used 4 transistors (or a single opamp could be used, just as well). But this is kind of heroic in terms of effort, compared to better alternatives.The usual approach for faster-than-glacial signaling, is a 6N136 (or better yet, SFH6345) which offers logic level capability at 100kbps, or a 6N137 or other similar highspeed logic opto that offer 10Mbps or more. Beyond there, digital isolators (usually based on very small (on chip) transformers or capacitors, and a pulse or FM modulated communication scheme) take over. Still further... you might as well go fiber, which can take you into the Gbps if you like.Tim

author: Kleinstein
author_rank: Super Contributor
timestamp: January 03, 2019, 08:21:27 am
content: Fiddling with a resistor across base and emitter can improve speed, but from my test advantage was not that high. Much of this is more like adjusting the sensitivity and avoiding deep saturation. Without the resistor I get the 4N35 running up to 9600 baud running to an RS232 without extra level shifting or amplification. With the resistor 19200 did work most of the time.The 9600 baud should not be the real problem even for one of the slower couplers, the problem is more with the CTR and possibly the extra cable capacitance.

author: nsrmagazin
author_rank: Regular Contributor
timestamp: January 04, 2019, 09:17:01 am
content: Using a photo coupler for RS232 is not even necessary. To begin with RS232 was developed to remove all noise, that is why it had "+-25VDC" swing maximum and "+-15VDC" or "+-12VDC" were used. This is a huge border, all the noise is absorbed.In modern days we do not use such high voltages, because everything is suppose to be with high efficiency. Therefore we use a swing of "0VDC"(formerly -15VDC) to "5VDC"(formerly +15VDC). This is no longer RS232, its a variation, but we still call it RS232 because its almost the same.For consideration:-Will the 5VDC swing be enough for your application? What are your noises? Keep in mind that the full "5VDC" will not be used, instead if tour RS232 is TTL logic you will have "2VDC" or more for high, "0.8VDC" or less for low.-The distance also matters, the isolation of the conductors(if its a PCB trace the EMC) and possible intereferences.

author: spec
author_rank: Frequent Contributor
timestamp: January 04, 2019, 11:33:24 am
content: This should be a bit of help in arriving at an answer:https://en.wikipedia.org/wiki/Multi-Drop_Bus_/_Internal_Communication_ProtocolThe physical connection is realized as a serial bus with a fixed data rate of 9600 baud. There are just 2 communications signals plus the essential common-ground reference signal. The TX signal goes from the MASTER to every SLAVE device. The RX signal goes from every SLAVE device to the MASTER device. Both signals have pull-ups. The bus is driven at every transmitter by an open collector transistor driver, and isolated at each receiver with an opto-isolator - though cable harnesses carrying the communication signals may also carry 24-volt power and ground signals to devices, meaning the devices may not be isolated from each other as they share the same power bus. Some devices, however, may have alternate power supplies, especially devices with motors and high current needs such as vintage bill acceptors or currency detector devices.https://www.ccv.eu/wp-content/uploads/2018/05/mdb_interface_specification.pdf(Section 4)

author: AndyC_772
author_rank: Super Contributor
timestamp: January 04, 2019, 12:27:06 pm
content: Quote from: nsrmagazin on January 04, 2019, 09:17:01 amA relatively large voltage swing doesn't eliminate the need for isolation. Even disregarding the differences there may be in ground potential between two pieces of equipment, a direct connection means no safety barrier.QuoteNo, "we" don't use logic levels and call it "RS232".A logic-level (0-5V or 0-3.3V) UART interface is a logic-level UART interface. It's not RS232 and should *never* be called as such. These levels are not compatible with RS232-compliant ports.For any port on modern equipment that's designed to connect to an RS232 port, designers typically use a level shifting device like the MAX232, which contains a voltage doubler and a voltage inverter to give about +/- 9V from a 5V supply. The output from such a device is typically RS232compatible, even if it's not strictly RS232compliantbecause the voltage levels at the transmitter are reduced compared to true RS232 levels.Note that a logic level interface typically idles at +5V or +3.3V, which corresponds to a negative voltage on a true RS232 port. RS232-compatible level shifters effectively invert the signal as well as amplifying it.

author: MrAl
author_rank: Super Contributor
timestamp: January 04, 2019, 01:17:45 pm
content: Hi,Opto couplers are used to electrically isolate the two devices that need to communicate.Thus if you have a meter with RS232 and opto coupling connected to your computer and you accidentally measure a 1000 volt signal, you blow out the meter but you dont blow out the computer.Granted these optos have their limitations too, but it's usually 2000v or more (check specs).

author: nsrmagazin
author_rank: Regular Contributor
timestamp: January 04, 2019, 08:10:31 pm
content: A swing at "+-15VDC" elimates 95% of all possible on the planet noises!There is no noise that is "12VDC" and can activate the circuit!Yes we DO call it RS232, we shouldn't thats true, but we still DO!I have never seen an opto-coupler on any RS232 or variations installation! Sometimes they put it on the "5VDC" and "3.3VDC", but like I said in the previous post, what are your distances and noises!?And please don't try to distort the situation, my description is accurate!

author: pwlps
author_rank: Frequent Contributor
timestamp: January 04, 2019, 10:39:12 pm
content: Hi,Quote from: mr_darker on January 02, 2019, 05:58:35 pmInstead of trying to adapt the CTR, pullup resistors etc. to get the current and voltage specs you need, it would be much easier to use an optoisolator with an integrated logic output. In a similar design I was using a HCPL2200:https://docs.broadcom.com/docs/AV01-0557ENwhich should meet your specs too. Another advantage is that it has a hystersesis in the transfer function (a Schmidt trigger is included) to prevent false transistions caused by spikes or oscillations on the pulse edges (NB. your circuit is not very safe regarding this issue: in principle Schmidt triggers should have been inserted between the optocouplers and the peripheral connections).The logic "on" output voltage of HCPL2200 follows the supply voltage (up to 20V) so you don't need any pullup resistor on "PERIPHERAL RX" (and with 5V supply the output can sink more than 20mA). The input "on" threshold is only 1.6mA and the forward current should not exceed 5mA so if you need to sink 15mA on "PERIPHERAL TX" you will need to add a shunt resistance between R2 and PERIPHERAL TX.As there is a high gain amp inside the optocoupler it is recommended to put a 10nF decoupling capacitor across the supply pins (otherwise sometimes the ouput might oscillate, depending on your PCB layout).

author: spec
author_rank: Frequent Contributor
timestamp: January 05, 2019, 04:00:59 pm
content: Quote from: pwlps on January 04, 2019, 10:39:12 pm+ pwlpsA logic coupler, (opto, inductive, capacitive) would be perfect for the Slave RX (from the master). But, AFAIK, you cannot use a logic coupler for the Slave TX to the Master, because logic coupler outputs are not isolated- they are tied to the host (slave) supply lines.The slave RX design is quite straight-forward. It is the slave TX design that is the difficult bit, because you have to sink 15mA and most decent speed couplers can only sink 8mA. Or, with the high current couplers, the speed suffers. as does the saturated current CTR. This means that the slave would need to drive the coupler input LED with about 32mA to sink 15mA at the coupler output, at the Slave output TX line. But if you can find a coupler with the speed and a saturated CTR of 100% or better, you could get away with around 20mA drive, which some logic chips can provide.

author: pwlps
author_rank: Frequent Contributor
timestamp: January 05, 2019, 11:26:15 pm
content: Quote from: spec on January 05, 2019, 04:00:59 pmOk I wasn't clear here, of course I was thinking to use the provided supply/ground lines from the master ("PEREPHERAL_V+", "PEREPHERAL_0V"), otherwise of course it wouldn't make sense to use optocouplers with common supply lines.But in the meantime I realized that I had forgot another problem: the MDB/ICP bus needs open collector outputs on TX. (NB. HCPL2200 has a tri-state capability that could be used to simulate it but but if the board/software do not provide control for it then it is useless). The standard solution to make an active logic gate output behave like an open collector output consists in placing a Schottky diode in series so that it can only sink current. In this way an HCPL2200 (or equivalent) can be used on the slave TX side too: in short, the VCC/GND of HCPL2200 powered by PEREPHERAL V+/PEREPHERAL_0V and the Vout of HCPL2200 connected to PEREPHERAL RX via a Shottky in series.What do you think?

author: spec
author_rank: Frequent Contributor
timestamp: January 06, 2019, 12:19:28 am
content: Quote from: pwlps on January 05, 2019, 11:26:15 pmI will have a look at this later- I am just about to post a schematic that I have come up with for the slave comms.

author: spec
author_rank: Frequent Contributor
timestamp: January 06, 2019, 12:26:50 am
content: UPDATE #1 of 2019_01_07 (text and R2 on schematic changed)UPDATE #2 of 2019_01_07 (text and R2 on schematic changed)Hi mr_darker,Attached below is the level 1, hardware specification for the Multi Drop Bus (MDB) comms, extracted from the MDB protocol document attached to reply #10Also attached is a schematic showing a circuit that should provide the MDB comms, at an adequate speed, for a Slave. The Slave RX line (Master TX) minimum inactive current requirement has been ignored for the present (not really sure what it means)As you say, the tricky bits are meeting the 9k6 baud rate and the MDB requirement of sinking 15mA minimum at 1V of less. I have looked at many couplers of all types and none easily meet the three conflicting requirements of, medium speed (9k6 baud), Input LED drive logic gate compatibility, and current sinking capability (15mA).But the LTV816SD single optocoupler comes the closest in that it could be a touch faster. This is a selected version where the 'D' indicates a minimum non-saturating current transfer ratio (CTR) of 300% (not available in twin or quad versions of this optocoupler). The minimum saturating CTR is not stated in the datasheet, so I decided to drive the optocoupler input LED with around 16mA, which must be supplied by the Slave logic. A 74LV245A duffer is shown as an example of a chip capable of sinking 32mA (for good measure), but there are other suitable logic chips. If the logic on the Slave is not capable of supplying the required current, fitting a suitable single logic element ('tiny') chip may be the solution. Note that an open drain/collector output is not suitable, but the circuit could be modified for OD/OC operation if required.It would be a good idea, but not essential, to use a Schmitt input logic element to accept the Slave on-board signal from the Master TX comms line.https://optoelectronics.liteon.com/upload/download/DS-70-97-0013/LTV-8X6%20series.PDFhttp://www.ti.com/lit/ds/symlink/sn74lv240a.pdf

author: spec
author_rank: Frequent Contributor
timestamp: January 06, 2019, 07:35:24 am
content: + pwlpsQuote from: pwlps on January 05, 2019, 11:26:15 pmIt is quite right that you can get the open collector function by using a Schottky diode, but when you add the low state output voltage of the logic optocoupler, the end result could be that meeting the MDB specification of 1V or less with a current sink of 15mA would be difficult. But, in any case, the logic optocouplers can only sink 8mA AFAIK.Quote from: pwlps on January 05, 2019, 11:26:15 pmYou have obviously put a lot of thought into ways to use a logic opto coupler. I have done the same, but without much success. It is the 15mA sink requirement that is the killer. Sorry to say though, that, in any case, your scheme, would not comply with the MDB specification, because the Slave output TX line would still be referenced to the Slave supply lines. The only way you could use your scheme would be to have an isolated 5V supply, generated by the Slave, to power the logic side of the logic optocoupler.

author: spec
author_rank: Frequent Contributor
timestamp: January 06, 2019, 08:25:35 am
content: + mr_darkerYou asked about factors that optimize optocoupler speed, and have had some good explanations by the other members. Here are a few more words starting with the very basic and general and working up to the more detailed and optocoupler specific:TYPES OF ISOLATING COUPLERThere are a number of different types of isolating couplers (there are also variations within a type. For example some optocouplers can be configured as type 1 or 3, depending on the connections used):LED input, photo diode output (medium speed+) (6N135/36)LED input, photo transistor output (medium speed) (LTV816/26/46)LED input, photo diode plus transitor output (medium speed-) (6N135/36)LED input, photo Darlington output (slow and high output saturation voltage) (PS2533)LED input, photovoltaic diode output (generates an output voltage/current rather than a change of resistance) (extremely slow) (TLP3905)LED input, host powered logic output (10Mbaud) (VO2601/31)Communications couplers (RS232, RS485, LVDVS, USB, etc) (10 Mbaud+)Capacitively coupled (150 Mbaud) (ICPL2630/31)Inductively coupled (150 Mbaud) (ADuM110N)CustomHaving investigated all types of isolating couplers, only type (2) above are covered further, as they are the only types that appear to be practicable for the MDB application, as far as I can tell that is.INPUT LED CURRENT AND CAPACITANCETo turn an optocoupler input LED on you need current: the more current the faster the optocoupler will turn on.To turn an optocoupler input LED off you need to remove the current and the faster you remove the current the faster the optocoupler will turn off.But there is a third factor. To change a current (increase or decrease) you need to change a voltage. The thing is that the LEDs on the input of optocouplers have a relatively high capacitances, so the voltage that controls the current flow, also needs to charge and discharge that capacitance.OPTOCOUPLER SWEET-SPOTThat takes care of the basic electronics side of things, but there is another factor. An optocoupler's performance, especially speed and Current Transfer Ratio (CTR), vary considerably with input current and, for many optocouplers, the sweet spot is 10mA input current. Any more input current does not increase speed significantly but you are in danger of exceeding the input LED's power rating.TURNING AN OPTOCOUPLER INPUT LED ON AND OFF FASTAfter all that, you have a dilemma. On one hand you need a relatively high current to turn the optocoupler on fast, but on the other hand you need to remove that current as fast as possible to turn the optocoupler off fast, and the more current that is there in the first place the more difficult it is to remove that current.So how do you turn an optocoupler on and off fast. The first thing to note is that all optocouplers have an inherent speed limitation, and there is nothing that you can do to change that, but what you can do is make sure that you drive the optocoupler input diode to get the highest speed out of an optocoupler that is possible. You do see circuits where the achieved speed is around 100x slower than the inherent optocoupler limiting speed. And in many applications this is acceptable, even desirable.The speed (delay) of an optocoupler has four distinct regions as shown on most optocoupler datasheets:on delayon rise timeoff delayoff fall timeUltimately, you cannot do much about the turn on and turn off delays. They are more a function of the optocoupler itself, but you can radically change the on rise time and off rise time.One last bit of optocoupler basics. The input of an optocoupler is simply a LED, although a very specialized one. And like all LEDs it has a maximum reverse voltage before breakdown and damage.HOST INTERNAL DRIVER CHARACTERISTICSArmed with all the above data you will be in a position to define the fastest way to drive an optocoupler host side input LED for maximum attainable speed:To turn on fast, provide a positive voltage step waveform with 0s rise time, limited to the input LED sweet-spot current. The initial part of the waveform should also allow additional current to charge up the input parasitic capacitance of the input LED.To turn off fast, provide a negative step voltage wave form with 0s fall time to a negative voltage 1V less in magnitude than the maximum LED reverse voltage. The negative waveform should be capable of providing infinite currentNote how far removed from the above ideal most optocoupler LED drivers are. One of the worst offending is the commonly used saturation transistor collector with serial current limiting resistor. This arrangement gives a fast turn-on, but a woefully slow turn off, where it just leaves the optocoupler input LED isolated in space with no route to lose its current and charge. Also, at turn off, the transistor needs to climb out of saturation, which is slow. The pull up resistor and pull down saturating transitor collector arrangement has a much faster turn off but significantly slower turn on, although the turn on can be made faster by replacing the pull up resistor with a constant current source..HOST INTERNAL RECEIVER CHARACTERISTICSThe host-side receiver is much simpler and less critical than the host-side optocoupler LED driver. The output is simply an open collector or drain which, with a pull up resistor can satisfactorily drive logic circuits. The value of pull-up resistor is a compromise between turn off speed (positive going) and CTR. On one hand you want a low value pull up resistor to increase pull up speed, but on the other hand you need a high value to make sure that with the current available from the output transistor that the output transistor will saturate and generate a good 0V logic level.There are some simple techniques to increase the performance/speed of the host receiver but these are not really worth the bother. It is a good idea, though, to make the input of the the unit receiving the signal a Schmitt trigger input type.HOST DRIVER LINE SIDEThere is not much you can do here as the characteristics of the line are normally predefinedHOST RECEIVER LINE SIDEOnce again, there is not much that can be done here, except to ensure that the current through the receiver LED is optimum and, worst case, does not exceed the receiver LED maximum current.

author: pwlps
author_rank: Frequent Contributor
timestamp: January 06, 2019, 08:17:41 pm
content: Quote from: spec on January 06, 2019, 07:35:24 amAh, right, somehow I overlooked the fact that there are only three wires on the VMC side, no power line in MDB. Maybe I shouldn't try to help people in electronics when I'm on ski vacation

author: spec
author_rank: Frequent Contributor
timestamp: January 07, 2019, 07:31:27 am
content: Quote from: pwlps on January 06, 2019, 08:17:41 pmAll ideas are good, as long as they are open for discussion.Have a nice vacation. I am cleaning the guttering on the house today.