Pages: [1]   Go Down
Author Topic: Internal Analog Reference - 1.1v & 5v in the same program  (Read 1039 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Morning,

I've got a program that is using the internal 1.1v reference to increase the read resolution of an LM35 temperature sensor output using analogReference(INTERNAL);

However, is there a way for me to set analogReference to 1.1v on specific analog pins, and 5v on other pins?
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No.  It's one or the other.

You can, of course, switch between them at will though.  Add a slight delay to allow the references to settle between each change.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I feared that would be the problem.... the dreaded delay.

Cheers anyhow!
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The other option is to use an external ADC.  Then you can have 2 voltage references - the one for the internal ADC, and a different one for the external ADC.

I am working on an ADC shield at the moment: http://hacking.majenko.co.uk/node/58 and in my testing of it I use the internal ADC of the Arduino to monitor the Vref of the external ADC.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I feared that would be the problem.... the dreaded delay.
It is not necessary to delay(). Simply discard the first reading after switching reference voltages.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It is not necessary to delay(). Simply discard the first reading after switching reference voltages.
Which basically creates a delay smiley-wink
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Which basically creates a delay
Yes, but it is a delayMicroseconds (110) (approx), which is only a tenth of a "delay(anything)" ;-)
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I feared that would be the problem.... the dreaded delay.
It is not necessary to delay(). Simply discard the first reading after switching reference voltages.

Simply discard the reading? Sorry?

What I meant, was to be able to simultaneously read the input from an LM35, whilst reading other 0 - 5v sensors - in addition to running numerous other I/Os. A delay of any sort is a delay is it not?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Simply discard the reading? Sorry?
Code:
(void) analogRead (myPin);
myReading = analogRead (myPin);
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What I meant, was to be able to simultaneously read the input from an LM35, whilst reading other 0 - 5v sensors - in addition to running numerous other I/Os. A delay of any sort is a delay is it not?

You can't simultaneously read more than one analog input anyway.  There is only one ADC.  The pins go into a MUX, which sits in front of the lone ADC.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Pages: [1]   Go Up
Jump to: