EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: man_marius on October 18, 2018, 07:04:19 am

Title: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 07:04:19 am
What is the easiest way to go about make a Differential Bi phase Level detector circuit board, with discrete components or FPGA,

The decoding works in two steps, first translating phase shift bit shift into A letter, this happens in the center of each bit cell, a change from -1 to 1 is encoded as "A" and a change form 1 to -1 is encoded as "B".
The second step is to compare the current letter to the previous one
 X current = X previous  -> 1 is encoded
 X current != X previous -> 0  is encoded

I have attached the encoder schematic
 
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 07:12:37 am
The  input signal is a polarity insensitive differential line 120 characteristic impedance and at a datarate of 564.48 kbit/s
Title: Re: Differential Bi phase Level Decoder
Post by: Dubbie on October 18, 2018, 07:17:38 am
I have just done a biphase mark decoder using an stm32 micro. I just start a timer on an edge interrupt and then add the timing of the last edge to a fifo buffer that gets processed in the main loop. Seems to be reliable. However I am only decoding up to 4kb/s. I am doing a lot of other stuff on the micro such as drawing an oled screen and writing to an sd card and everything plays well together.
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 07:26:09 am
That would work, but that is dependant on how fast the micro controller is running
Title: Re: Differential Bi phase Level Decoder
Post by: Dubbie on October 18, 2018, 07:45:41 am
Have you got any experience with fpgas? This would be pretty simple to implement on one. Kinda seems like overkill almost though. Maybe a cpld? Or get one of those soc micros with the built in clpd.
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 08:11:38 am
I have one, but I want a standalone system, the board I have is zynq and it will be overkill
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 08:12:33 am
can it be done use discrete components, it is better
Title: Re: Differential Bi phase Level Decoder
Post by: Dubbie on October 18, 2018, 08:20:50 am
You could make it out of a fistful of 74 series logic
Title: Re: Differential Bi phase Level Decoder
Post by: KrudyZ on October 18, 2018, 08:56:40 am
If you have a synchronous clock, then it's trivial.
In the likely event that you don't have that, you would either need to do clock recovery or oversampling.
Since your data rate is fairly low, I would suggest to oversample the data to recover the bits.
Use a couple of flops to remove metastability from the synchronizing stage.
Then detect edges by comparing two consecutive samples.
Start a counter when you see an edge and measure clock cycles to the next edge.
Use a window comparison to figure out if you just saw a short or long pulse width.
If it was long then you saw a zero.
If it is short set a flag, unless the flag is already set in which case you detected a one.
Make sure to reset the flag when you see a zero as well and capture weird pulses as errors, which will help with debug.
You should aim to get at least three to four samples on the short pulse width, more is better, so the sample clock frequency should be above 4 MHz.
Easy to do inside a CPLD or FPGA.
You could also do this on a dedicated timer pin of an MCU, but you would be spending a lot of time in the interrupt routine and might not get much else done.
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 09:06:42 am
Does anybody know how to translate a finite state machine into logic gates,
Title: Re: Differential Bi phase Level Decoder
Post by: man_marius on October 18, 2018, 09:11:10 am
thanks @KrudyZ, I will make the design and share it with you guys just for verifications
Title: Re: Differential Bi phase Level Decoder
Post by: nctnico on October 18, 2018, 04:46:41 pm
What is the signalling rate of the signal?
The easiest way is to sample with 6x (or more) the transmission clock rate and then use a state machine to decode the bits. You can make this auto-align by resetting the statemachine when it detects an illegal combination. IIRC I made an NRZ decoder using two GAL22V10s back in school >20 years ago so a simple CPLD should be able to do it.
Title: Re: Differential Bi phase Level Decoder
Post by: JS on October 19, 2018, 07:26:58 am
Isn't that differential manchester encoding?

Nobody mentioned it in the thread so you can go to google and get useful results, I bet you can find vhdl code for that!

JS

Title: Re: Differential Bi phase Level Decoder
Post by: cv007 on October 19, 2018, 02:25:25 pm
http://ww1.microchip.com/downloads/en/appnotes/01470a.pdf (http://ww1.microchip.com/downloads/en/appnotes/01470a.pdf)

a PIC16F15323  (<$1) has 4 clc's and an nco