Loading...
Pages: [1]   Go Down
Author Topic: Internal Analog Reference - 1.1v & 5v in the same program  (Read 371 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 313
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
Edison Member
*
Karma: 44
Posts: 2225
What a host of balls she had seen: gaity, the brass buttons...
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


UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 313
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cheers anyhow!
Logged

UK
Offline Offline
Edison Member
*
Karma: 44
Posts: 2225
What a host of balls she had seen: gaity, the brass buttons...
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


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 315
Posts: 35519
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
Edison Member
*
Karma: 44
Posts: 2225
What a host of balls she had seen: gaity, the brass buttons...
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


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 138
Posts: 19067
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.

UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 313
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: 138
Posts: 19067
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.

Austin, TX
Offline Offline
Faraday Member
**
Karma: 41
Posts: 5170
CMiYC
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

www.cmiyc.com - A guide to being an Enginerd

Pages: [1]   Go Up
Print
 
Jump to: