Author Topic: Hooking up LEDs to my UART's RX and TX lines  (Read 6314 times)

0 Members and 1 Guest are viewing this topic.

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Hooking up LEDs to my UART's RX and TX lines
« on: April 30, 2008, 11:16:05 PM »
I have an Atmega8 hooked up to a bluetooth module.  I'd like to hook up LEDs to the lines so that they blink as data is being transferred.  I presume I can just connect each of the UART lines to ground with an LED and resistor.   Is this right?  If the LED lines siphoned almost all of the current away from the uc / bluetooth, would it cause a problem?

Here's the diagram I'm thinking about

Bluetooth module TX ---------------------|----------------- Atmega8 RX
                                                             |
                                                            LED
                                                              V
                                                              |
                                                        RESISTOR
                                                              |
                                                            GND
« Last Edit: April 30, 2008, 11:21:40 PM by stopgo »

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #1 on: May 01, 2008, 02:41:08 AM »
whats the idea of doing so????
the data is so fast you wont recognize anything,,, and the resistor should have a big value
so the led wont take current enough,,,
its just a pointless idea
good ol' BeNNy

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #2 on: May 01, 2008, 02:50:55 AM »
Quote
whats the idea of doing so?Huh
for debugging obviously.

Quote
its just a pointless idea
it's a very good idea. that is why you see them on a lot of RS232 coms equipment.

stopgo: i can't remember if the UART lines are high or low when inactive.
but yes, that is the right idea.
try it your way round first
but
if you find the LED on when the UART is inactive just connect the LED between the signal line and Vcc. (instead of GND.)


dunk.

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #3 on: May 01, 2008, 05:43:39 AM »
There is a sparkfun rs232 shifter board that uses leds to flash (and you do see them flash when the data is moving. ) Maybe you can see the schematic on the website to see how they do it.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #4 on: May 01, 2008, 08:56:55 AM »
using baud rates its very fast the digital byte travels, so a led is obviously not the best way to do your debug
because you would not be able to know the exact byte value.

to do debugging just hook it to a pc and send/recieve bytes.

good ol' BeNNy

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #5 on: May 01, 2008, 09:31:05 AM »
You can use the leds to debug at most at a hardware level, ie working/not working. You won't be able to decode data over the serial simply by watching it. I have leds on my MAX232 pcb, cause I think it's a good idea to see activity.
Remember to wire the leds so that +5V means off, since when idling, the RX/TX pins stay high (this is, before the converter).

edit: oh, and use a resitor >1k, or let the led be commanded via a transistor. This way, you won't introduce additional capacitance over the wires so you can use high baud rates.
« Last Edit: May 01, 2008, 09:32:16 AM by izua »
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #6 on: May 01, 2008, 11:13:01 AM »
Quote
oh, and use a resitor >1k, or let the led be commanded via a transistor. This way, you won't introduce additional capacitance over the wires so you can use high baud rates.

Can you explain why this would add capacitance?  I can see how such a setup could be a bit like adding a capacitor... essentially current (limited by a resistor) is leaking onto the RX/TX lines whenever they are low.  Is that the reason?

Offline Steel_monkey

  • Full Member
  • ***
  • Posts: 85
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #7 on: May 01, 2008, 04:16:52 PM »
To detect, if something is working/broken there exists a multimeter. Then, if additional info required- oscilloscope/COM port (inputs can be paralleled- to ATmega and PC) /PC soundcard ( 9600 can be heard, and,  recorded with 44000 samplerate). Led will not give much info.

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #8 on: May 01, 2008, 07:20:53 PM »
I've got the LEDs hooked up and they're doing a decent job.  Obviously, not as informative as an oscilloscope, but the intensity / frequency of the light blinking already helped me debug the fact that my microcontroller and my bluetooth module were speaking at different speeds.  It's nice to just have a status indicator always around.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #9 on: May 01, 2008, 08:51:44 PM »
I've got the LEDs hooked up and they're doing a decent job.  Obviously, not as informative as an oscilloscope, but the intensity / frequency of the light blinking already helped me debug the fact that my microcontroller and my bluetooth module were speaking at different speeds.  It's nice to just have a status indicator always around.

nice

can you post the final schematic up?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #10 on: May 02, 2008, 12:34:33 PM »
Yeah, I'll post this later today.  I'm doing more development (dumping serial data from my microcontroller to my linux laptop) atm and I'm going to go ahead and say that the LEDs are proving invaluable.  Saves tons of times to just be able to glance at my circuit rather than use a probe.

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #11 on: May 09, 2008, 05:42:25 PM »
Sorry, it took me longer than I said it would to get this up here.  Also, please forgive my noobish Eagle skills.

I'm actually having difficulty with this setup.  Having the LEDs is really nice, but I think these LED + resistor lines are essentially pull-up resistors and I chose too low of a resistance value.  When I look on the scope at the marks, they just aren't being pulled down to 0V.  The spaces are at like 3.3V and the marks are at like 3V.  Is this like having large bus capacitance? 

I'm still having some conceptual difficulty with how pull-up resistors work.  I think the issue is that I don't really understand what's going on at the microcontroller pin.  The whole pull-up thing shouldn't really work unless we can think of the microcontroller pin as having huge resistance during a space, and then, I guess, having 0 resistance during a mark.  The fact that my marks are at 3V and not 0V suggests to me that the 0 resistance assumption is false, and that my pull-up resistors (having about 700 ohms) are much less resistive than the microcontroller pin on a space.  I'm going to try increasing my pull-up resistance and see what happens.
« Last Edit: May 09, 2008, 05:50:55 PM by stopgo »

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #12 on: May 09, 2008, 06:33:21 PM »
Hmm, I swapped out my lower resistors for a pair 4k7s and now the marks are at the proper level.  Looks good so far... hopefully this will fix this mysterious software issues I've been having.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #13 on: May 10, 2008, 10:24:17 AM »
Look, because I tried it and I know...

For this job you obviously need a transistor...
Cause if the Led draws current you won't get any data though...

Whatever transistor you use (I mean PNP or NPN)... just use a 10K between the line and the transistor base and you are done...

I would prefer a BC557 or BC547 for this job...
And don't forget the LED resistor... with a 220Ω you are ok!

Cheers!!!

Lefteris
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #14 on: May 10, 2008, 04:43:51 PM »
TrickyNeckro, can you clarify this?

Quote
For this job you obviously need a transistor...
Cause if the Led draws current you won't get any data though...

Why would the LED drawing current disrupt my data flow?  I had this working at low baud a bit ago, so it certainly was able to transmit some data.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #15 on: May 10, 2008, 04:54:45 PM »
Man... I used a led at the programming reset line of microcontroller...
You must know how much current your controller can supply and if it's able to feed both the device and the LEDs...

You see electronics are kinda complicated... also... what a lot of people miss is that a diode, and a light emitting diode as well, has works
like a capacitor reversed... meaning that the have capacitance capabilities... working like a filter in higher frequencies cutting of data...
You don't have this problem with transistor don't worry... so it's more wise to use a transistor in between the LED and the line...
I hope you know how to connect one :P... Just use a 10K resistor between the line and the transistor base if you are going to
connect the collector to the power supply and the emitter to the LED...

I again hope you know how a transistor is... (cause I'm bored to explain ::)... but I'll do if must 8))


Anyways, ask whatever you want...
Lefteris
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #16 on: May 10, 2008, 09:34:07 PM »
TrickyNeckro,

I've never directly used a transistor in a circuit design before, but I have a rough idea of how they work.  Would you be willing to post a schematic?

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #17 on: May 12, 2008, 02:28:36 AM »
TrickyNeckro,

I've never directly used a transistor in a circuit design before, but I have a rough idea of how they work.  Would you be willing to post a schematic?

Since I promised to help... here is the schematics of what you want... hope they help
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline stopgoTopic starter

  • Full Member
  • ***
  • Posts: 58
  • Helpful? 0
Re: Hooking up LEDs to my UART's RX and TX lines
« Reply #18 on: May 12, 2008, 05:42:28 AM »
This is extremely clear now.  Thank you very much!

 


Get Your Ad Here

data_list