Go Down

Topic: How to invert serial polarity (Read 4229 times) previous topic - next topic


On the Arduino Uno, I would like to invert the polarity of the serial tx signal. The default setting is logic high = 5V. I would like to invert it to logic high = 0V.
I am able to do this using SoftwareSerial using the argument, true:

SoftwareSerial mySerial(10,11,true);

However, the SoftwareSerial's maximum speed is 115200 and I would like to run faster than that.
Is there a way to invert the serial polarity?


Jan 31, 2013, 06:26 pm Last Edit: Jan 31, 2013, 06:43 pm by Riva Reason: 1
I'm not sure if the on chip USART supports inverted logic so you will probably need to run the signal(s) through a NOT gate like a 7404 (Expect to be told this is not suitable here)
Don't PM me for help as I will ignore it.


Run the line thru a transistor inverter with open collector (OC) output.
2N2222A or similar NPN transistor , 2 resistors.
When Tx is high, OC is low; when TX is low, OC is high.

Hardware serial can do up to 1Mbps rates. Don't know if the serial libary supports that directly.
I think I tested as high as 250000 with just small burts of data.

See Section 20 of the datasheet for hardware discussion.  Table 20-7 for supported speeds with 16 MHz system clock.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


That works perfectly. Thank you!

Go Up