Author Topic: SPI isolation using optocouplers  (Read 17259 times)

0 Members and 1 Guest are viewing this topic.

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
SPI isolation using optocouplers
« on: October 18, 2014, 10:28:01 am »
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?
Trust me, I'm NOT an engineer.
 

Offline bobcat

  • Regular Contributor
  • *
  • Posts: 94
  • Country: us
Re: SPI isolation using optocouplers
« Reply #1 on: October 18, 2014, 10:39:51 am »
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.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #2 on: October 18, 2014, 10:54:18 am »
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.
« Last Edit: October 18, 2014, 10:57:26 am by void_error »
Trust me, I'm NOT an engineer.
 

Offline bobcat

  • Regular Contributor
  • *
  • Posts: 94
  • Country: us
Re: SPI isolation using optocouplers
« Reply #3 on: October 18, 2014, 10:58:56 am »
device selection is not critical, just as long as it is speed and voltage rated for your application.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2254
  • Country: ca
Re: SPI isolation using optocouplers
« Reply #4 on: October 18, 2014, 01:32:02 pm »
... 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.
...
I 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.
 

Offline MarkL

  • Supporter
  • ****
  • Posts: 2131
  • Country: us
Re: SPI isolation using optocouplers
« Reply #5 on: October 18, 2014, 02:40:19 pm »
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.html

Internally, 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.

 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #6 on: October 18, 2014, 02:57:57 pm »
I 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.

I 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.

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.html

Internally, 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.

I'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.
Trust me, I'm NOT an engineer.
 

Offline tom66

  • Super Contributor
  • ***
  • Posts: 6707
  • Country: gb
  • Electronics Hobbyist & FPGA/Embedded Systems EE
Re: SPI isolation using optocouplers
« Reply #7 on: October 18, 2014, 03:02:51 pm »
How about one of these devices?
http://www.farnell.com/datasheets/1816589.pdf
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #8 on: October 18, 2014, 10:37:51 pm »
How about one of these devices?
http://www.farnell.com/datasheets/1816589.pdf

Well, 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. :)
Trust me, I'm NOT an engineer.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13748
  • Country: gb
    • Mike's Electric Stuff
Re: SPI isolation using optocouplers
« Reply #9 on: October 18, 2014, 10:47:56 pm »
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.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline PJE

  • Newbie
  • Posts: 2
Re: SPI isolation using optocouplers
« Reply #10 on: October 18, 2014, 11:21:43 pm »

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.html

Internally, 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.

I second this approach. I used one in an industrial automotive production environment... Still working without any issue after 7 years!
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: SPI isolation using optocouplers
« Reply #11 on: October 18, 2014, 11:30:00 pm »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline lgbeno

  • Frequent Contributor
  • **
  • Posts: 349
  • Country: 00
Re: SPI isolation using optocouplers
« Reply #12 on: October 19, 2014, 03:32:58 am »
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 
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13748
  • Country: gb
    • Mike's Electric Stuff
Re: SPI isolation using optocouplers
« Reply #13 on: October 19, 2014, 09:11:14 am »
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.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #14 on: October 19, 2014, 10:16:26 am »
Optos suck at highish speed stuff like SPI.  You can also get issues with slow clock risetimes.

How 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.

Optos are good for moderate speed stuff (1Mb/s, up to 10 is kind of pushing it), and cheap.

Cheap is good. I don't need more than 1Mbps.

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 

The only special approval will be from me -  this is part of a pesonal project  :P. I'm also trying to avoid using fancy/expensive specialized components.
Trust me, I'm NOT an engineer.
 

Offline mij59

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nl
Re: SPI isolation using optocouplers
« Reply #15 on: October 19, 2014, 01:48:34 pm »
You could use the AD ADuM3154 for spi.
But since you don't need high speed communication use an I2C bus with the adum1251.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16617
  • Country: us
  • DavidH
Re: SPI isolation using optocouplers
« Reply #16 on: October 19, 2014, 02:22:04 pm »
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?

Why do any of the signals need to be tri-stated to isolate SPI?  They are all unidirectional.

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.

SPI 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.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #17 on: October 19, 2014, 02:53:01 pm »
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?

Why do any of the signals need to be tri-stated to isolate SPI?  They are all unidirectional.

The 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.


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.

SPI 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.

Not 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?



Trust me, I'm NOT an engineer.
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: SPI isolation using optocouplers
« Reply #18 on: October 19, 2014, 03:11:58 pm »
4N35 level optos are pretty bad, you wouldn't want to use them above 100kbps or so without special 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 is very misleading).  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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #19 on: October 19, 2014, 03:41:23 pm »
4N35 level optos are pretty bad, you wouldn't want to use them above 100kbps or so without special 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 is very misleading).  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.)

How about this one? http://www.tme.eu/en/Document/724e01c6de3535b2bc18f091ff16d8f9/6N137.pdf Less 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.
Trust me, I'm NOT an engineer.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16617
  • Country: us
  • DavidH
Re: SPI isolation using optocouplers
« Reply #20 on: October 19, 2014, 05:26:35 pm »
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?

Why do any of the signals need to be tri-stated to isolate SPI?  They are all unidirectional.

The 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.

Ok.  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.

Quote
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.

SPI 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.

Not 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?

I 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.

 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16617
  • Country: us
  • DavidH
Re: SPI isolation using optocouplers
« Reply #21 on: October 19, 2014, 05:33:16 pm »
4N35 level optos are pretty bad, you wouldn't want to use them above 100kbps or so without special 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 is very misleading).  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.)

You can get a huge amount of extra speed if you have access to the base lead and use external signal conditioning.

Quote
If you need to be really miserly, you might resort to building your own (say with planar coils and RF design).  But, geez... :)

Gate drive and Ethernet transformers work well for this but need more signal conditioning then most people are willing to design these days.
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: SPI isolation using optocouplers
« Reply #22 on: October 19, 2014, 07:11:36 pm »
How about this one? http://www.tme.eu/en/Document/724e01c6de3535b2bc18f091ff16d8f9/6N137.pdf Less 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.

Sure.  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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline IanJ

  • Supporter
  • ****
  • Posts: 1608
  • Country: scotland
  • Full time EE & Youtuber
    • IanJohnston.com
Re: SPI isolation using optocouplers
« Reply #23 on: October 19, 2014, 07:52:37 pm »
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.pdf

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of the free WinGPIB app.
Website - www.ianjohnston.com
YT Channel (electronics repairs & projects): www.youtube.com/user/IanScottJohnston, Twitter (X): https://twitter.com/IanSJohnston
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: SPI isolation using optocouplers
« Reply #24 on: October 19, 2014, 08:35:34 pm »
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 here http://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).
Trust me, I'm NOT an engineer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf