What The Tech

USB Over Fibre

Extending USB over Long Distances

Johann Wyss

Issue 24, July 2019

Ever needed a USB extender to send signals to the other end of the house or workshop? We run some experiments to see how feasible it could be to design your own USB extender over optical fibre.

This month, we set about designing and building a fibre optic USB extender. Commercial units are fairly niche and expensive despite their seemingly simple function. They essentially work by converting electrical signals into light, which travels through a fibre optic cable to be received at the opposite end and converted back into electrical energy.

To see if a simple project was feasible, we decided to run a series of experiments using LEDs, photodiodes, photoresistors, and lasers. A series of experiments were conducted to determine which device provided the greatest accuracy and speed, and to compare their speed and signal quality against the speed of a simple USB transmission.

THE BROAD OVERVIEW

Our approach was to build a simple circuit using an operational amplifier to amplify the signal from the receiver and, hopefully, enable us to send actual data using light.

To create our pulsating DC square wave signal we use a 25MHz Function Generator, however, because the signal has a very small output impedance, we found we were unable to drive large loads directly from the generator. Therefore, we implement a MOSFET switch to drive the load.

We use various light emitting and light detecting electronic components available to the electronics hobbyist, from the common LDR to photodiodes and lasers.

To read the output waveform we used a DSO5072p Digital Oscilloscope. We include screenshots at the end of each experiment.

Our Test Build:

USB Pass-through Board

The very first question we needed to answer was exactly how fast was the average USB transmission. To test this, we made a very simple sketch in the Arduino IDE to serially print text from an Arduino Nano. Naturally, this all depended on the bit rate, however, it served as a benchmark to gauge the viability of each experiment.

We created a basic PCB to help us connect our oscilloscope probes to the D+ and D- lines of the USB, which connected to our computer. The PCB was essentially a simple pass-through with three copper wire tags that the probes clipped on to.

Note: We recommend using a laptop that is not connected to mains power for this. Oscilloscopes are ground referenced, as are many computers. This means it’s possible that connecting a ground referenced oscilloscope to a computer’s USB port can result in damage to the computers USB port.

THE CODE

The code was a simple sketch that would repeatedly send the text “Hello World” via the serial port. The computer was set to display the data from the serial monitor. This allowed us to see, in real-time, the data being transmitted. With the oscilloscope connected; both channels set to 2V, the timebase set to 400ns per division in single shot mode, triggered on the D+ rising edge, we observed the previous output.

We can see the entire transmission took approximately 5.4µs with each pulse lasting only about 80ns. Since Time = the inverse of frequency, we can calculate the “frequency” of each bit to be around:

Frequency = 1 / Time = 1 / 80 × 109s = 12.5MHz

It’s worth mentioning that bitrate isn’t actually calculated in this fashion, this was simply an easy way to visualise and measure the expected range / ballpark figure for our experiments.

If you wish to reproduce this simple test, this is the code we used.

void setup() {
  Serial.begin(9600);
  }
void loop() {
  Serial.println("hello World");
}

HOW IT WORKS

We designed a basic amplifier circuit to amplify the tiny voltages we detect on the receiver. The circuit is little more than an LM358 operational amplifier in the non-inverting configuration.

To set the gain, we use the resistors R1 and R2, along with the non-inverting gain equation:

V0= 1 + (R2 / R1)

When R1 = 10kΩ and R2 = 1kΩ the Gain will be 11.

V0= 1 + (10000 / 1000) = 11

We could increase this, however, we also amplify the DC offset, which we will have to deal with later. We can also add capacitors in parallel with R1 and R2 to increase the gain of the AC signal, which we also describe in another experiment. As mentioned previously, the function generator isn't capable of driving large loads, which is why we needed to implement a driving circuit. We originally experimented using a MOSFET with the signal from the function generator connected to the gate, however we stopped using this driving circuit as it was adding error due to the slew rate of the device. The slew rate is essentially the time it takes for the MOSFET to switch from a logic LOW to a logic HIGH.

In the case of an IRF540N, the td(on) is 11ns and the td(off) is 39ns.

DIAGRAM CREDIT: International Rectifier

This means every pulse will take at least 50ns; 1 / Time = 1 / (50 × 10-6) = 20MHz, which isn’t too bad. However, given we were be operating in the MHz region, we will need to find MOSFETs that operate much quicker and therefore, would be more suitable for the task.

We used our Oscilloscope to view the input and output waveforms for comparison. Channel 1 (yellow trace) connected to the output from the function generator. Channel 2 (blue trace) connected to the output from the operational amplifier.

Note: If we had a 4-Channel scope, we would have been able to visualise the signal before amplification and filtering, which would have helped show the complete picture.

We set up each sensor configuration and increased the frequency until the signal became completely unusable, in lieu of significantly more filtering. We have included screenshots from the oscilloscope to clearly show how the circuit behaves as the frequency increased.

Experiment 1:

LED to LED

The first circuit was by far the simplest. LEDs can generate small voltages when light is applied to them, therefore, for our first experiment we use two LEDs in Sympathetic Excitation. One connected to the function generator and the other to the Op-amp circuit.

By pointing the LEDs at each other, we expected to see a small voltage on the output that correlated to the voltage on the input. To increase the level of light entering the receiver LED we used a small piece of heatshrink tubing to seal around the two devices. This ensured that as much light as possible was being transferred into the receiver.

It came as no surprise that this method produced the lowest amplitude of signal of all methods tested. LEDs are simply not designed with this function in mind. However, it was fantastic to learn that in this configuration, data can still be sent, albeit very slowly. It would be interesting to repeat this experiment with a length of fibre optic cable to see if signal degradation is affected at such low speeds and low intensity.

With that said, at 100Hz the output had zero DC offset and a maximum peak-to-peak output of about 250mV. At frequencies around 1kHz, the signal becomes rather complex. We observed a rather high DC offset seemingly caused by the rise and fall time of the LED receiver. When we placed a 100nF capacitor in series with the output we got a signal that near perfectly matched, however, it had an inversion in relation to the rise and fall of the signal pulse.

Experiment 2:

LED to LDR

Our next experiment was done using an LED as the light emitting device and a photoresistor/light dependent resistor (LDR) as the detecting element.

The DC offset was expected to be an issue here due to the need for a voltage divider network to run the LDR. This experiment used bypass capacitors across R1 and R2 to enable higher frequencies.

For the purpose of this experiment we just show the results using the same Op-amp circuit to keep everything consistent. You will also notice we also enclosed the LED and LDR in heatshrink to help avoid any ambient light from affecting the performance.

In this configuration, we were pleasantly surprised with the LDR’s ability to detect and respond to the rapid changes in light.

Even though the output amplitude drops significantly, and the same inversion occurs as with the LED-LED experiment, the output from this configuration maintains a fairly useable signal into the 10kHz ranges. The signal still certainly needs to be sharpened up using a Schmidt trigger or similar, however, the circuit does maintain a matching frequency to the input signal.

Experiment 3:

LED to Photodiode

This experiment used a photodiode as the receiver element with an LED providing the light. In this configuration, we observed a DC offset of about 400mV with a peak-to-peak value of about 200mV at 5Hz. Whereas, at 100kHz, the DC offset increases to 600mV and the peak-to-peak value of the output drops to tens of millivolts.

We can rectify this offset by inserting a 100nF ceramic capacitor in series with the output before the scope probe. This capacitor blocks the DC, which allows us to view the waveform. Of course, this capacitor does add impedance, reducing the amplitude of the AC signal, however, that is outside the scope of this experiment.

With the capacitor, our signal was about 100mV peak-to-peak and matching the frequency of the incoming signal. However, as we increased the frequency further up to 500kHz, the SNR reduced again.

As you can see in this screen capture the cursors are set to 100mV framing the output signal. Whilst we are still getting 100mV output, the vast majority of this output is simply AC noise being coupled to our signal. To remove this, we can use a low pass filter.

This solution wasn’t exactly practical given we want to send high-speed signals. Perhaps the best way to filter this signal would be with a bandpass filter set to the expected USB speeds. We could also tune the DC blocking capacitor to match the frequency. This should result in a higher quality AC signal.

Note: The circuit for the LED and Photodiode combination shown above had the gain set differently, and the DC blocking capacitor was not installed in this image.

Experiment 4:

Laser to Photodiode

We expected that this experiment would yield the best possible results due to how quickly laser diodes can switch their output.

We used the same Op-amp amplifier circuit with a gain of 11 and powered the laser directly from the function generator. Due to the expected significant increase in speed, we ensured the signal cables were as far away from each other as possible. i.e. trying to minimise the potential for AC coupling giving erroneous readings.

Unsurprisingly, at the 100kHz range, the laser and photodiode combination worked perfectly fine. They produced an output closely emulating the input to the laser module, albeit with only a peak-to-peak amplitude of 100mV. This could easily be rectified with a second amplifier stage with a much higher gain.

At the 1MHz frequency range, noise became a very significant issue. Even though we can still clearly see the signal, it does become out of phase and has a low SNR. It is very difficult to filter the signal and amplify it at these frequencies.

EXPERIMENTS SUMMARY

The results have proven to be very interesting. Whilst every method allowed us to send “data” wirelessly using nothing but light, each method had its own limitations and hurdles to overcome. There were, however, a few consistent issues which we alluded to numerous times, with regards to the slew rate.

THE SLEW RATE

The slew rate is the rate in which a semiconductor can react to a change in voltage level on its input. This affects many of our components from the LM358 operational amplifier to the Photodiode. Each one takes a certain time to react to the changes on its input. This can be observed by placing our scope into single shot mode, set to trigger on the rising edge of the input wave (yellow trace).

As we can see, there is a lag of essentially 50µs before the output attempts to match the input (ignore the inversion). At low speeds, this isn’t likely to be a significant issue. However, the faster the frequency the more prominent this will become, until such time as the frequency is faster than the slew rate. In which case, you will start to get a triangle shaped wave on the output. This is precisely what we observed on many of the outputs as we increased the frequency and may explain this output. This can be rectified with better choice components, however, it can never be completely removed. Note for this experiment we used the LED and LDR because it showed a more pronounced slew rate.

RISE TIME AND PULSE DECAY TIME

Rise time is the time required for a pulse to rise from 10% to 90% of its steady value. Inversely, the Pulse decay time is the time it takes a semiconductor to fall from 90% to 10% of its maximum value.

Like the slew rate, rise time is another phenomenon we can never escape. Our operational amplifier is very quick, however, it isn’t instant. It takes a small amount of time to rise and fall from its high and low positions.

Typically, this time is very small at around 5µs, however, when we are dealing with frequencies in the 1MHz range, 1 period only lasts for 1µs. This means the waveform we see when using the laser and photodiode combination with a 1MHz input frequency, isn’t likely a signal being received by the diode at all. Rather, it is just potentially AC coupled noise. Further experiments will need to be done to verify this.

DIAGRAM CREDIT: Texas Instruments

This image shows quite clearly the rise time of the LED and photodiode circuit. The waveform takes about three-time units to reach about 90% of its maximum value, after the input signal is pulled high.

Since our scope is set to 20µs a division it appears to take 60µs to reach its peak value. Again, this delay can’t ever be removed completely, however, careful choice of components will help minimise it.

INTERFERENCE

Another consistent problem we observed when operating at these frequencies was interference. Every connection on the breadboard and every wire is essentially an antenna rogue signal. As such, many of our observations will be inherently obfuscated under the sea of spurious signals. Any further testing would need to be done with the circuit assembled on a PCB, preferably with a large ground plane and other noise suppression techniques.

FILTERING

We used minimal circuit filtering. Designing and implementing a band pass filter could be considered using active and passive components. This filter will need to compromise of components carefully selected to minimise the aforementioned slew rates and rise and fall times. Op-amps specifically designed to operate in the 10MHz range, such as the Analog Devices LTC6228, should suffice, although these are not likely easy for the hobbyist to obtain in small quantities.

The bandpass filter would need to be designed to match the expected data transfer speeds. Since 1Bit/second is equal to 1 Hertz, the USB 2.0 standard of 480Mbps would be equal to 480MHz. Therefore, the filter would need a centre frequency of 480MHz. Since this is largely outside of the scope of what is possible for the average hobbyist, perhaps the USB 1.0 standard of 1.5Mbps, with a frequency of 1.5MHz, is more realistic.

GAIN

Another issue we observed in the experiments was the lack of amplitude in the output signal. We averaged about 200mV on the output with a gain of 11. We were limited largely by the rise and fall time of the components we were using. Reaching the higher voltages takes even longer, and as such, better performing equipment would be required before experimenting further. With the active bandpass filter previously mentioned though, it’s possible to apply gain on each stage. This would mean our filter could also double as our amplifier.

DC OFFSET

Each of our experiments showed an increasing DC offset that correlated with an increase in frequency. This required the use of a small value capacitor to block the DC. This capacitor needs to have as low an impedance as possible at the desired frequency range and is calculated using the impedance equation.

|xc| = 1 / (2 × π × f × c)

Where f is the frequency you’re operating at and c is the capacitance in farads.

Therefore, at 1.5MHz and using our 100nF capacitor our impedance is:

|xc| = 1 / (2 × π × 1500000 × 100 × 10-6) = 1.06Ω

This value should suffice nicely, as it is quite close to zero ohms, and thus should have minimal impact at the higher frequencies. However, at lower frequencies of 1kHz, for example, the same capacitor will have an impedance of 1.6kΩ.

WHERE TO FROM HERE?

This process all started from a desire to transport USB signals over fibre optics, at a low cost. After all, it's entirely feasible.

There are now HDMI fibre optic cables which are ultra lightweight and don't require amplifiers inline, even for 100m runs! Since HDMI bandwidth exceeds USB in some cases, we are fairly confident there are no insurmountable hurdles here. However it's clearly a little more complex than we had hoped.

One train of thought that we're investigating further is the use of SFP adaptors, which are used for high speed Ethernet and Fibre Channel storage networks. The image below is from our Fibre Channel Switch for our SAN at the DIYODE HQ.

Fibre channel switches also run at extremely high speeds, and constantly translate the electrical signals to light using SFP transceivers. Rather than reinventing the hardware entirely, we're running tests to see if we can adapt these rather cheap SFP units to send whatever serial data we want. If we can get that to happen, then we should be able to achieve something great!

We'll keep you up to date. However if anyone out there has experience in this area - drop us a line!