SPI isolation using optocouplers - Page 1
Forum section: electronics / projects

author: void_error
author_rank: Frequent Contributor
timestamp: October 18, 2014, 10:28:01 am
content: Title pretty much says it.After searching the web for ways of electrically isolating the SPI bus (the part with ADCs & DACs) which is part of my bench power supply I found a few rather hard to get specialized chips. I need the isolation because I'm going to have a USB connection to the PC (one that's built into the microcontroller, not going for FTDI) and the PSU itself will be floating.As LED-phototransistor optocouplers are cheap that's my first option, but I'll need to find a way to tri-state them, probably using the chip select signal. Can it be done?

author: bobcat
author_rank: Regular Contributor
timestamp: October 18, 2014, 10:39:51 am
content: Thats the way to do it. Just add another coupler for the CS and use it to drive the enable on a three state buffer.

author: void_error
author_rank: Frequent Contributor
timestamp: October 18, 2014, 10:54:18 am
content: Any recommendation for a common tri-state buffer? I could also go with a multiplexer I suppose. It has to be on the microcontroller side though which is not a problem.EDIT: Nevermind, found a 74HCT125. Output enable active low.

author: bobcat
author_rank: Regular Contributor
timestamp: October 18, 2014, 10:58:56 am
content: device selection is not critical, just as long as it is speed and voltage rated for your application.

author: macboy
author_rank: Super Contributor
timestamp: October 18, 2014, 01:32:02 pm
content: Quote from: void_error on October 18, 2014, 10:28:01 amI prefer to use a USB-serial chip (e.g. FTDI as you mentioned) and isolate the UART lines. Then you only have one low speed signal in each direction to isolate, and the microcontroller can interact directly with all of of the rest of the circuit. Doing optocouplers on multi-MHz SPI lines is not as easy as a 115k2 uart line.

author: MarkL
author_rank: Unknown
timestamp: October 18, 2014, 02:40:19 pm
content: Take a look at Analog Devices iCoupler devices. They have a large selection of uni- and bi-directional channels, isolation voltages (up to 5kV), speed, and some specialized for USB, I2C, CAN, etc. They even have some devices that can move a limited amount of power across the isolation barrier to power your circuit on the other side (all integrated onto one chip).http://www.analog.com/en/interface-isolation/digital-isolators/products/index.htmlInternally, they use the CMOS process to create on-chip transformers, so they're actually magnetic and not optical devices. I don't think I'll ever use an opto isolator again in a design for digital data. These things just work.

author: void_error
author_rank: Frequent Contributor
timestamp: October 18, 2014, 02:57:57 pm
content: Quote from: macboy on October 18, 2014, 01:32:02 pmI gave that a thought as well. The SPI clock frequency can be as low as 1/256 of the PIC oscillator frequency, I'll have to scavenge for some optocouplers in my junkbox and look for rise/fall times.Might go for a FTDI-SPI chip though... and a small DC-DC isolated converter.Quote from: MarkL on October 18, 2014, 02:40:19 pmI've run into those while searching. They're quite expensive compared to optocouplers and the suppliers that can get them shipped at a reasonable price (I'll need like two of them max) don't have what I'm looking for.

author: tom66
author_rank: Super Contributor
timestamp: October 18, 2014, 03:02:51 pm
content: How about one of these devices?http://www.farnell.com/datasheets/1816589.pdf

author: void_error
author_rank: Frequent Contributor
timestamp: October 18, 2014, 10:37:51 pm
content: Quote from: tom66 on October 18, 2014, 03:02:51 pmWell, it's cheap and I can get it so it'll be one option. No idea how many I'm going to need though. Thanks for the suggestion.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 18, 2014, 10:47:56 pm
content: Optos suck at highish speed stuff like SPI. You can also get issues with slow clock risetimes.Digital isolators (e..g Silabs, NVE) are the way to go.

author: PJE
author_rank: Newbie
timestamp: October 18, 2014, 11:21:43 pm
content: Quote from: MarkL on October 18, 2014, 02:40:19 pmI second this approach. I used one in an industrial automotive production environment... Still working without any issue after 7 years!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 18, 2014, 11:30:00 pm
content: Optos are good for moderate speed stuff (1Mb/s, up to 10 is kind of pushing it), and cheap. iCouplers are more expensive but have fantastic specs, in particular the pulse timing is consistent (whereas optos suffer from time-dependent skew and delay), and the dV/dt rating is through the roof (enough to use on high speed, high voltage switchers), and they have DC stability and fail-safe states (if the transmitter side goes down). Competitors may be cheaper but I haven't seen that they offer the same guarantees. If you don't need that, you can be fine, but if you need the extra confidence I would suggest going with the original(?) brand.Tim

author: lgbeno
author_rank: Frequent Contributor
timestamp: October 19, 2014, 03:32:58 am
content: Having done a lot of research on the topic, if you don't need a very special agency approval in the data sheet for say 60601-1 reinforced insulation. The isolators from silabs are pretty much a no brainier

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 19, 2014, 09:11:14 am
content: And if you need something that looks just like an opto, with an input side that doesn't need power, NVE's passive-input isolators are nice.Another neat chip is AD's ADM2582, which is a single-chip isolated RS485 solution that integrates both power and data isolation. Not cheap unfortunately.

author: void_error
author_rank: Frequent Contributor
timestamp: October 19, 2014, 10:16:26 am
content: Quote from: mikeselectricstuff on October 18, 2014, 10:47:56 pmHow about digital output optos, like H11Lx series or 6N137? I guess they should work with lower SPI clock speeds, only having two ADCs and two DACs which don't have to run at high speed. To put it short I have at least a 100ms window to communicate with them which is an eternity in the world of microcontrollers.Quote from: T3sl4co1l on October 18, 2014, 11:30:00 pmCheap is good. I don't need more than 1Mbps.Quote from: lgbeno on October 19, 2014, 03:32:58 amThe only special approval will be from me - this is part of a pesonal project. I'm also trying to avoid using fancy/expensive specialized components.

author: mij59
author_rank: Frequent Contributor
timestamp: October 19, 2014, 01:48:34 pm
content: You could use the AD ADuM3154 for spi.But since you don't need high speed communication use an I2C bus with the adum1251.

author: David Hess
author_rank: Super Contributor
timestamp: October 19, 2014, 02:22:04 pm
content: Quote from: void_error on October 18, 2014, 10:28:01 amWhy do any of the signals need to be tri-stated to isolate SPI? They are all unidirectional.Quote from: mikeselectricstuff on October 18, 2014, 10:47:56 pmSPI is generally not that fast and its synchronous nature relaxes constraints on signal fidelity. I would use optical isolation at least up to 10 MHz.

author: void_error
author_rank: Frequent Contributor
timestamp: October 19, 2014, 02:53:01 pm
content: Quote from: David Hess on October 19, 2014, 02:22:04 pmThe isolated SPI peripherals are not the only ones that connect to the MCU, there are going to be some other non-isolated ones. In other words, there's going to be more than one SDO from peripherals feeding into the MCU's SDI pin. Pulling the CS pin low will put the peripheral's SDO from hi-Z mode into output mode. I'll come up with a schematic soon.Quote from: David Hess on October 19, 2014, 02:22:04 pmNot planning to go over 1MHz. Apart from the SPI stuff I'm going to have some multiplexers to connect some other signals to the ADC inputs.My question is whether to use logic output optocouplers or transistor output ones, the latter being slower?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 19, 2014, 03:11:58 pm
content: 4N35 level optos are pretty bad, you wouldn't want to use them above 100kbps or so withoutspecial hardware. (Hmm, I have the schematic of the circuit I was referring to, but it doesn't look like I posted it there.)For doing better on the cheap, I would go with 6N136, or the high dV/dt equivalent SFH6345 (be warned, the dV/dt rating on 6N136s isverymisleading). They're good to 1Mbps easily.Both of these, you just add a pull-up to the open collector output. Or the 4N35 can be wired "emitter follower" style (though it's not actually following anything), in case you need the diode end in a particular direction and you need the inverted (or not) output. (You can't invert a 6N136 output in the same way without defeating the high speed feature.)For more, I'd go with logic level parts, or iCoupler style devices. There may also be power advantages, say, if you need to be miserly with battery power (a logic level opto probably uses less bias on the output side).If you need to be really miserly, you might resort to building your own (say with planar coils and RF design). But, geez...Tim

author: void_error
author_rank: Frequent Contributor
timestamp: October 19, 2014, 03:41:23 pm
content: Quote from: T3sl4co1l on October 19, 2014, 03:11:58 pmHow about this one?http://www.tme.eu/en/Document/724e01c6de3535b2bc18f091ff16d8f9/6N137.pdfLess than $1 each in small quantities and they seem fast enough, on paper at least.I'd need at least 6 of them, 3 for ChipSelect (2 single ADCs and 1 dual DAC) 1 for SCK, 1 for SDI and 1 for SDO. The rest of them are going to be used for the multiplexers.

author: David Hess
author_rank: Super Contributor
timestamp: October 19, 2014, 05:26:35 pm
content: Quote from: void_error on October 19, 2014, 02:53:01 pmOk. That makes sense. When I did this in the past, I multiplexed the signals together on the non-isolated side or used separate SPI ports. You already have CS on the non-isolated side and that may be used to disable the output from the optocoupler or whatever you use that is driving the microcontroller's SDI pin if you do not want to add a digital multiplexor. If you want to drive lots of isolated SPI peripherals though, then you probably want to multiplex those on the isolated side which again, is not difficult because the isolated CS signal is there to do it.QuoteI prefer the transistor output ones because of cost but you need access to the transistor's base to get high speed which limits your selection somewhat.The other mentioned solutions for digital isolation are more integrated and so take up less space but cost more.If you want a lot of isolation way beyond regulatory requirements, then separate LEDs and phototransistors can be used with light pipes. High precision multimeters often use this approach.

author: David Hess
author_rank: Super Contributor
timestamp: October 19, 2014, 05:33:16 pm
content: Quote from: T3sl4co1l on October 19, 2014, 03:11:58 pmYou can get a huge amount of extra speed if you have access to the base lead and use external signal conditioning.QuoteGate drive and Ethernet transformers work well for this but need more signal conditioning then most people are willing to design these days.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 19, 2014, 07:11:36 pm
content: Quote from: void_error on October 19, 2014, 03:41:23 pmSure. Or you might consider a decoder or SPI expander, so you only need two CS isolators, or even just one: high = selects the expander, low = anything else. Use a decoder/demux to turn the one CS into an "any other device you want" fanout. Only need one at a time, after all.Beware the CM immunity: Fairchild specs those at only 50V. Although looking at the Vishay datasheet, they specify excellent CM and amplitude, so they should be okay from anyone.Tim

author: IanJ
author_rank: Unknown
timestamp: October 19, 2014, 07:52:37 pm
content: Hi,I have used Silicon Labs devices to isolate I2C (bidirectional in one device), worked great on my Bench PSU.Might be worth checking them out.http://www.silabs.com/Marcom%20Documents/Resources/Isolation-Selector-Guide.pdfIan.

author: void_error
author_rank: Frequent Contributor
timestamp: October 19, 2014, 08:35:34 pm
content: After a bit of head scratching I'm down to one ADC, one DAC, one mux (4051) and some ISO722x/ISO723x, haven't decided which ones/how many yet. Datsheet herehttp://www.ti.com/lit/ds/symlink/iso7230m.pdf.The ISO7231 is probably the best choice as it is capable of hi-Z mode via an enable pin.The DAC only has SDI while the MCP3551ADC only has SDO, the clock being common, so only the ADC will output data back to the MCU.I'll probably use transistor output optocouplers (or whatever is the cheapest) for the CS lines and mux address. If there are issues with rise/fall times I'll add some schmitt trigger buffers and some software delay before I start clocking bits in and out.Unfortunately I'm limited to only a handful of component distributors because of shipping costs / lead times (I hate waiting 5 weeks for the damn parts to get here).

author: void_error
author_rank: Frequent Contributor
timestamp: October 20, 2014, 03:21:05 pm
content: Quote from: IanJ on October 19, 2014, 07:52:37 pmFound something that I can get from my main distributor - the Si8441.Ditched the optos, although they could have replaced two Si8441s. Couldn't be bothered to add a bunch of resistors.As Ipromisedmentioned earlier... schematic (unfinished):