EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: JVR on March 26, 2013, 07:29:24 pm

Title: Fiber from scratch?
Post by: JVR on March 26, 2013, 07:29:24 pm
I have a project where we are using chinese sourced RS485-Fiber-RS485 units that I have modified.  We are sending a nonstandard electrical protocol over the units, with differential signalling.  The problem I currently have, is that the protocol may be idle for long periods of time, and then send massive bursts of data, either bidirectional or only one way.

The units that I have modified have nice and cheap optical modules, but I needed to modify these as well.  It seems that if a certain level is kept for two long, the receiving diode "loses concentration" and brings both the Q and /Q levels back to normal. If this was all I could live with it, but when a transmission then starts, the diode takes some time to start reacting, this means that I distort the sync bit of the incoming data, making it useless.

The mods I've done was with R/C networks, adjusting the quantizer setpoints etc etc, and they sort of work, only losing a packet every now and then, this is still not good enough though.

I need a really cheap solution, as the units we are buying in, are $180 landed, and then I pretty much strip their guts out.  So I was looking at AVAGO's website, and found the HFCT-591xE family. 

The app notes makes it look like they are not that full of shit to build for, and RS charges ~40$ ea.  The question I have though, the datasheet's mention that you need to strive for a 50% duty cycle, does this mean the device will do exactly the same as the modules above, ie letting the Q,/Q come back to neutral if a single bit is left on?

If this is the case, how can it be overcome, cheaply and sans FPGA, as I have no experience working with them.
 
Title: Re: Fiber from scratch?
Post by: kxenos on March 26, 2013, 07:40:42 pm
The cheapest solution would be to change the software to poll every x time to wake the modules up and equivalent software on the other side to ignore those polls but I guess you have already thought of that. So the next best thing I'm thinking is to build a unit that will sit between the terminal and the module and when it senses inactivity it will inject polls that the unit from the other side will inhibit from going to the other terminal.
Title: Re: Fiber from scratch?
Post by: cyr on March 26, 2013, 08:26:20 pm
Is the protocol some kind of async serial or something completely different? Does it run at a constant bitrate?

There are many ways to encode data to create approximately 50% duty cycle and limit the length of consecutive ones or zeroes, since that is required for many channels.

Examples:

http://en.wikipedia.org/wiki/Manchester_encoding (http://en.wikipedia.org/wiki/Manchester_encoding)
http://en.wikipedia.org/wiki/8B/10B_encoding (http://en.wikipedia.org/wiki/8B/10B_encoding)
Title: Re: Fiber from scratch?
Post by: JVR on March 26, 2013, 08:33:33 pm
Yeah, I dont have control of the soft/firmware running on the nodes, so I need to get it to mach, as if a hardline was present.

Manchester makes sense, but what will do the encoding at ~1Mbps?

System runs a constant bitrate, but uses proprietry stat/sync bits.
Title: Re: Fiber from scratch?
Post by: daveatol on March 27, 2013, 12:40:58 am
There are plenty of line coding techniques you could use. There are ICs for encoding and decoding manchester, or you can create your own using a microcontroller (e.g. ATMEGAxx). A simple coding method I would probably use would be FSK, where each '1' is represented by an inversion after a full bit time and each '0' is represented by two inversions in a bit time. I prefer this method of FSK over manchester as synchronisation to the bit stream is instant.
Title: Re: Fiber from scratch?
Post by: C on March 27, 2013, 01:39:47 am
JVR,
I do not know how much, or what kind of help you might like, ( Do not want to take away your fun) so to restate the problem which sometimes helps and if you want more ideas/help ask.

You have A Network of black boxes using RS485 transceiver chips communicating with a 1Mbps data rate.
 
You want one or more long distance extensions that do not break the rules of the black box network. One way to say this is, A black box pretender that communicates with a second black box pretender at a distance that makes the remote black box act as if it's local. 

RS485 problem's
 with RS485 network idle status is normally the same as one of the data logic states.
 You do not know network idle status unless you recreate it based on time.
 with RS485, You do not want two or more transmitters enabled at the same time on a two wire network.

For a great extension, you need min delays, this suggests that each end of the extension needs to know the idle status of the other end. The extension needs to follow some rules as to when to enable the TX on the RS485 network on each end of the link. To get the delays as low as possible the lower cost long distance extensions linking half duplex networks use full duplex links between each end of the extension if they can. If they can not then things get more complicated at each end. Think of what each end of the extension needs to say to the other end. I am idle, I am data 0, I am data 1.  There are many, many ways to convey the these three states to the other end of the extension so that extension ends up with three states( idle, link A to B, link B to A). 

What You have not said and could help the helper's is.

What is the distance between the two RS485 networks?
More about the data format, can you detect network idle?


I do notice that the HFCT-591xE is for 1 Gbps, if your RS485 network is at 1Mbs, you could be adding a lot of cost just to interface with the HFCT-591xE that would not be present with a lower speed device.

Quote
50% duty cycle
To say is a different way, They need to maintain a fixed DC balance to function. They can only tolerate a signal different from that DC balance that for ____ time.  A 1Khz square wave is a balanced signal but could still break the rules by being low and high for too long. Just an example, At 1 Gbps a 0 might be a 1 Gbps square wave while a 1 is a 2 Gbps square wave, but you have to play using their rule book or you have a bad link. The 8b/10b breaks the rules for a short time but is balanced at 10b lengths.


C       
   
Title: Re: Fiber from scratch?
Post by: JVR on March 27, 2013, 06:34:54 am
What is the distance between the two RS485 networks?
More about the data format, can you detect network idle?

Normal cable distance is max 30m, we need to extend this to <2km. 

The system does use 485 Transceivers, but as I said, the protocol is proprietary.  As it was a cable connection, you are correct in stating that the idle is one of the bit states. It is also simplex. Full duplex is implemented over two 485 networks between the black boxes.

As the quantity's will be low, I do not have any issues with buying a slightly more expensive solution, but as always, cheaper is better.

One other failure point that I need to stress, is that when the network sends a few 1's or 0's. this also allows the rx diode to normalize back to unreadable data.

I was thinking of using a method of gating, by "mixing" the incoming data with either a (for arguments sake) 10MHz signal for a 0, or a 20Mhz signal for a 1, as this should keep the line balanced.  I have no idea how to recover the data from that yet though.
Title: Re: Fiber from scratch?
Post by: ConKbot on March 27, 2013, 03:26:59 pm
I was thinking of using a method of gating, by "mixing" the incoming data with either a (for arguments sake) 10MHz signal for a 0, or a 20Mhz signal for a 1, as this should keep the line balanced.  I have no idea how to recover the data from that yet though.

The same way you'd recover digital data from any FM/FSK data. Your encoding would be just feeding your TTL data into a VCO (Maxim has some SOT-23 ones which should be right in the range your looking for, I think they do a few mhz upto 100+)   And a PLL/VCO on the recieving end, get your digital data from the voltage controlling the VCO on the reciever.

This would basically be a HF radio link, except rather then antennas, you have a fiber TX/RX plopped on the end.

EDIT:
said Maxim VCO's
http://www.maximintegrated.com/datasheet/index.mvp/id/2323 (http://www.maximintegrated.com/datasheet/index.mvp/id/2323)
They only go down to 45 MHz, but even at 100 MHz, the wavelength is 3 meters, so unless youre trying to go further than ~30CM, you dont need to worry about controlled impedance, just good signal integrety practices. Put your VCO/amp (if your fiber TX needs it) next to the fiber TX with lots of ground plane and you should be fine.
Title: Re: Fiber from scratch?
Post by: Rufus on March 27, 2013, 05:28:42 pm
I was thinking of using a method of gating, by "mixing" the incoming data with either a (for arguments sake) 10MHz signal for a 0, or a 20Mhz signal for a 1, as this should keep the line balanced.  I have no idea how to recover the data from that yet though.

AVAGO do a range of fibre transmitters and receivers with frequency capabilities from DC to 5MHz through DC to 160MHz. I don't understand the jumping through hoops trying to make a transceiver designed for Gbit Ethernet work at DC or 1MHz. 
Title: Re: Fiber from scratch?
Post by: C on March 27, 2013, 07:38:55 pm
Reading between the lines, it sounds like the fiber link you are trying to use may be built for a protocol that has a preamble, (some of witch can be lost) or have a min data rate, Not RS485.
With a true full duplex link, what You stuff in the input will come out the output but delayed.
Rufus's
Quote
DC to 5MHz
   
would cover RS485 to 1Mbs easily.

I would spend a little time thinking on what bad news things the black boxes could do or might do with a future update. Would not be good move to spend _$$$____ on extension and have it break due to black box update

In thinking what could go wrong, here is my nasty thought
A black box knows that the network will be idle so it can start transmitting right now. Example: master tells slave to respond. As soon as slave receives the complete master message it starts transmitting.  Using asynchronous protocol as an example the slave starts enabling it's transmitter during the receive time of master's stop bit. Where the next start bit from the master would be becomes the slave's start bit. Looking from the master this would be the network delay to the slave and network delay from slave back to master. As a black box designer this would be a good design and it's bad for extension builders. The unknown question is how long is the master going to wait for the slave's start bit. From the black box designer point of view, the smaller the delay is, the quicker the master can say "Trouble at Slave __"
 

The rules I have seen for RS485 are something like this.
Two devices can talk  _____ speed for ____ distance. Adding additional devices decreases distance by _____ and each device must maintain _____ distance from it's nearest neighbor. A tee connection is bad news and should be avoided or kept below _____ length.

One way to add more devices or distance is to split the network. Two networks (A , B ) connected via a repeater. Receiver on A always transmits non idle level to B, Receiver on B always transmits non idle level to A,  Idle level time of ____ disables the transmitter enable. Note that this repeater has three states ( idle, B to A, A to B). With a repeater a 20 device network could become two 11 device networks (11 device network can be longer then 20) but act almost as a single network. Almost because there is a delay going through the repeater. This repeater is the same idea as a two port dumb hub. You could think of your extension as two dumb hubs linked with network C or a split dumb hub with full duplex internal link.
The unknown is how much delay is OK.
 
For twisted pair 10Mbs Ethernet there were some rules for hubs( from any node to any other node a max of 5 hubs between are allowed). Break this rule and you get nasty errors. 

SO:
Network A = simplex (2 wire) RS485
Network B = simplex (2 wire) RS485

Idea: A Receiver attached to Network A extends what is happening on Network A to close to Network B.
1. Network A RS485 Receiver delay
2. Extension Transmitter delay
3. Cable/fiber propagation delay
4. Extension Receiver delay
5. RS485 transmitter enable delay from network B.
What is happening on network A can be monitored close to network B, but is delayed by 1-4.
It's easy to add more delay, the question is this already to much delay?


RS485 is a logic level network(DC to _bps). Converting from logic levels to a frequency = logic level system may not change #2, but will probably effect #4 ( you have to detect the frequency) which adds delay.     

Note: A while back I was looking at some RS485 transceiver chips, as luck would have it the first one I started looking at had a very, very ....VERY slow transmitter enable time. Not a good chip to pick for a repeater or extension. I would not even like to use it in a node.

C

Title: Re: Fiber from scratch?
Post by: kxenos on March 27, 2013, 08:09:11 pm
If it is of any help, I have implemented a similar modification. I used RS485 to ethernet modules (I don't remember what make they where but I find it out) to extend a multidrop network for railway application. These modules where then routed through adsl lines. It was quite easy.
Maybe you could use RS485 to ETH and then E/O converters but I guess the cost would be higher
Title: Re: Fiber from scratch?
Post by: JVR on March 28, 2013, 09:05:55 am
Bliksem ,you okes are running away with this  :)

The units will never update their protocol, as they are company wide (Sony) and standards.

The units use a 485-like electrical spec, but the bauds and data sizes are not consistent.

There are two channels, remote to unit, and unit to remote, so its not a master/slave setup.

Some delay in the messages is not the end of the world, but losing or stretching/clipping a single bit is. So in essence all I need is a repeater that will transfer the binary input, to the output, reliably.

*Edit To Add
Longevity etc is not of utmost importance, if it fails after 5000hrs of use, its fine, I can replace it. But I need a reliable channel that will transmit from DC to 1Mb/s

My apologies if I'm not setting this clear enough, been a rough week

The Avago DC-xMb/s units look promising, but I cant find any that will run on glass fibers, all are rated for plastic fiber.  Also, it AS to be fiber, as I am already running some other signals through a fiber harness. I have two strands left to do this on.
Title: Re: Fiber from scratch?
Post by: daveatol on March 28, 2013, 09:20:18 am
The system does use 485 Transceivers, but as I said, the protocol is proprietary.  As it was a cable connection, you are correct in stating that the idle is one of the bit states. It is also simplex. Full duplex is implemented over two 485 networks between the black boxes.
Is there any chance you can draw & scan (or photograph) a diagram of the setup?

If it is just two simplex connections (running in opposite direction for full-duplex), then the transmission and reception schemes are very simple. If you use the FSK as I suggested earlier, the modulator (line coder) can simply consist of an crystal oscillator & divider, data flip-flip (synchroniser) and AND logic gate. The demodulator can share the oscillator and will consist of an edge detector, divider and data flip-flop. The whole shebang could be knocked up with just a few logic ICs.
Title: Re: Fiber from scratch?
Post by: JVR on March 28, 2013, 06:19:58 pm
If it is just two simplex connections (running in opposite direction for full-duplex), then the transmission and reception schemes are very simple. If you use the FSK as I suggested earlier, the modulator (line coder) can simply consist of an crystal oscillator & divider, data flip-flip (synchroniser) and AND logic gate. The demodulator can share the oscillator and will consist of an edge detector, divider and data flip-flop. The whole shebang could be knocked up with just a few logic ICs.

(http://i649.photobucket.com/albums/uu217/JVRDesign/Fiber_zpse78e468d.jpg)

Sorry, I had to do this a long time ago, its exactly as you say.

Please elaborate on the FSK scheme? Would it react quick enough in-line?
Title: Re: Fiber from scratch?
Post by: daveatol on March 29, 2013, 01:37:40 pm
Please elaborate on the FSK scheme? Would it react quick enough in-line?
The FSK scheme is simply representing the '1' and '0' as e.g. 500kHz and 1MHz, respectively, or as you suggested, using 10MHz and 20MHz..

For the transmitter, the base frequency is used to generate the FSK high frequency and is divided by 2 for the low frequency. The input data is passed through a FF, clocked by the low frequency for synchronisation, and used to select which frequency should be output. If you use 500k/1MHz, you have to account for the phase inversion caused by the half cycle per bit of the 500kHz (which just entails an extra divider on the output).. using some multiple of 1M/2MHz doesn't have such an issue.

For the receiver, the edges of the rx signal are detected and used to reset a timer and to clock the output data FF. The timer is clocked by a multiple of the base frequency, but does not increase once it has reached >= 1.5 bit times; when the timer stops, it presents a '1' to the output data FF, else it presents a '0'. In this way, a long pulse (low freq.) outputs a '1' while a short pulse (high freq.) outputs '0'.

You can implement all this in logic ICs, or use a CPLD to do the same.
Title: Re: Fiber from scratch?
Post by: C on March 29, 2013, 10:47:03 pm
JDR,

Just wondering, Would some or all of the following be true?

1. An analog value is converted to the time domain. By using analog methods for continuous step free value in the time domain.
2. The time value from #1 has ____ time add to it for transmission.
3. The transition of the RS485 driver marks the end of #2 and a possible start of a new value. 4. This value could be  for the same or a different analog source.
5. By using the High time and Low time for separate values, transmission rate is maximized.
6. For values that need more accuracy additional time in the time domain can be used.
7. The list of analog values transmitted can be expanded, by use of a list selection value.


---------


If you use your 0's and 1's to control a VCO and the VCO's output frequencies were in the proper range, You could probably us a cable tv system's RF to Fiber and Fiber to RF converters or build your own.

While a pure digital frequency selection is simple, if your 1's and 0's have independent timing with respect to the digital frequency you can end up with glitches. The glitches become smaller the more you move your freq. selector to the higher freq. gaining more divider steps after selection.

In the analog world, switching between two oscillators can be bad news when transmitted. Making one oscillator move (change it's freq.) is the better choice.

C