Driving An SFP Module with Protocols Other Than Ethernet - Page 1
Forum section: electronics / projects

author: jamfletch
author_rank: Contributor
timestamp: April 08, 2024, 10:49:43 am
content: Hi all,I'm trying to figure out if it's possible to use an SFP module for UART comms (or any other protocol for that matter). Judging from datasheets I've seen, such as this one :https://www.mouser.co.uk/datasheet/2/678/AVGO_S_A0003371972_1-2574527.pdf. It seems that all the SFP module is doing is just acting as a "dumb" LED driver and receiver for the optical link, and my asssumption is that you can drive this module on the TX side with whatever protocol you like (As long as the signalling format you're using has 0 DC component, due to the AC coupling internal to the module)I've been trying to get explicit confirmation from information online that you can actually do this, but I haven't had any luck yet. I'm just wondering if anyone here has had success/knowledge about doing this?

author: Someone
author_rank: Super Contributor
timestamp: April 08, 2024, 11:10:49 am
content: The lowest frequency they will sustain is usually undocumented, and quite high.UART? Almost no chance of that working. You'd need some high speed SERDES to modulate that onto the wire.

author: jamfletch
author_rank: Contributor
timestamp: April 08, 2024, 11:35:12 am
content: Okay thanks, so say we drive the TX pins of the module using a SERDES (or FPGA that's performing SERDES in it's logic), using 8b/10b encoding or similar, we should be able to use any protocol we like for our module right? (I.e we don't need to do any Ethernet PHY stuff)Any idea why there's a minimum frequency? Is it to do with the impedance of the internal AC coupling capacitors?

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 08, 2024, 12:29:33 pm
content: You can do high frequency FSK to send your UART signal, demodulating it would be as easy as low pass filtering and then envelope detection. It would make sense for something like an isolated digitizer, which needs gigabits of bandwidth in one direction but next to nothing in the other direction.BTW, the slowest SFP modules worth buying nowadays are the 10Gb ones, they're like $2 each on Ebay and are also useful for Ethernet.

author: Henrik_V
author_rank: Regular Contributor
timestamp: April 08, 2024, 02:14:31 pm
content: Quote from: jamfletch on April 08, 2024, 11:35:12 amac coupled log-amplifier in the photo diode ?

author: Echo88
author_rank: Frequent Contributor
timestamp: April 09, 2024, 06:46:23 pm
content: I was interested in doing the same as jamfletch.So i used these test-pcbs to explore the idea:https://osmocom.org/projects/misc-hardware/wiki/Sfp-breakoutI tested the minimum frequency when the SFP-modules would begin to transfer the waveform reliably (checked input/output frequency with scope for obvious jitter, delay and phase difference), here are the results for two SFP-modules as an example:SFP1G-SX-85: 200kHzUF-SM-1G-S: 180kHzBut i couldnt get UART transfer between two ESP32 to work despite using 1MBaud for example, instead both ESPs just receive random gibberish/nothing at all. Maybe the data would need to be embedded in a longer stream with CRC to reliably send/receive data?Apart from SerDes it would also be possible to use Ethernet and a dedicated LAN->SFP bridge IC like RTL8213B.

author: jbb
author_rank: Super Contributor
timestamp: April 09, 2024, 08:13:17 pm
content: I expect you need to send a signal with an equal number of 0 and 1 bits in it. This is known as a DC balanced signal.The common 8b/10b encoding scheme could be useful here. It encodes each byte (8 bits) of data into 10 bits and provides a DC balanced output.Edit: it may be possible to apply some encoding to UART transmissions which is both compatible with a UART and DC balanced. But you could only send a small number of bits per UART character (maybe 4??)

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 09, 2024, 11:01:23 pm
content: If you're going for minimum component count, you could set up one of the microcontroller timer outputs in variable frequency, 50% duty cycle mode. (Check the datasheet, it's often listed as "toggle" mode.) Not sure if you need to provide a differential signal or if just driving one side while having the other side on a fixed bias would do. On the receive side, use a comparator (either built into the microcontroller or a separate one) to turn the differential signal to single ended and then use a microcontroller timer to measure the frequency.I have some old 4Gb SFPs lying around that I would like to play with, I assume they're not even worth as much as the matching sockets so my best bet would be to just solder wires to the pins. (Is it correct that on the off chance I get something that expects a 4Gb SFP, I can just put in a 10Gb SFP and expect it to work?)

author: jamfletch
author_rank: Contributor
timestamp: April 10, 2024, 06:23:33 am
content: And in theory, we should be fine to use 8b/10b with any protocol we want right? i.e we don't have to follow the ethernet protocol and can just signal any data we want to the TX pins of the SFP module, assuming we meet the minimum speed? My main concern is that we can get away with not using the ethernet PHY with these devices, seeing as they all advertise as Ethernet SFPs.

author: mikerj
author_rank: Super Contributor
timestamp: April 10, 2024, 08:12:44 am
content: Quote from: jamfletch on April 08, 2024, 11:35:12 amThere is usually AC coupling in the data path on both TX and RX sides. Additionally the TX side will typically have a power control loop for the laser which compares the low pass filtered monitor photodiode current against a reference value and adjust laser bias current, with a very low data rate this control loop will be fighting the data signal.

author: Hydron
author_rank: Super Contributor
timestamp: April 10, 2024, 08:21:23 am
content: Could you just use a Manchester code and run it fast enough to be well over the minimum frequency (a few mega baud should do it)?I can attest to SFPs being WAY cheaper than any DC coupled optical TX/RX pair - go have a look at the prices of HFBR parts (especially the ones for glass rather than plastic fibre).

author: radiolistener
author_rank: Super Contributor
timestamp: April 10, 2024, 08:34:04 am
content: You can wrap UART communication into UDP packets and send it over usual Ethernet IP protocol

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 10, 2024, 09:34:38 am
content: SFP RS232 modules do exist, e.g.https://www.flexoptix.net/en/t-c12-rs232i.htmlBut I suspect internally these are ethernet to UART convertersSFPs will have minimum frequencies they can operate at - if you are wanting to use a pair of SFPs in a closed system, then maybe you could just modulate your UART data onto a suitable carrier frequency with some fairly simple electronics.I suspect they like a constant signal so probably FM or manchester coding rather than AM or on/off control.Perhaps a 315MHz FM telemetry RF transceiver chip could work ?

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 10, 2024, 10:43:14 am
content: Quote from: Hydron on April 10, 2024, 08:21:23 amOther than S/PDIF aka Toslink, of course, which is limited in both length and bandwidth, and typically uses plastic optical cables.(Inverted UART at higher baud rates works fine over Toslink, although I've only used the same MCU on both sides. Whether you count it as DC coupled or not depends.)

author: ejeffrey
author_rank: Super Contributor
timestamp: April 10, 2024, 01:33:19 pm
content: Quote from: Hydron on April 10, 2024, 08:21:23 amThis should work fine. 8b10b is more efficient, taking only 10 clocks to transmit 8 bits instead of 16 but since you are trying to run slow communications who cares.The other thing you have to address is the idle state. You can either have some AC idle state, such as transmitting repeated Manchester encoded zero bytes or you can send something like the Ethernet preamble, a long repeated sequence that allows the receiver to synchronize.

author: dobsonr741
author_rank: Frequent Contributor
timestamp: April 10, 2024, 01:54:57 pm
content: I am using SFPs for SPDIF to send signal in the home theater (instead of toslink). Works like a charm. Just need to configure and enable the transmitter etc. via I2C.It’s a fairly low frequency 6MHz-ish. Polarity does not matter, an extra bonus.

author: jamfletch
author_rank: Contributor
timestamp: April 10, 2024, 03:05:28 pm
content: Quote from: dobsonr741 on April 10, 2024, 01:54:57 pmOut of curiosity, what SFP module are you using for this?

author: David Hess
author_rank: Super Contributor
timestamp: April 10, 2024, 10:28:16 pm
content: Quote from: ejeffrey on April 10, 2024, 01:33:19 pmSome UARTs support Manchester encoding directly, or at least they used to. I think it was used for IRDA?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 10, 2024, 11:27:30 pm
content: Quote from: David Hess on April 10, 2024, 10:28:16 pmNo, Irda isn't manchester code - irda coding sends a either short pulse, or no pulse at the start of each bit-cell, allowing high peak, but low avarage infrared power

author: dobsonr741
author_rank: Frequent Contributor
timestamp: April 10, 2024, 11:33:51 pm
content: QuoteWorked with 4G Fiber Channel SPFs, later I changed them out to 1G ethernet SFP bought on FS.comThis is what I am using now:https://www.fs.com/products/48929.htmlAs far as connectors, I'm using a TwinGig:https://networkoutlet.com/products/cisco-twingig-converter-module

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 11, 2024, 01:23:37 am
content: Quote from: jamfletch on April 10, 2024, 06:23:33 amYes absolutely. No problem. As said above, you should just meet the min/max rated frequency, and use some adequate line encoding scheme (8b/10b is fine, but you could use something else - 4b/5b should be fine too.)You will need to do clock recovery, which is the "tricky" part. There are some interface ICs that can do just that (don't remember references but I think TI have some) without being Ethernet PHY.But you could also of course use Ethernet PHYs and implement your own protocol on top of it.

author: jbb
author_rank: Super Contributor
timestamp: April 11, 2024, 02:06:42 am
content: I think it's possible to -veryinefficiently - use a UART to spit out signals which are properly framed (for UART receiver), DC balanced and have limited run lengthsAt the very least, the following symbols could be attempted using 8 data bits, no parity, 1 stop bit:EDIT: here's a list of 26 frames with max run length of 2. This could be divided up into 16 distinct data frames (and therefore encode 4 arbitrary bits) plus some link idle frames (bonus points if you can find a sequence that is guaranteed to get the UART receiver to synch) plus some control frame (like 'start of packet', 'end of packet')7785868990101102105106108149150153154165166169170172178180201202204210212It's low efficiency because you can only move 16 values -> 4 bits per frame; 40% efficiency.

author: richard.cs
author_rank: Super Contributor
timestamp: April 11, 2024, 08:49:54 am
content: I'm pretty sure we did something at work a few years back where we got DC equalisation on UART at low processing overhead by repeating every byte inverted, but I can't remember how we avoided DC from the start and stop bits. Obviously it's inefficient, but when the channel is wide enough it doesn't matter. Gave us some redundancy for free too.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 11, 2024, 09:30:27 am
content: Quote from: richard.cs on April 11, 2024, 08:49:54 amAs long as you're sending continuously with no gaps, the start and stop bits will cancel each other out

author: richard.cs
author_rank: Super Contributor
timestamp: April 11, 2024, 10:25:26 am
content: Quote from: mikeselectricstuff on April 11, 2024, 09:30:27 amI guess that was probably it. We did send a big block of data with a fairly long preamble before it.

author: ajb
author_rank: Super Contributor
timestamp: April 11, 2024, 06:44:54 pm
content: Using SPI instead of UART could be more flexible. Some MCUs directly support word oddball SPI word sizes, including some STM32s, and a 256x2 byte lookup table of pre-encoded 10-bit words wouldn't be too bad. It's a little bit of memory overhead to trade against transmission overhead on the wire verses an 8->16 bit encoding (or 8->18 by the time you account for UART start/stop bits ).Using a little greenpak device for encoding/decoding could be worth exploring as well--could be neat to build a dumb but very flexible adapter module that way.

author: David Hess
author_rank: Super Contributor
timestamp: April 11, 2024, 08:14:34 pm
content: Quote from: mikeselectricstuff on April 11, 2024, 09:30:27 amI just noticed that; the start and stop bits have opposite polarity because the stop bit sets up detection of the edge of the following start bit. All that is required now is continuous transmission to prevent a stop bit which is longer than one bit duration, and DC balancing of the 8 data bits.If 8 (actually 9) zeros or ones in a row cannot be tolerated, then the data can be split into nibbles and odd or even bits used to maintain DC balance over 2 bit periods. This could conceivably be Manchester encoding of 4 data bits into 8 RS-232 bits with start and stop bits for asynchronous operation rather than regenerating the clock from the Manchester encoding. I guess that leaves one of the unused codes as an idle code, but now DC balance has to be over 4 bit periods but maybe that is acceptable. The more complex this gets, the more 8b10b encoding becomes reasonable.

author: jbb
author_rank: Super Contributor
timestamp: April 11, 2024, 08:21:14 pm
content: Next step; using Ethernet

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 12, 2024, 12:46:39 pm
content: Quote from: jbb on April 11, 2024, 08:21:14 pmIn adifferent thread, I mentioned that one could use raw Ethernet frames (layer 1 frames) to transmit RS-232 data between endpoints if using a small FPGA (with a sufficient SERDES), making it routable within a single local area network segment using standard switches. You could even wrap the data within UDP/IP frames with configurable source and destination IP addresses and UDP port numbers, making the traffic ordinary UDP/IP.The point there was, wrapping the datagrams in an Ethernet frame does not actually cost that much; you definitely don't need a full IP stack at all. Only the 32-bit checksum (0x82608EDB, x³²+x²⁶+x²³+x²²+x¹⁶+x¹²+x¹¹+x¹⁰+x⁸+x⁷+x⁵+x⁴+x²+x+1) at the end (but before the interpacket gap) needs computation.To drive the SFP module, one could use e.g. Microchip LAN9250 Ethernet controller (7€ to 9€ in singles at Mouser), communicating with it via8 or 16-bit data bus and SPIfrom basically any microcontroller.I do realize OP asked explicitly aboutother than Ethernet, but my point is that you can easily offload or use Ethernet on the wire, without specifically targeting Ethernet in your MCU. If you look at the MicrochipEVB-LAN9250SFP interface (FTLF1217P2 on page 6), you only need four pull-up resistors (2×82Ω + 2×49.9Ω), two pull-down resistors (2×130Ω), four 100nF capacitors in series with the four data lines, plus some 3.3V supply filtering and mode strap resistors for the SFP module that will depend on the exact SFP module used. In particular, one might use a separate slave microcontroller between the main microcontroller/device and the LAN9250 chip, converting the data from/to the custom format or data stream, to Ethernet packets; a kind of a custom-protocol to Ethernet + SFP driver module. Replacing that module you can switch to a different interconnect, without chaning the main data stream format at all.TL;DR: Having your main device know nothing about Ethernet or the interconnect used, it would only cost about 20€ in parts in singles from Mouser to implement an Ethernet-over-SFP interconnect using 100Base-FX (like the Broadcom AFBR-57E6APZ-HT SFP module OP linked to), if you use a translating/buffering microcontroller and e.g. LAN9250 industrial 100Base-FX ethernet controller. To switch to a different interconnect fabric, you just replace the microcontroller + LAN9250 + SFP module, with no changes to the original device, maximizing upgrade path and long-term maintenance opportunities.

author: Echo88
author_rank: Frequent Contributor
timestamp: June 29, 2024, 12:02:20 pm
content: Going with a suitable 100BASE-FX controller would of course be the most cost effective way to go for direct SFP ethernet usage and id go that way if there were arduino libraries that would use the LAN9XXX transceivers.In my case id like to use the existing arduino ethernet libraríes which use e.g. a W5500 (or ESP32 + LAN8720) and just add a medium converter IC to get SFP connection.However, im unsure if i can connect the medium converters ethernet input pins directly to the W5500 output or if the underlying 100BASE-TX stuff like baseline wander correction necessitates a magnetics path? The RTL8213B datasheet is rather sparse on specs.I attached a schematic showing the intended connection scheme USB -> CP2102N -> ESP32 -> W5500 -> RTL8213B -> SFP.Any thoughts?

author: Echo88
author_rank: Frequent Contributor
timestamp: June 30, 2024, 10:30:37 pm
content: Attached is an alternative version doing what was intended by OP in the first place: using SFP modules without resorting to Ethernet.It uses the already mentioned FSK-modulation idea and should be suitable to achieve <=1MBit (yet untested).Since this is my first time using the 74HCT4046A it would be nice if more experienced users could point to obvious errors in the schematic or add improvements, before i produce a pcb to test it.Thanks.