Go Down

Topic: Digital Pin 0 and 1 (RX, TX) (Read 11028 times) previous topic - next topic

Grumpy_Mike

Quote
I guess this means that as long as you can disconnect whatever it is you have hooked up to that pin while you're uploading the sketch, you could reconnect it after the sketch is uploaded and everything will work fine?


Yes exactly. That is what I have done here:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html

scswift

Quote
Sorry that's not how it works. A diode would present a low impedance because it would short out half the time and the other half it would be open circuit. In effect the short wins and gives a low impedance.


Ah. :(


Quote
Here impedance is used to indicate the load on a pin. What you have to consider is that the USB / Serial chip is trying to drive the arduino pin, if you put another load across it there might not be enough power to drive both the arduino and the load you put on the pin.


So what about the circuit I described?

If I have an LED with the anode connected to pin 0, and the cathode connected, via a resistor, to another pin, then as long as that other pin is low, there won't be a load, right?  The serial pin may go high and low, but when it's low, no electricity would flow from one pin to the other, and when it's high, the led would prevent the electricity from flowing.  Correct?

What state are the pins in when I reset the Arduino though?  They are low, aren't they?  If they're high, that might be a problem.

Grumpy_Mike

#17
Feb 19, 2010, 02:46 pm Last Edit: Feb 19, 2010, 02:46 pm by Grumpy_Mike Reason: 1
Quote
What state are the pins in when I reset the Arduino


They default to inputs so they are all high impedance.

Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.

scswift

You said earlier that a high impedance load is no problem.  And that an LED is such a high impedance load.  

But you also indicated that a diode isn't a high impedance load.  Or at least, that connecting a diode in series with a low impedance load wouldn't allow you to connect the low impedance load.

Does high impedance mean low resistance?

You also just said the pins are set to an input state which is high impedance.  Does that also mean low resistance?  I thought the input state was one where they went to ground via a large resistor, which is why you can use that state to charlieplex... because electricity won't flow easily.

But then you said:

Quote
Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.


Given that it's been said leds are high impedance, and the pins are high impedance, and that it was said high impedance loads aren't a problem for the serial pins, why does it seem here like you're indicating that the setup I descibed will interfere with uploading the sketches?

I'm totally confused now. :-(

scswift

Let's start over.


Quote
Kind of depends exactly what you're doing with the digital pins beside using them for serial communications.  If you're blinking LEDS with them it isn't going to be a problem, if its a lowish impedance circuit it will be a problem, of course your sketch will need to allow for it if you're using it for serial communication within the sketch


Quote
a high impedance load is no problem but a low impedance load will distort the signals coming in / out to / from the serial / USB chip.


Quote
Quote
What state are the pins in when I reset the Arduino?

They default to inputs so they are all high impedance.

Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.



Okay, so I've been reading up on impedance, and what I've read seems to indicate that in general, impedance = resistance.  Therefore, high impedance means high resistance.  

If that's the case, then I'm guessing that those pins which are set to input, a high impedance state, are going to ground through a large resistor.

And when you say that it's okay to connect a high impedance load to the serial pins, what you mean is that it's okay to connect a load with a lot of resistance.

What I don't get is why that means an led is okay, but something else with a resistor in series is not.

What I also don't get is if it's the voltage that matters to the serial chip, then why is an led okay, but something else with a resistor is not.  A resistor to my knowledge doesn't affect voltage levels.  An led does.

Lastly, if an led is a high impedance load, and the pins are set to a high impedance state, then that's like twice the impedance.  Shouldn't an LED connected (via a resistor) between one of the serial pins, and another pin therefore have no effect on the serial signal when it is off?

What I really need to know is if I can multiplex an array of led's using those serial pins for a couple of the rows without affecting my ability to upload sketches.  

I could unplug the arduino to upload a sketch, but I'd rather not stress the chip plugging and unplugging it if I don't have to.  I don't even know how easy it will be to get those header pins out of the IC socket once they're in there.

scswift

Hm, well the good news is once I get the pins into my 20 pin socket they seem to go in and out without too much difficulty... and I don't need to worry about bending them like with ic pins, so maybe pulling the arduino out to program it will work for me.

I'd still like to understand exactly what I can and can't do with the serial pins though.

Also, if pin 1 is set high when the arduino is reset, and shutting off the power to it is the same as a reset, then does that mean when I turn the power on, pin 1 is going to be high?

If pin 1 is high, and I have an led on that going to another pin, and the other pin is set to an input state... then the led is either not going to light, or will light dimly, correct?

How long after I apply power to the arduino does it take for the program to start running so I can set that pin to some other state?

Grumpy_Mike

Quote
If that's the case, then I'm guessing that those pins which are set to input, a high impedance state, are going to ground through a large resistor.


Sort of only it means they are effectively disconnected.

Quote
what you mean is that it's okay to connect a load with a lot of resistance.


Yes.
Quote
What I don't get is why that means an led is okay, but something else with a resistor in series is not.

No an LED is not a high impedance load. An LED is a load, it can be quite heavy (low impedance). If you put a bigger series resister with the LED it can make it a higher impedance BUT it has to be a much higher resistance than you would normally use and the LED will be quite dim.

Quote
and shutting off the power to it is the same as a reset

No shutting off the power is turning it off, it is not resetting it.

Quote
when I turn the power on, pin 1 is going to be high

When you turn the power on all pins are inputs (high impedance), when it starts the boot loader program makes it into an output and sets it high because that is the state of a serial line sending nothing.

Quote

How long after I apply power to the arduino does it take for the program to start running so I can set that pin to some other state?

It is about 3 seconds before the boot loader decides it is not going to get a new program and so runs the existing one.


scswift

Quote
No shutting off the power is turning it off, it is not resetting it.


I was told by someone else shutting it off is the same as resetting it.

Both resetting it and cutting power seem to put the arduino in a state where it will accept new programming, so what's the difference?


Quote
It is about 3 seconds before the boot loader decides it is not going to get a new program and so runs the existing one.


I have found that when I plug in my USB cable only partway, the program runs immediately.  Are you saying that is not how it will behave when I simply apply power to it normally, without the breakout board attached?  Why does it behave that way in this instance?

Grumpy_Mike

Quote
I was told by someone else shutting it off is the same as resetting it.


You was told wrong. Were you perhaps told turning off the power AND THEN turning it on again caused a reset?

Quote
Both resetting it and cutting power seem to put the arduino in a state where it will accept new programming, so what's the difference?


When you cut the power there is no power and so the board can not do anything, it is off.

Quote
have found that when I plug in my USB cable only partway, the program runs immediately.


You shouldn't do this as you have no idea as to what is being connected.

scswift

Quote
Were you perhaps told turning off the power AND THEN turning it on again caused a reset?


Yes.  That's what I meant.


Quote
I have found that when I plug in my USB cable only partway, the program runs immediately.


Quote
You shouldn't do this as you have no idea as to what is being connected.


You're right of course, but that doesn't answer my question as to why it executes the code immediately in that instance.

So I was wondering, I have to send a signal through a transceiver to a receiver, does this mean I must use the pin 1 and 0?

Go Up