0
\$\begingroup\$

For a project, I am trying to decode the digital signal (depicted as Example 1 and 2 in the diagram below) into UART and from UART into a similar digital signal. The digital signal is generated from a power line communication protocol/chip.

Digital Signal to UART Diagram is made with http://wavedrom.com/

As you can see data is half the speed of the actual changes, the second half of each UART data-bit the signal always goes to logic 1 if it was not already 1.

If the data is 9600 baud 8 bits even parity and one stop bit, the current digital signal is not decoded well. Is there an easy solution to it? E.g. removing the change in the last half of the data bit.

For encoding, how could the UART data be converted back again? Since we need to add again the 1 for the second half of each bit.

How can this be solved? Since bit banging is not the nicest solution.

\$\endgroup\$
  • \$\begingroup\$ You're good at describing the problems you are faced with in great detail. But.. this question boils down to "solve this for me" which is harder to help than "I've tried this, how should I continue?". \$\endgroup\$ – Harry Svensson Jan 25 '18 at 9:49
  • 1
    \$\begingroup\$ Since bit banging is not the nicest solution. That is your opinion. I would immediate grab a 6-pin MCU and have it solved. Even commercially I don't think you find a cheaper solution. \$\endgroup\$ – Oldfart Jan 25 '18 at 10:08
  • \$\begingroup\$ @HarrySvensson What I have tried so far is double the baud rate, however, I will need to retrieve 17 data bits (excluding parity), but the microcontroller can only support up to 16 bits in hardware. \$\endgroup\$ – EmbedWise Jan 26 '18 at 3:36
  • 1
    \$\begingroup\$ This is the well-known "Return-to-Zero, Inverted" line code. \$\endgroup\$ – Ben Voigt Jan 28 '18 at 23:14
  • 1
    \$\begingroup\$ Note that many microcontroller UART/USART peripherals have an IrDA mode that directly supports this line coding, possibly requiring an external inverter. Check the programming guide for your microcontroller and see if it has a UART IrDA mode that behaves like this. \$\endgroup\$ – Ben Voigt Jan 28 '18 at 23:29
1
\$\begingroup\$

Thank you all for the answers.

IrDA mode is the easiest solution in hardware, provided by @Ben Voigt,

I started looking into IrDA, and found the hardware solution that works! The microcontroller that I am using supports USART-IrDA, for me it was necessary to invert the signal set oversampling to 8 and the pulse width to 4/8, to get the required 50% pulse width.

\$\endgroup\$
0
\$\begingroup\$

When receiving

You could use the same baud rate if you delay everything after the start bit by a little amount. This can be implemented with a delay element (2 logic inverters acting as a buffer with some RC filter in between) and a mux and a counter. Or just add another MCU as oldfart says. Bit banging vs hardware solution. Easy vs hard.

Here's the delay element I'm talking about.

enter image description here

Here's the link if you want to mess around.

And the delayed data would be everything except for the start bit. So a counter that goes to 11 and then resets would be something. And a mux where the one channel goes straight through and another channel goes through the circuitry above.

But now when I'm thinking about it, the data is 1/4th away from where it should be. If it would've been 1/2 away then the data would have been at the transitioning point, but now the transitioning point is... relatively far away, so I believe you can read this data without any problems at all.

Same baudrate, output to input. No extra circuitry or bit banging.


When sending:

It's only the zeros that send half 0 and half 1. In other words you can just hook up a circuit that sends inverted pulses on falling edges.

This is a simple schematic that does just that. All you have to do is change the RC constant.

enter image description here

Here's the link if you want to mess around.

It's hard to make some bits when clicking by hand. But as you can see, ones keep the output at 1, zeros make it go low for a set duration and then goes back up again. Exactly as what you are trying to do.

Gahh I just realized that this circuit won't re-trigger if two zeros are sent in a row... Hmm, when sending I believe you need to use bit banging, because things are flipping at a specific clock. I doubt you want to use an external oscillator... well.. I don't even know if you are using one or not. Either way, I'd recommend solving it on the software side.


TLDR;

When reading, just use the same baudrate and everything should be fine.

When sending, use bit banging. If there is an external clock for the UART (turning it into a USART), then you can modify the sending circuitry above and solve it on the hardware side.

\$\endgroup\$
  • \$\begingroup\$ Thank you for the elaborate answer, really appreciate it. I upvoted your answer, however, I do not have enough reputation to upvote it yet ;) I will try out if I at least can receive with the uart and the delay circuit, which already helps a lot. \$\endgroup\$ – EmbedWise Jan 26 '18 at 6:24
  • 1
    \$\begingroup\$ You'd have to choose your capacitor wisely in that delay circuit, though - or else it would vary quite a bit over temperature \$\endgroup\$ – MrGerber Jan 26 '18 at 6:26
0
\$\begingroup\$

it can be solved in hardware by stretching the low parts of the signals:

schematic

to create such a signal or the uart output with the bit clock.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.