Have we got a way to invert the Tx/Rx signals?

Hi,

I am trying to replace a program written in BASCOM running on an ATMEL ATmega 8 with an Arduino-IDE based solution.

The hardware has a passive-resistive "serial" V-24 like port that connects to PC serial inputs.
These are however running with an inverted logic.

Have we got a way to invert the transmitted Tx/Rx signals?
If yes how could I code that in Arduino C++?

Would it interfere with the boot-loader, or is the chip always starting with UART defaults?

Thank you for your advice.

Please give a proper description of the hardware that you're talking about.

I'm not quite sure what you mean by a passive-resistive interface. Can't you bypass that and use the Arduino's USB; worst case, if you have to deal with RS232 level signals because of antique PC hardware, a MAX232 for level shifting and inversion.

Lastly, if I'm not mistaken, SoftwareSerial supports inverted signals.

sterretje:
Lastly, if I'm not mistaken, SoftwareSerial supports inverted signals.

So do the hardware serial ports in the Teensy Family.

gfvalvo:
So do the hardware serial ports in the Teensy Family.

There is a Teensy with 32U4; I have my doubts :wink: But correct me if I'm wrong :slight_smile:

sterretje:
There is a Teensy with 32U4; I have my doubts :wink: But correct me if I'm wrong :slight_smile:

OK, the ARM-Based ones.

sterretje:
Please give a proper description of the hardware that you're talking about.

I'm not quite sure what you mean by a passive-resistive interface. Can't you bypass that and use the Arduino's USB; worst case, if you have to deal with RS232 level signals because of antique PC hardware, a MAX232 for level shifting and inversion.

Lastly, if I'm not mistaken, SoftwareSerial supports inverted signals.

The existing primitive passive "electrical serial V-24 interface" consists of a protective resistor on TX and a protective resistor clamped by two diodes between 0v and 5V on RX.

I am speaking of a whole bench of about 50 non-Arduino existing devices with a socketed Atmel Mega 8 DIL Chip.

I would just want to replace the chip with one that I would program on an Arduino UNO.
The solution should be for noobs with no skills: take out the DIL chip, plug in the provided new one, finished.

So the programming base MUST be a good old Arduino UNO with a socketed ATmega Chip, nothing else.
The Atmel ATmega 8 UART must be capable of natively inverting TX-RX, since the original BASCOM based firmware does it.

P.S. The BASCOM code contains that:

...
Open "comd.0:19200,8,n4 INVERTED" For Input As #2
Config Portb = Output
Config Ad0 = Single , Prescaler = 16 , Reference A = Off 
...

so it looks like it should be simple to invert the USART IO signals, however I did not find anything related in the ATmega 8 data sheets.

You probably can invert the signals with an NPN transistor and two resistors if a hardware solution is appropriate.

i'm curious, if the signal is inverted, is the start bit being recognized, or is it continuously started?

The start bit is recognized as usual. The relevant waveforms are shown here.

The inverted signal of TTL 0 V roughly corresponds to RS-232 negative, inverted TTL 5V corresponds to RS-232 positive, and is usually but not always recognized as such by old fashioned PC RS232 serial ports.

the start bit is both generated and recognized correctly (a zero), by the UART, but the signal is inverted ?

All signal levels are inverted, to correspond roughly to RS-232 voltage levels as seen and interpreted by a PC RS-232 serial port adapter.

See link in reply #8.

zoomkat:
You probably can invert the signals with an NPN transistor and two resistors if a hardware solution is appropriate.

I would just want to replace the chip with one that I would program on an Arduino UNO.
The solution should be for noobs with no skills: take out the DIL chip, plug in the provided new one, finished.

I guess the question for the OP is what is the resting voltage on the tx and rx lines on the two devices that are to communicate?

zoomkat:
I guess the question for the OP is what is the resting voltage on the tx and rx lines on the two devices that are to communicate?

No. The electrical circuit is given and runs as it should. It is not the "kosher" way of doing a RS232/v24 interface interface, but it works nevertheless.

The problem to solve is to get (by program) The USART of an an Arduino UNO to communicate over TX/RX with an inversed logic, since RS232/V24 standard operates with a reversed logic (a "0" being +12V and a "1" being -12V)

RIN67630:
The problem to solve is to get (by program) The USART of an an Arduino UNO to communicate over TX/RX with an inversed logic, since RS232/V24 standard operates with a reversed logic (a "0" being +12V and a "1" being -12V)

A quick glance over the datasheet of the ATmega8 does not seem to show that the USART can handle reversed logic; I might have missed it though.

Do you have access to the source code of the ATmega8?

i don't understand what is inverted that can be corrected by software. It's not a question of whether a bit is transmitted with +/- voltage (as long as rs-232 and v-24 are consistent)

if the signal on the wire is inverted (polarity reversed between TX and RX), a start bit generated by the UART on the one end would not be the correct level for the UART on the other end to recognize the beginning of the character and the received byte would be corrupted. (parity and stop bits would also be wrong).

(if the UARTs were connected using balanced pair RS-485 transceivers, i would suggest reversing the A/B wires between them) what driver chip is used on the Arduino between its TX/RX and rs-232/v-24 interface?

if by inverted, do you mean each bit in the byte read from the UART buffer is inverted (again can't imagine why)? If this is the case, couldn't each byte simply be exclusive-OR'd

obviously no clear to me (puzzled)
of course the TX on the one side is connected to the RX on the other

The USART of an an Arduino UNO to communicate over TX/RX with an inversed logic, since RS232/V24 standard operates with a reversed logic (a "0" being +12V and a "1" being -12V)

this is handled by the driver chip.

are you connecting the 5V arduino pins directly to the interface?

I looked up RS232/V24

RS232 signal levels
The voltage levels are one of the main items in the specification. For RS232 data signals a voltage of between -3V and -25V represents a logic 1. The logic 0 is represented by a voltage of between +3V and +25V. Control signals are in the "ON" state if their voltage is between +3V and +25V and "OFF" if they are negative, i.e. between -3V and -25V.

Logic 1 is LOW, logic 0 is HIGH.

That's the same thing default Arduino UARTs use, but different voltages.

https://www.avrfreaks.net/forum/inverted-io-direct-avr-uart

Posted by dwb240: Fri. May 18, 2001 - 03:08 AM
Yeah, BASCOM-AVR supports inverted only using the software UART. It does support hardware as well, but then inverted can not be used.

Well maybe the PC is programmed for inverted logic as well. It must beat learning why things work as they do.

That's the same thing default Arduino UARTs use, but different voltages.

but that what makes it rs-232, among other things. The Ardduino isn't going to output -12V, that's why you need a driver chip