full duplex serial question
mikea
Posts: 283
I'm sorting out a code problem, and not sure what the zero relates to in this ... Debug.start(31,30,0,9600). 31, 30 are serial to talk to p.c., and 9600 is baud speed, right? Also for next time where would i look to find the docs on my own for code like this and the ASCII codes. E.G. ..13 i think is carriage return.Thanks-mike
Comments
In debug.start(31,30,0,9600) the 0 is to invert RX. Its the mode in how the bits are sent. Google ASCII chart and you will get many pictures you can print out and place next to your monitor.
You might be mistaken...
This is a copy of the comments in the object So mode 0 inverts rx unless my object is out dated or has been molested in some digital form.
Here is the object.
Attachment not found.
If mode is set to 1 (%00000001) rx is inverted. If mode is set to two (%00000010) tx is inverted. You can invert both by using mode equal to 3 (%00000011).
The normal mode is "0" which means neither are inverted. How it works is that RS232 drivers and receivers invert the bits sent and received by the UART. So, in our case, the bits are sent and received by the prop which is acting like a UART. Now, if we connect directly to the FT232RL USB chip, we are again connecting to a UART equivalent. This means we have a direct connection UART to UART, so we omit the RS232 drivers and receivers at each end which cancel each inversion out. Hence, our code does not require inversion.
However, if we connect directly to an external RS232 device, such as a PC, using just serial resistors and pullup/pulldown (need to think which atm), then you would require FDX to invert both the TX and RX because you have omitted the RS232 driver and receiver. Sometimes this works and sometimes it does not, depending on the actual interface used in the PC (or other RS232 device). This is because you are swtching between +3V3 and GND and the RS232 requires +V and -V (used to be 12-15V, but has been lowered in later RS232 revisions). However, often the chips used these days see > +3V as the +V and GND as the -V.
So, to recap, if you have a true RS232 connection, and you omit the inversion in hardware (the RS232 driver/receiver) then you need to invert the tx/rx pins accordingly in software. If you omit the inversion in hardware at both ends (i.e. both are at TTL or CMOS levels and not RS232 levels) you do not require software inversion.
An easy way to remember is if you look at a UART chip, the other pins such as /RTS, /DTR, /CTS, /DCD, /DSR & /RI are all denoted as active low. Then feed these through an RS232 chip which inverts these signals, so +3V becomes -V (~-12V) and GND becomes +V (~+12V). So an active signal is GND which becomes +V in RS232 levels.
Hope this helps.
Enjoy!
Mike