Pages: [1]   Go Down
Author Topic: Pull-up resistors  (Read 2235 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I will be using Arduino Mega 2560
As right know I don't have board and later I will have only a little time to finish project I would like to ask
newbie quastions.

1. I will power my board from 12VDC - I am assuming that I should connect it to VIN port and ground to Arduino ground

2. I will have 20 Digital Inputs and 20 Digital Outputs.
My inputs will be controlling by switches which will give 5VDC or 0VDC to inputs

I have read http://www.ladyada.net/learn/arduino/lesson5.html tutorial and was wondering
if I will need 10 Kohm (pull-up resistors) and 100 ohm resistors for all inputs separetely or I could connect all inputs to two resistors only?

on the other hand in article

"Read Two Switches With One I/O Pin" there is:
"There are handy 20K pullup resistors (resistors connected internally between Arduino I/O pins and VCC - +5 volts in the
Arduino's case) built into the Atmega chip upon which Freeduino's are based. They are accessible from software by using the
digitalWrite() function, when the pin is set to an input."

which confused me a little as it means that accually I don't need any pullup resistors or I am wrong?
Do I really need those 100 ohm resistors as I know which my pins for sure will be inputs?

3. I am assuming that when I connect Arduino output directly to 5VDC relay it is possible to control it or maybe I will need transistor before? 

Thanks for patience and tips!
Logged

Bristol, UK
Offline Offline
Edison Member
*
Karma: 1
Posts: 1197
Exhibitor at UK Maker Faire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. I will power my board from 12VDC - I am assuming that I should connect it to VIN port and ground to Arduino ground

Yes, that's correct, 12V to VIN and Ground.

2. I will have 20 Digital Inputs and 20 Digital Outputs.
My inputs will be controlling by switches which will give 5VDC or 0VDC to inputs

Will the switches actually supply 5V, or will they be just a switch that connects the two wires?

I have read http://www.ladyada.net/learn/arduino/lesson5.html tutorial and was wondering
if I will need 10 Kohm (pull-up resistors) and 100 ohm resistors for all inputs separetely or I could connect all inputs to two resistors only?

Separately. One pull-up per switch/pin.

"Read Two Switches With One I/O Pin" there is:
"There are handy 20K pullup resistors (resistors connected internally between Arduino I/O pins and VCC - +5 volts in the
Arduino's case) built into the Atmega chip upon which Freeduino's are based. They are accessible from software by using the
digitalWrite() function, when the pin is set to an input."

which confused me a little as it means that accually I don't need any pullup resistors or I am wrong?

If you have simple on/off switches, then yes, you'll need pull-up (or pull-down) resistors.  One resistor per switch. If you don't want to use an external resistor, then you can use the internal pull-up resistors using the 'digitalWrite' method that you refer to.

Do I really need those 100 ohm resistors as I know which my pins for sure will be inputs?

The 100 Ohm resistors are to give some additional protection to the Arduino. Optional, but a good idea.

3. I am assuming that when I connect Arduino output directly to 5VDC relay it is possible to control it or maybe I will need transistor before? 

It depends on how much current the relay coil will draw. Up to 40mA, you don't strictly need a transistor. More thatn 40mA, then you will definitely need a transistor. It's a good idea to use one anyway, even if the current is lower that 40mA. Always use a diode across the relay coil -- if you don't, the back-EMF high voltage spikes will destroy your circuit.

http://www.flickr.com/photos/anachrocomputer/3242387876/
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Up to 40mA, you don't strictly need a transistor.

Be careful about this since the 40 mA value is an 'absolute maximum rating'.  If you look at the datasheet you will see that it says: "Exposure to absolute maximum rating conditions for extended periods may affect device reliability."

Don
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote from: mrozny on Today at 04:56:26 AM
1. I will power my board from 12VDC - I am assuming that I should connect it to VIN port and ground to Arduino ground


Yes, that's correct, 12V to VIN and Ground.

You can also supply power using the barrel-jack, then you also get the protection of the reverse polarity diode.
If the 12V is not being used elsewhere, you could go with a 7.5V wallwart such as dipmicro.com carries, and you will not be wasting so much energy heating up the regulator.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do I really need those 100 ohm resistors as I know which my pins for sure will be inputs?
I would say no, but then I would never connect an input directly to +5V. Connecting a pin to +5V and making it an output with a logic zero on it is a sure way of blowing up a pin. Much more dangerous than (the still dangerous) connecting it to ground and outputting a logic high.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank You for so much help!

Quote
Quote from: mrozny on August 12, 2011, 09:56:26 AM
2. I will have 20 Digital Inputs and 20 Digital Outputs.
My inputs will be controlling by switches which will give 5VDC or 0VDC to inputs

Will the switches actually supply 5V, or will they be just a switch that connects the two wires?

Switches will be connected to 24V and they will give signal to relay which will active 5VDC or 0VDC to input.
I am planning to use http://www.sparkfun.com/products/9346
I hope I will have enough space to connect everything there..
So lets say that I would like to resign from pull-up resistors and 100 ohm resistors.
I have this code:


const int switch1 = 2;   
const int switch2 = 3;   
const int light1 = 4;   
const int light2 = 5;   

void setup() {

pinMode(switch1, INPUT); 
pinMode(switch2, INPUT);
pinMode(light1, OUTPUT);
pinMode(light2, OUTPUT);
}

void loop() {

if (digitalRead(switch1) == HIGH & digitalRead(switch2) == HIGH) { 
   digitalWrite(light1, HIGH);
   digitalWrite(light2, HIGH);   
}   
}   


And I am planning to change it for that one where I am using internal pull-up resistors:


const int switch1 = 2;   
const int switch2 = 3;   
const int light1 = 4;   
const int light2 = 5; 

int state1 ;
int state2;

void setup() {

pinMode(switch1, INPUT); 
pinMode(switch2, INPUT);
pinMode(light1, OUTPUT);
pinMode(light2, OUTPUT);
}

void loop() {
   
digitalWrite(light1, LOW);
state1 = digitalRead(switch1);

digitalWrite(switch2, LOW);
state2 = digitalRead(switch2);

if (state1 == 1 & state2 == 1) {
   digitalWrite(light1, HIGH);
   digitalWrite(light2, HIGH);   
}
}


Is that ok? As I doubt of it but I have no idea how to do it different..


Quote
Quote from: mrozny on August 12, 2011, 09:56:26 AM
3. I am assuming that when I connect Arduino output directly to 5VDC relay it is possible to control it or maybe I will need transistor before?

It depends on how much current the relay coil will draw. Up to 40mA, you don't strictly need a transistor. More thatn 40mA, then you will definitely need a transistor. It's a good idea to use one anyway, even if the current is lower that 40mA. Always use a diode across the relay coil -- if you don't, the back-EMF high voltage spikes will destroy your circuit.

http://www.flickr.com/photos/anachrocomputer/3242387876/

Thank You for this advice. Now I am planning to use A 1N914 Signal Diode to protect against "Back emf". Is that diode
ok? The picture in link is not loading. I am assuming that for each output I am connecting this diode between relay and output. Each output has got its own diode..

Let's say that I would like to use transistor - is that mean that for each output I need one transistor?
Which I should use then and how to connected it with my diode, relay, and output..

Quote
Quote
Quote from: mrozny on Today at 04:56:26 AM
1. I will power my board from 12VDC - I am assuming that I should connect it to VIN port and ground to Arduino ground


Yes, that's correct, 12V to VIN and Ground.

You can also supply power using the barrel-jack, then you also get the protection of the reverse polarity diode.
If the 12V is not being used elsewhere, you could go with a 7.5V wallwart such as dipmicro.com carries, and you will not be wasting so much energy heating up the regulator.

I am planning to supply my board with 12VDC or 24VDC which will go through first switch than diode 1N4001 and LM7812 with capacitors
and from that to my board. I am planning also to use fan which eliminate heat from LM7812.
Sounds ok?
Logged

Bristol, UK
Offline Offline
Edison Member
*
Karma: 1
Posts: 1197
Exhibitor at UK Maker Faire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank You for this advice. Now I am planning to use A 1N914 Signal Diode to protect against "Back emf". Is that diode
ok?
No, the 1N914 signal diode is only rated for 150mA, which is not enough. Use a 1A rated (or higher) diode such as 1N4001, 1N4002 or similar.

The picture in link is not loading. I am assuming that for each output I am connecting this diode between relay and output. Each output has got its own diode..

Yes, one diode per transisor/relay, that's correct.

Let's say that I would like to use transistor - is that mean that for each output I need one transistor?

Yes, one transistor per relay, that's correct.

Which I should use then and how to connected it with my diode, relay, and output..

Use an NPN transistor with 100mA or greater current capacity. For instance 2N2222, BC108, BC547 or similar.
Logged

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12700
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are driving lots of relays there are neat chips that have 7 or 8 transistors (or Darlington pairs) and the reverse diodes already on them, I think ULN2803 is one such that is often used.  Checkout the datasheet (google "uln2803 datasheet pdf")
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12700
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank You for this advice. Now I am planning to use A 1N914 Signal Diode to protect against "Back emf". Is that diode
ok?
No, the 1N914 signal diode is only rated for 150mA, which is not enough. Use a 1A rated (or higher) diode such as 1N4001, 1N4002 or similar.

Which I should use then and how to connected it with my diode, relay, and output..

Use an NPN transistor with 100mA or greater current capacity. For instance 2N2222, BC108, BC547 or similar.


Hey?  If a 100mA transistor is enough to drive the relay, then a 150mA diode will be enough to protect it!  When the transistor turns off the current in the relay will transfer to the diode, so the diode only has to be rated to handle the relay coil's current.

In fact since the 1N914 is an ultra fast diode is it to be preferred over a sluggish rectifier diode like the 1N4001.
Logged

[ I won't respond to messages, use the forum please ]

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hey?  If a 100mA transistor is enough to drive the relay, then a 150mA diode will be enough to protect it!  When the transistor turns off the current in the relay will transfer to the diode, so the diode only has to be rated to handle the relay coil's current.

In fact since the 1N914 is an ultra fast diode is it to be preferred over a sluggish rectifier diode like the 1N4001.

I've never seen a switching diode recommended for this application and I wouldn't use one.

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are driving lots of relays there are neat chips that have 7 or 8 transistors (or Darlington pairs) and the reverse diodes already on them, I think ULN2803 is one such that is often used.  Checkout the datasheet (google "uln2803 datasheet pdf")

Hey
I checked it and it sounds interesting. I've read datasheet but as I am not as good in it I would like to be sure..
unl2803a
http://www.datasheetcatalog.org/datasheet/allegromicrosystems/2801.pdf

1. There is output voltage 50V. It means that I can connect my output from arduino via this chip and control 24Vdc relay?


And two questions apart from that:
2. I am assuming that using 5Vdc PCB relays(http://za.rs-online.com/web/p/electromechanical-relays/7196335/) to control lights (230VAC) is more reliable than using uln2803 to control standard 24Vdc relays installed on rail which controls lights (230VAC).

In solution with 5Vdc PCB relays I need to put diode and maybe transistor before connecting output from arduino 

3. How to check what is the minimum current I need to control 5Vdc pcb relay? Is there any parameter?
Let's say it's 20mA. It would means that I don't need transistor as output from my arduino is 40mA..

Thank You for any little tip or help!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Yes, ULN2003/2803 han sink current from  24V source to control a 24V relay.

2. Either one would work - if you can get away with just using 5V, do that.

3.  That relay has
Coil Resistance 118 Ω,
so with a 5v supply, 42mA will  flow (5V/118ohm = 0.042A).
So you should use an NPN transistor to drive it, or a part like ULN2003/2803.

Looks like a good relay to drive 230VAC.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: