Pages: [1]   Go Down
Author Topic: Arduino UNO serial connection  (Read 3975 times)
0 Members and 1 Guest are viewing this topic.
Rome
Offline Offline
God Member
*****
Karma: 1
Posts: 987
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From official page:

Communication

The Arduino UNo has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The '8U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is required. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1).

Does this mean that I can just connect pins 0 and 1 to a standard PC serial port, without any serial adapter which inverts signals as required for TTL/Serial conversion (-12 -> +5 , +12 -> 0)?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does this mean that I can just connect pins 0 and 1 to a standard PC serial port, without any serial adapter which inverts signals as required for TTL/Serial conversion (-12 -> +5 , +12 -> 0)?
Only if you want to fry it.

Quote
The ATmega328 provides UART [glow]TTL (5V[/glow]) serial communication,

Quote
An ATmega8U2 on the board channels this serial communication[glow] over USB[/glow]
No true serial port connection/communication takes place at all.
Logged

Rome
Offline Offline
God Member
*****
Karma: 1
Posts: 987
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it's just a matter of reducing voltage: as far as I can understand, The ATmega328 provides UART TTL (5V) serial communication, An ATmega8U2 on the board channels this serial communication over USB  means that Atmega328 uses UART protocol ( V<0 : HIGH; V>0 : LOW) and Atmega8U2 turns UART protocol into USB protocol, regardless of voltage.

In other words, maybe I'm wrong, but I think UART communication is made of UART protocol and UART levels:
UART protocol:  V<0 : HIGH , V>0 : LOW
UART levels: 12 V

TTL protocol: V>0: HIGH , V<0 : LOW
TTL levels: 5V

How can we verify this?
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
maybe I'm wrong, but I think
.
.
.
How can we verify this?
For verification, see the Footnote.

Now, here's the deal about what I think you are missing:

The serial port on a PC uses RS232 communications.

On the data lines (TXD and RXD) logic 1 is a negative voltage (nominally -6 to -12 Volta) and logic 0 is a positive voltage (nominally +6 to +12 Volts).


Data communication on a PC UART port can be set up in various modes.  For communications with an Arduino board, here's what happens on the RS-232 data lines:

Idle (no data being transferred): Logic 1

Data bytes consist of the following ten bits:
Start bit (logic 0)
Eight data bits  (data bit 1 ==> logic level 1; data bit 0 ==> logic level 0
Stop bit (logic 1)



If another byte is to be transferred, its start bit can begin any time after the end of the stop bit of the previous byte.  The data lines are held in the idle state between bytes.

Using the ATmega hardware UART, here's the deal:

Logic 1 is nominally equal to the supply voltage of the ATmega.  That's +5 Volts for Arduino Duemilanove, Arduino UNO, Arduino MEGA and lots of others.  Some are designed to use +3.3 Volts

Logic 0 on the ATmega is nominally equal to zero volts.



For serial data transfer using the hardware UART on an ATmega with Arduino software, here's what happens on the serial I/O lines:


Idle (no data being transferred): Logic 1

Data bytes consist of the following ten bits:
Start bit (logic 0)
Eight data bits  (data bit 1 ==> logic level 1; data bit 0 ==> logic level 0
Stop bit (logic 1)


That is: It's exactly the same UART settings as the PC, but the physical layer logic levels are different.

Bottom line:
The voltage levels on the serial data lines between the PC to the ATmega must be level shifted and inverted.

Note that some PC serial ports will actually operate on input data line levels of +5 Volts for logic 0 and 0 Volts for logic 1, and I have seen some kludgy circuitry that doesn't actually create negative RS232 voltages. Sometimes that kind of junky stuff works and sometimes not (depending on the PC circuitry).

Output signals from the PC can be converted from +12 Volts and -12 Volts to zero and +5 Volts, respectively, fairly easily but note that a logic inversion is required.

There are various commercial RS-232 to TTL converters available or you can build your own with readily available chips such as MAX232, MAX2232, etc..

Note that if you use a serial port RS232 to TTL conversion circuit for a 5 Volt Arduino board, you have to supply +5 Volts from an external power supply to the converter circuit as well as the Arduino board, whereas with a USB interface the Arduino board can get its operating voltage USB port on the PC.


Regards,

Dave

Footnote:
You can verify this by measuring voltages during idle states on the PC RS232 data lines and on the ATmega UART I/O lines.  This can be done with just about any kind of voltmeter.

If you have access to an oscilloscope, you can look at the signals as data bytes are being transferred.   You will note that the data bytes are sent least-significant-bit first.

I have done this many times over the years, including recent development with RS-232 converters for my non-USB Arduino designs, but I heartily recommend that you conduct your own experiments.
« Last Edit: November 12, 2010, 12:12:51 pm by davekw7x » Logged

Pages: [1]   Go Up
Jump to: