Page 1 of 1
Internal Pull resistors for Arduino
Posted: Tue Sep 11, 2012 12:16 pm
by trisbillers
Hi, Guys,
I have been told I can enable the Pull up resistors on the Arduino Mega by using c-Code.
does any one have a example of this I could use.
Thanks
Tristan
Re: Internal Pull resistors for Arduino
Posted: Tue Sep 11, 2012 12:28 pm
by Benj
Hello Tristan,
Right to enable the pull up resistor on an input pin you simply write a 1 to the appropriate bit in the port register.
eg a pull up on pin A0
DDRA = 0x00; //Convert PortA to Input
PORTA = 0x01; //Enable pullup on A0, Disable pullup on A1-A7
var = PINA; //Read the data on Port A
You can use the Flowcode input icon to convert the pin to an input, the pins should default to input mode on startup.
Re: Internal Pull resistors for Arduino
Posted: Tue Sep 11, 2012 1:15 pm
by trisbillers
Thanks Ben.
I will give this a go.
Tristan
Re: Internal Pull resistors for Arduino
Posted: Wed Sep 12, 2012 11:39 am
by jgu1
Hi Ben!
Maybe a stupid question, is this also possible in FC without using C, and if, what happend if I pull the input down (on hardware) Will it then be active low ,inverted.
Best regard
Jorgen
Re: Internal Pull resistors for Arduino
Posted: Wed Sep 12, 2012 11:52 am
by Enamul
Hi Jorgen,
Ben has suggested pull-up option which requires adding code in C code..But just two lines of code will be enough for this. As soft pull-up enables weak pull up in the PIC input, so if you pull down by 10K resistor for example; I think the pin will be still pull-up...
Re: Internal Pull resistors for Arduino
Posted: Wed Sep 12, 2012 1:43 pm
by Benj
Hello,
It looks like the pull up resistors on AVRs are between 20 and 50K.
Therefore at 5V the input pin will see the following.
Worst Case - (5 / (20 + 10)) * 10 = 1.66V
Best Case - (5 / (50 + 10)) * 10 = 0.83V
The input low voltage is specified as between -0.5V and 0.3 * Vcc. at 5V this is 1.5V so 10K might be a bit too high. Maybe try 4.7K instead?
Worst Case - (5 / (20 + 4.7)) * 4.7 = 0.95V
Best Case - (5 / (50 + 4.7)) * 4.7 = 0.43V
Re: Internal Pull resistors for Arduino
Posted: Wed Sep 12, 2012 1:53 pm
by Enamul
Hi Ben,
Do you know what is the internal pull-up resistor value for PIC ics? I didn't find that from datasheet..may be my eyes skipped that.
Edit:A strong pullup means using small value resistor for pull up whereas a weak pullup means using high value resistor for pulling the signal to Vcc.
I got it now..
There's no direct spec for the resistance value. You can, though, calculate the effective resistance from the "Ipu" parameter.
For example, in the 18F USB chips, the port B pullup current is listed at 50 to 400 microamps. (This is with a Vdd value of 5 volts and the input pin grounded.) The current range corresponds to a resistance range of 12.5 to 100 Kohms.
Some datasheets list a 'typical' value of 250 microamps which corresponds to a 20 Kohm resistance.
Re: Internal Pull resistors for Arduino
Posted: Wed Sep 12, 2012 5:37 pm
by jgu1
Hello both of you!
Again, many thanks for your help and explanation. I understand that although it is possible to make an input high internally, so it will still be high impedance.
I will continue as I have always done, either to mount a pull down or pullup resistor on the unused inputs or in the program define them as outputs.
I'm trying to learn as much as possible and is therefore very curious.
Thank“s
Best regard
Jorgen