Inverted sertxd output on picaxe. How to disinvert it?  - Page 1
Forum section: electronics / general

author: Bendba
author_rank: Regular Contributor
timestamp: March 30, 2017, 12:37:26 pm
content: Hi,Here is somewhat of a silly issue I have with a picaxe 08m2. I'm transmitting some serial datas to an arduino over a rf link using the sertxd command (I don't particularly want to use serout or other software serial and/or another pin as it slows things down too much). And I can't seem to find how to set it to have a true output instead of an inverted output. So I have to put it through an inverter before feeding it in the transmitter (74HCT04 at the moment) but I would like to save a chip on the final project.Is there a trick for it?

author: macboy
author_rank: Super Contributor
timestamp: March 31, 2017, 04:07:54 pm
content: Have a look athttp://www.picaxe.com/BASIC-Commands/Serial-RS232-Interfacing/hsersetup/Try changing bit 1 of the mode byte to 1. Or set the baud rate in your serout command to "Nxxxx" (instead of Txxxx) where the xxxx is your desired speed.

author: Bendba
author_rank: Regular Contributor
timestamp: April 01, 2017, 10:35:26 am
content: Hi macboy,I guess that deserves at least a slap in the wrist, it's in the book and I must it.QuoteThat's the bit (literally) I was after, as sertxd is by default 4800 baud, inverted, 8 bit, no parity, 1 stop bitAnd I need true UARTThanks a lot

author: mikerj
author_rank: Super Contributor
timestamp: April 01, 2017, 06:41:42 pm
content: Quote from: Bendba on April 01, 2017, 10:35:26 amTo be fair the output of hardware UARTs is almost universally inverted by default.

author: Ian.M
author_rank: Super Contributor
timestamp: April 01, 2017, 07:35:25 pm
content: Yes. The RS-232 standards family defines logic 1 ('Mark') as a negative voltage range and logic '0' ('Space') as a positive voltage range, and that the line idles in the 'Mark' state. This is inverted with respect to normal TTL or CMOS logic levels and the line drivers and receivers are expected to perform this inversion. Nearly all standard UARTs use logic 1for 'Mark' so idle high. A *VERY* few provide the option to logically invert their TX and/or RX lines to allow a simplified connection to RS-232 compatible devices that can accept reduced voltage levels inlludimng extending 'Mark' to slightly above 0V. Notably Microchip's newer PIC18...K/J.... parts typically have this option, as do some PIC18xxxx and PIC16F1xxxx parts.If the PIC hardware doesn't support inverted mode, the only way the PICAXE can offer UART signal inversion is by bit-banging the protocol. This adds a considerable processing overhead so is generally worth avoiding.

author: Bendba
author_rank: Regular Contributor
timestamp: April 02, 2017, 12:33:24 am
content: Hi,Just to make sure there is no misunderstanding, let me recap:As I thought, and you confirmed it, the RS232 protocol is I = negative voltage and O = positive voltage. (By I and O, I'm talking about the state of the line, not the value of the bit transferred of course)Bus drivers such as MAX232 are inverting the signal aren't they?UART protocol is I = ~V+ (~3.3V or ~5V) and O = ~Gnd (~0V), idle high, isn't it?Picaxe default serial is I = ~Gnd and O = ~V+, or inverted, idle low. So I need to invert again it to be able to communicate from chip to chip using the UART protocol, without bus driver, isn't that right? Which is why my original question. And that's what the "mode" in the hsersetup is for.If I'm right, that summarizes it, doesn't it?The other thing I've noticed is when using rf links, the transmission is a lot clearer using true UART logic levels as it is easier to detect seen it idles high (relatively no noise received when idling) . Compared to inverted, you receive a lot of noise all the time except when transmitting. But it is hard to differentiate transmission high from the ambient noise. (Sorry if the last bit isn't clear.)Thanks

author: Bendba
author_rank: Regular Contributor
timestamp: April 03, 2017, 12:23:55 pm
content: Hi,I finally got time to try out the hserout settings and it works like a clockwork. That solved many problems (I can finally communicate between arduino and picaxe, and between picaxe and my phone via Bluetooth.)Thanks heaps.