Author Topic: UART conections  (Read 2694 times)

0 Members and 1 Guest are viewing this topic.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
UART conections
« on: July 22, 2013, 12:01:15 PM »
hey guys I wanted to add UART function to my Atmega8 form the $50 robot, but I was wondering If i could, open a usb and connect the usb's tx and rx directly to my atmega8...But I saw the UART  tutorial and there was this CP2102, but for what use this thing? Cant i just go form my usb to the atmega8?

The USB has data (+) and data (-)... which one is RX and TX???
« Last Edit: July 22, 2013, 01:36:56 PM by robotmaniac »
Learning from what I can...

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: UART conections
« Reply #1 on: July 22, 2013, 02:05:34 PM »
it is possible to connect m8 directly to usb but the circuit and software are very complicated. better to use a usb2serial dongle like this:

http://www.ebay.com/itm/USB-To-RS232-TTL-Auto-Converter-Module-Converter-Adapter-For-Arduino-S9-F8s-/370859426819?pt=LH_DefaultDomain_0&hash=item5658f1c403#ht_4376wt_1056

they only cost a buck or so and will allow interfacing many different serial projects.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: UART conections
« Reply #2 on: July 22, 2013, 04:27:00 PM »
hey, thanks but what about using a usb cable used for cellphones... I mean, cellphones have microcontrollers of some sort so wouldnt that usb have a thing for communicating the computer with the cellphone? ?
and sorry for my english, I am from Puerto Rico...
Learning from what I can...

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: UART conections
« Reply #3 on: July 22, 2013, 04:30:23 PM »
hey guys I wanted to add UART function to my Atmega8 form the $50 robot, but I was wondering If i could, open a usb and connect the usb's tx and rx directly to my atmega8...But I saw the UART  tutorial and there was this CP2102, but for what use this thing? Cant i just go form my usb to the atmega8?

The USB has data (+) and data (-)... which one is RX and TX???

The Atmega8 does not support USB. The TX/RX on the Atmega8 speak "UART" protocol. Meanwhile, the D+ and D- on a USB port speak "USB NRZ" protocol. They are not compatible.
There is a version of the Atmega8 called the Atmega8u2 which does support USB, but unfortunately, it's not available in DIP package, only in surface-mount package, so it's going to be very hard to work with if you don't know how to do reflow soldering in an oven.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: UART conections
« Reply #4 on: July 22, 2013, 04:40:22 PM »
 :o OK, thanks buddy... I will buy the USB2serial dongle... I don't need anything else for the UART right?? Already have Hyper-terminal...
Learning from what I can...

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: UART conections
« Reply #5 on: July 22, 2013, 05:49:06 PM »
First look up UART, asynchronous serial, RS232 and USB in Wiki to learn about these.
Second, there are a few Async Serial (UART) to USB adapters. These use a chip that converts between the two protocols and are fairly easy to use.
Adafruit and SparkFun both sell them that go for your USB port directly to your Atmega UART pins.

Other adapters go from USB to RS232 which then means you need an RS232 to TTL level translation chip, like a MAX232.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: UART conections
« Reply #6 on: July 22, 2013, 07:11:47 PM »
ok, thank you guys :)
Learning from what I can...

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Learning from what I can...

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: UART conections
« Reply #8 on: July 23, 2013, 06:24:57 AM »
yes, other than costing 4x more than the one in the link i gave you it will work fine. all you need is hyperterm and the software driver which is easy to download.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: UART conections
« Reply #9 on: July 23, 2013, 12:08:47 PM »
Haha, but the one you gave me is from USB to rs232 right? So I would need for example a max232?
Learning from what I can...

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: UART conections
« Reply #10 on: July 24, 2013, 10:29:21 AM »
RS232 is a high-voltage dual-voltage signaling scheme (typically -12V for 1 and +12V for 0.)
The USB adapter shown is to TTL levels (which means 5V) where +5V is 1 and 0V is 0.
The TTL version is what you need for any on-board UART connections. The Max232 chip is only needed if you actually need to talk to RS232 specific equipment through RS232 connectors (typically DB-25, or DB-9 form factor.)
It is a little confusing that, sometimes, people will say "RS232" when they really mean "asynchronous serial." The key in the product listing is that it says "TTL" in the title. (There is no such thing as "RS232 TTL" but there is "TTL-level asynchronous serial.") Additionally, generating RS232 signals from an USB bus powered device is somewhat complex, and requires more hardware than can be seen on that dongle, and would also significantly increase the price.
« Last Edit: July 24, 2013, 10:30:50 AM by jwatte »

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: UART conections
« Reply #11 on: July 24, 2013, 11:04:39 AM »
Haha, but the one you gave me is from USB to rs232 right? So I would need for example a max232?

nope. virtually all these little pcb dongles are active low signal which is what the mcu needs. although commonly called "ttl" or "5v", this is a big mistake because level has nothing to do with it. original rs232 worked fine with ttl/5v. it is polarity that matters and creates 99% of the confusion for those starting out.

old pc rs232 was active high (+9v, +12v, etc) but modern serial is overwhelmingly reversed to active low (0v). voltage never really matters. its polarity and baud that count.
« Last Edit: July 24, 2013, 11:07:19 AM by johnwarfin »

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: UART conections
« Reply #12 on: July 24, 2013, 11:51:12 AM »
All of this is why I suggested to:
Quote
First look up UART, asynchronous serial, RS232 and USB in Wiki to learn about these.
Else is does get confusing especially when some one advertizes some thing that is "RS232 TTL" which jwatt commented on correctly.

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: UART conections
« Reply #13 on: July 25, 2013, 09:51:14 AM »
Quote
old pc rs232 was active high (+9v, +12v, etc) but modern serial is overwhelmingly reversed to active low (0v).

What's extra confusing is that what you call "active" here is actually the "0" value for a bit. The TTL asynchronous serial devices all pull the line up to 5V while idle. Then, the "start bit" is a zero, so it will pull the line low to indicate the byte that's coming, then the logic level is normal (5V == 1, 0V == 0) for each bit, then the stop bit is high, which returns the line to "idle" 5V state.

Meanwhile, RS232 defines the negative voltage as the "1" state, and the positive voltage as the "0" state. What you call "active" would be less confusingly called "logical 0" IMO.

Offline johnwarfin

  • Full Member
  • ***
  • Posts: 120
  • Helpful? 3
Re: UART conections
« Reply #14 on: July 25, 2013, 07:15:07 PM »
in electrical engineering active low refers to input and output pin voltage and has nothing to do with binary software states. if it performs a function when 0v or negative its "active low". otherwise "active high". if those terms bother you then "idle high" and "idle low" are acceptable, but less common, alternatives. "logical 0" or "logical 1" is more appropriate for describing boolean operations and other internal software states. in any case with modern pc async and nearly all mcu uarts active low IS logic zero.

its true that polarity results in some confusion for beginners but nowhere near as bad as referring to "level" (ttl or otherwise) which has little to do with most serial problems.

 


Get Your Ad Here

data_list