Does anybody have an idea what the easiest way to send SPI over fiberoptic would be? I need to send a serial signal to a device that floats at high voltage.
I was looking at this thing, but I’m not yet sure what that would involve (I’m not a programming whiz like many of the VHS people are):
What speed are you running the SPI at? SPI uses kind of a lot of lines, that can run at quite high speed, so it’s a bit of an awkward one for fibre. Without fancy optics, one fibre is one signal, so bidirectional SPI will need at least 3 transmit/receive pairs as well as three fibres. If you can, UART will be a bit cleaner since you avoid the clock signal.
What I would recommend you try is TOSLINK modules designed for optical audio. They are typically rated from DC to at least a few MHz and both the transmit/receive electronics as well as cable are cheap and readily available. The only real downside is that ‘a few MHz’ may not be good enough, and the range is only a few metres, but for your purposes probably a good fit.
A typical transmitter would be the Everlight PLT133, matching receiver PLT135. Good for up to 16mbps and about $4 for a link pair. Generic TOSLINK cable should be available very cheap at the usual sources, and will work with this solution.
A more industrial-designed product would be the Avago AFBR/HFBR series. Slower, but better range and better quality connectors etc, but much more expensive ($50 or so for a link pair).
If what you’re after is a prebuilt module to go from SPI - optical - SPI and don’t want to build something yourself I’m not aware of anything, but I haven’t looked . It would be a pretty simple product to design with the above, but I doubt there is enough demand.
Edit: SFP might not be well suited. Relatively expensive, as you need a cage and the modules which are $10-15 each. It’s also AC-coupled and requires low-voltage differential drive and isn’t specified down to a few mbps.
I’d like to keep it as simple as possible because really I don’t want to have to troubleshoot on the HV end. If I were to use TOSLINK, UART, or SFP I imagine I would need another RasPi or a microcontroller to convert back into SPI, correct? In that case, would it make more sense to just communicate to a RasPi at high voltage via ethernet transmitted over fibreoptic? I was kind of hoping I wouldn’t have to float it…
The TOSLINK modules I suggested are specified down to DC, so you should be able to run SPI directly over them, though you need to “waste” a link for CLK. Since it’s just a DAC though you wouldn’t need MISO I don’t think so it could be just CLK and MOSI if you don’t need a chip select. No need for anything else on the HV side, at least for that part of the system.
UART would require some kind of converter (eg a micro) but would get you down to a single fibre. SFPs would need some stuff too as you’d require a more complex encoding to eliminate DC as well as the differential driver.
Optical Ethernet is, IMO, probably the best solution. You can use fully off the shelf parts, and assuming the Pi doesn’t need to talk to any gear on the LV side, you don’t need to write any code at all, just move it to the HV side and hook it up to your network. Relatively expensive though, a pair of 100FX converters at fs.com is about $75 with optics. It just so happens I have some I’ve been keeping around for some sort of application like that. I can part with a pair and maybe some old fibre if it hasn’t been thrown out yet if you can pick them up.
Edit: An even simpler and cheaper option would be to float the Pi and use a WiFi dongle.
I did think of the WiFi option before, but I was concerned about the reliability of connecting to WiFi in a grounded metal box.
I’m intrigued by the TOSLINK option because it would avoid floating the Pi. From what I’m reading, it says that TOSLINK is digital. Does that mean I need to code/decode it to and from serial? Or can I just send a serial signal into something like this?: http://www.goldmine-elec-products.com/prodinfo.asp?number=G16911
TOSLINK is not very fancy, within the limits of the optical transmit/receive pair, whatever TTL signal you put into the transmitter should be recovered exactly at the receiver. They’re very simple, basically just an LED and resistor or CC driver in the transmitter and a phototransistor and schmitt trigger in the receiver. Since they are usually specified all the way down to DC, even static signals will be recovered properly, so up to whatever the maximum specified bitrate is, for TTL-level signals you can more or less consider TX-fibre-RX a wire.
For your application you should be able to do something like:
And make sure the Pi’s SPI is configured to run slow-ish. Since you say you don’t need it to be particularly fast, 1Mhz or so would be conservative and is similar to the bitrate of CD audio, so TOSLINK parts should be designed to work well at that rate.
I haven’t actually run SPI over this kind of setup myself, but I have used them for some DC control signals and see no reason it wouldn’t work.
Thanks a lot. It looks like TOSLINK will probably work as long as I lower my clock frequency. I found a unit that is supposed to run at 16Bbps (signals are currently sent at 30Mbps). It’s cool how cheap and simple this is.