The drive side can already be set to send inverted data.
I would be looking for the same on the receive side (i.e. add an additional parameter to the Soft_Uart_Init function):
Instead of
void Soft_Uart_Init(unsigned short port, unsigned short rx, unsigned short tx, unsigned short baud_rate, unsigned short inverted);
it would then be
void Soft_Uart_Init(unsigned short port, unsigned short rx, unsigned short tx, unsigned short baud_rate, unsigned short inverted_rx, unsigned short inverted_tx);
Seems simple to do... and it would enable the user to get rid of the MAX232 interface for maximum circuit simplicity.
Wolfang
invert receive data option for soft UART
Actually I don't - I know for sure because I have done it many times in the past - have a look at www.picaxe.co.uk and check out their download circuit. It works very well for connection to a computer.
The idea of that circuit is to use a 22kOhm resistor to limit the maximum current into the microcontroller input. The internal protection diode will then clip anything above Vcc plus one diode drop, and everything below GND minus one diode drop.
So while standard RS-232 uses voltages well above +5V and well below 0V, this simple circuit translates that into roughly 0V to 5V. On the other hand, if you send 0V to 5V, standard RS-232 has a trip point of about +2V, so again data arrives correctly. It does reduce the maximum cable length but that's not an issue for connections that are less than a few meters.
In fact, there is an application note on Microchip's website that uses the same trick - albeit with a much higher resistor value - to have a 16F microcontroller DIRECTLY measure line voltage (i.e. 220V) to get a 50 Hz reference. Not that I personally would recommend this approach in this particular case...
Wolfgang
The idea of that circuit is to use a 22kOhm resistor to limit the maximum current into the microcontroller input. The internal protection diode will then clip anything above Vcc plus one diode drop, and everything below GND minus one diode drop.
So while standard RS-232 uses voltages well above +5V and well below 0V, this simple circuit translates that into roughly 0V to 5V. On the other hand, if you send 0V to 5V, standard RS-232 has a trip point of about +2V, so again data arrives correctly. It does reduce the maximum cable length but that's not an issue for connections that are less than a few meters.
In fact, there is an application note on Microchip's website that uses the same trick - albeit with a much higher resistor value - to have a 16F microcontroller DIRECTLY measure line voltage (i.e. 220V) to get a 50 Hz reference. Not that I personally would recommend this approach in this particular case...
Wolfgang