View previous topic :: View next topic |
Author |
Message |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
How I use the input with pull up/down internal resistor? |
Posted: Sat Jul 02, 2011 4:08 am |
|
|
How to build an application using the input with the pull up/down internal resistor from the microcontroller or microchip.
Can I use that and analog inputs? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Sat Jul 02, 2011 5:00 am |
|
|
'Resistors' are generally pull-up only, not pull up/down.
They are actually programmable current sources, rather than resistors, so for an analog application might give rather different results than a resistor. Also currents involved vary significantly from pin to pin. The data sheets are generally very unclear whether these can be enabled on a pin configured as analog. But does in most cases say these are for digital inputs only. A search finds the 16F688, with a block diagram for the pin logic, (Figure 4-1), which clearly shows that the pull up is _disabled_ when the port is set to analog, for either comparator, or ADC.
So I'd say you cannot use the pull-ups with pins set for analog.
Remember also the impedance requirements for analog inputs. The leakage current on an input pin would be over 1/10th the available current on these weak pull-ups, so any form of accuracy would be lost....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sat Jul 02, 2011 9:36 am |
|
|
Thanks Ttelmah
So no each controller has a system pull up resistance.
I worked with PIC12F509 and pull up resistor is activated automatically if you read input pin B0, B1, B3, B4 for B2, B5 don't have.
If the algorithm operates with pull up separately for 16F688 do you know an example?
For Atmel have pull up resistor and of course pull down.
Atmega16 is a example. |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Jul 02, 2011 3:12 pm |
|
|
You really have to read the data sheet for the chip you are using. There are digital inputs, analog inputs, and Schmitt trigger inputs. Common outputs are digital, PWM, and open collector or open drain, and any output may or may not have a pull up resistor or current source as well.
The are far too many types to cover them all in a BBS posting.
Read your data sheet and get back with specific questions about specific chips. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sun Jul 03, 2011 2:47 am |
|
|
Be sure I read datasheet.
But if you know all ATMEGA controllers have internal pull up/down system.
Of course the current is about 10-20uA for some devices.
Look for this example:
Code: |
DDRA = 0x00; //make port a as input
PORTA = 0xFF; //enable all pull-ups
//or next line
PORTA = 0x00; //enable all pull-down
y = PINA; //read data from port a pins
|
This example work with all Atmega.
Someone have a example to work with internal pull up/down digital input? Microchip
Thanks in advance. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Sun Jul 03, 2011 3:52 am |
|
|
Seriously, _what chip_.
You need to read the data sheet for the specific chip.
The point is that the PIC's _DO NOT_ have universal resistors. Most smaller/older ones only offer them on 'port_b' (port_b_pullups(TRUE); is the command to enable these). Latter chips with them still on port B, often allow then to be individually enabled (port_b_pullups(0b11110000); - turn them of for the high four bits). Some of the latter chips have them on other ports as well, and on these you get 'port_x_pullups', where x is the port name.
Then a _very few_ chips do have pull down resistors as well. On these you have:
port_x_pullups(upmask,downmask);
and here you could have:
port_a_pullups(0b11110000.0b00001111);
to enable pull 'down' on the low four pins, and pullup on the high four pins.
You need to talk about your specific chip. There are currently about 10* as many PIC based 'models' as there are Atmel, and the range of features is much larger, with the smaller chips in particular being much more 'cut down'.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sun Jul 03, 2011 4:42 am |
|
|
PORTA = 0xFF; //enable all pull-ups
//or next line
PORTA = 0x00; //enable all pull-down
On a PIC with the CCS compiler this would not enable pull-up and pull-down RESISTORS, but it would use the pull-up and pull-down TRANSISTORS of the logic output stage. Make sure you know the difference.
Pull-up resistors (or current sources) are meant for "wired OR" situations where multiple devices may pull a line low, and the pull-up brings the line high when none of the other devices are active. Pull-ups can also be used to set the state of an unconnected pin.
If you use a pull-up transistor (the usual logic output set to "1") in a wired OR situation with another device pulling the line low you get a bad situation called "bus contention" which causes high current to flow, and if you do it for a whole byte the heat generated may even perminately damage the processor port. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sun Jul 03, 2011 8:40 am |
|
|
yes Ttelmah
Code: | port_X_pullups (value) |
This example I need.
Thanks.
for SherpaDoug
I know that function work with AVR.
I don't tested on Microchip.
Thanks
This example I need for my application. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Sun Jul 03, 2011 9:37 am |
|
|
Yes.
To SherpaDoug, this is a big difference with the Atmel chips. On a port set (via their equivalent of TRIS), as an _input_, the direction the pull-up/down's operate, is controlled by the contents of the output latch.
This has it's advantages, but also disadvantages. Obviously it does mean that every port can offer pull-up/pull-down, without needing separate registers, but you can't do the equivalent to the PIC on things like I2C, setting the TRIS as an input, and the driver to 'pull down', and then giving effectively 'open collector' drive, without having the pull-down resistor present, if you are using this on any other bit. It is a very different approach.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Sun Jul 03, 2011 11:44 am |
|
|
Ttelmah wrote: | Yes.
To SherpaDoug, this is a big difference with the Atmel chips. On a port set (via their equivalent of TRIS), as an _input_, the direction the pull-up/down's operate, is controlled by the contents of the output latch.
|
If I may just clarify a little for Ttelmah,
PIC's have pullups (I've never seen pull-downs at all, but that doesn't mean it could change with newer devices -- so READ the Datasheet).
I'm currently working with a Samsung ARM core chip and it's GPIO's do have a configurable pullup/pulldown resistor system.
I think I've also seen configurable pullup/pulldowns on a Xilinx FPGA somewhere -- but to be specific, I'd have to go look it up again. I want to say Spartan3, but I could be incorrect.
Regardless, ALWAYS refer to the datasheet!!
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Sun Jul 03, 2011 3:52 pm |
|
|
Some of the new 24E/33E chips have programmable weak pull-downs.
On older chips the only pins with this feature (that I know of), are the USB pins, where it is automatically enabled.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|