NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » serial data over alternate pins on ATmega168?

January 15, 2012
by jeffspc88mx
jeffspc88mx's Avatar

Can UART be utilized to send its serial bytes over other pins (on ATmega168) other than the Tx and Rx pins? I'm trying to hook up a serial interface from my vacuum fluorescent display to the MCU, but the serial pins on the MCU are currently used for the USB-serial interface to my computer. I suppose I could just set up a DPDT switch and flip it manually along with the programming/execute switch, but that's not as elegant.

January 15, 2012
by BobaMosfet
BobaMosfet's Avatar

jeffspc88mx-

Think it's tied to just PD0 and PD1. I didn't find anything in the datasheet for that to work with other pins.

BM

January 15, 2012
by Rick_S
Rick_S's Avatar

The TX/RX pins cannot be re-directed to other pins. You will have to use the same pins your cable is connected to. Remember, if your display is a serial display, you will need to find out if it is TTL or RS232 levels. If it is RS232, you will need some sort of level translator such as a max232 to communicate with it.

BTW, which display did you get??

Rick

January 15, 2012
by jeffspc88mx
jeffspc88mx's Avatar

Thanks guys. Yeah - that's what I gathered from the data sheet as well, but no matter. This display also utilizes parallel - it's just that it already has the pin header installed for serial. I'll just go parallel with it - it's just a bit messier

FYI, its the noritake-itron gu112x16g-7000

http://dl.dropbox.com/u/46534013/VFD%20gu112x16g-7000_e04%20datasheet%20copy.pdf

I'm training it to be a VU meter for my (also in-progress) mic preamp.

January 16, 2012
by Rick_S
Rick_S's Avatar

That's right, you mentioned that a while back in another thread. Looks to be an interesting display.

If you want to go the serial route, there would probably be no problem having both connected. The display most likely only needs connected to the RX pin of the mcu probably through a transistor or max232 to get the signal correct for what it expects. (You'd also have to connect the NerdKit Ground wire to the display)

Should be an interesting project. Have you thought of an enclosure for the display?

Rick

January 16, 2012
by Rick_S
Rick_S's Avatar

I just noticed. That's a pretty small display. The actual lit up portion is only 2.066" x .45". When I think VFD's, I normally think much larger display's. That should make it easier to find your enclosure.

January 16, 2012
by jeffspc88mx
jeffspc88mx's Avatar

It's going into a microphone preamp, a 3U beast full of tubes and giant capacitors. Most folks use those electromagnet-VU meters, but I have to be different, so I'm having my case customized, but basically it'll look like a piece of audio equipment.

redd47

Except, of course, that the big circle in the center will be a big rectangle.

I did originally want to go big, but i'm glad I didn't given the space restriction. Also I got a deal on this one - apparently it was a demo, so ~$33 for the thing. Noritake sells lots of demo/used stuff on their website.

January 16, 2012
by jeffspc88mx
jeffspc88mx's Avatar

Say - I might go serial IO with this after all. Can I just leave the wires hooked up "live" all the time, or do I need to switch back-and-forth for when I'm programming/reading. That is, is there a risk that I'll accidentally wreck my display while I'm sending programming data to the MCU? And as such I'd need to disconnect the display interface while programming?

There's no worry about the voltage - the display wants 5V for everything. So it'll just go straight into the MCU.

January 16, 2012
by Rick_S
Rick_S's Avatar

Electrically it most likely wouldn't be a problem. The only problem I could see would be if for some reason data would come across during programming that would appear as a control code to the display. It could theoretically mess up custom characters you may have created. Of course if your software in the micro automatically re-created these at run time, even that wouldn't be an issue.

As for the hookup, it wasn't voltage I was referring to. The TTL output of the micro's serial port is inverted to what RS232 serial data is. Which means, if the display is expecting RS232, you would have to go through at least a transistor to flip the signal around for the display to understand it.

Rick

January 16, 2012
by jeffspc88mx
jeffspc88mx's Avatar

Oh yeah - I keep forgetting about polarity. As I read the data sheet, I think it's OK as is. Logic "H" is +5V, "L" is 0V.

January 16, 2012
by Rick_S
Rick_S's Avatar

That isn't what I'm talking about either. The actual data being transmitted by the micro-controller is inverted to what a computer's RS232 would be.

In other words if the RS232 device expected to receive 10011001, the micro's output would be opposite or 01100110, and would have to be inverted for the RS232 to get the actual data expected. This can be done either with a transistor to flip all the bits around or a device like a max232 which not only inverts the signal, it also pumps up the voltage for the RS232 levels.

January 16, 2012
by jeffspc88mx
jeffspc88mx's Avatar

Oh - so are the TX/RX pins on the MCU sending RS232 protocol (i.e., -5V = 1; +5V = 0)? And is this a function of the UART?

If so, then - as you've said - I need to convert the bits before sending them to the display, which itself is not expecting RS232, but is expecting 5V = 1; 0V = 0 bits.

January 16, 2012
by Rick_S
Rick_S's Avatar

The voltage isn't the issue, even though RS232 can do +/- 15v, it doesn't have to. The problem is that according to the display's datasheet, it has an RS232 interface not TTL. The problem is that the mcu is TTL. Even though they are both at 5v, they are not the same. RS232 has a +/- swing and it's bits are opposite what you would think.

If you look at wikipedia, there is this diagram of RS232 protocol.

In that picture, you can see the start bit is high, bits with a 1 value are low and 0 value are high. Stop bits are low.

According to the datasheet for the mcu,

St Start bit, always low.
(n) Data bits (0 to 8).
P Parity bit. Can be odd or even.
Sp Stop bit, always high.
IDLE No transfers on the communication line (RxDn or TxDn). An IDLE line must be high.

As you can see, the protocol is inverted. To make the two talk to each other, you must invert the mcu signal so that the RS232 serial interface of your display will understand what is being sent to it.

Hope that helps clear it up.

Rick

January 16, 2012
by jeffspc88mx
jeffspc88mx's Avatar

OK - I got the inverted thing, but I'm not sure how you determined that the display is RS232. It does say "possible RS232"....

OK, nevermind - I see the clues now in the data sheet. (0 is high, 1 is low in the serial diagram).

Very good then. So I'll get that chip and put it in between the MCU and the display and that'll be a good start.

Thanks for your patient teachings.

January 17, 2012
by Rick_S
Rick_S's Avatar

No problem.

Post a Reply

Please log in to post a reply.

Did you know that spinning a permanent magnet motor makes a voltage? Learn more...