Skip to content

Due analog read #1740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
donelsonas opened this issue Dec 16, 2013 · 13 comments
Closed

Due analog read #1740

donelsonas opened this issue Dec 16, 2013 · 13 comments
Assignees
Labels
Board: Arduino Due Applies only to the Due Component: Core Related to the code for the standard Arduino API
Milestone

Comments

@donelsonas
Copy link

I'm trying to read multiple analog sensors with the Due board. Reading one sensor works fine, but when I try to read two or more, the device returns garbage. This same code works fine on the Uno. I found a web posting about this issue and it has a work around that doesn't seem to work anymore.

Also, analogReference() does not compile with the due.

Here's my code:

int a, b, c, d;

void setup()
{
  Serial.begin(9600);
  Serial.println("Program is Starting");
}

void loop()
{
  a=analogRead(0);
  delay(50);
  a=analogRead(0);

  b=analogRead(1);
  delay(50);
  b=analogRead(1);

  c=analogRead(2);
  delay(50);
  c=analogRead(2);

  d=analogRead(3);
  delay(50);
  d=analogRead(3);  

  Serial.print("Port 0 ");
  Serial.println(a);
  Serial.print("Port 1 ");
  Serial.println(b);
  Serial.print("Port 2 ");
  Serial.println(c);
  Serial.print("Port 3 ");
  Serial.println(d);
  delay(1000);
}
@cmaglie
Copy link
Member

cmaglie commented Dec 16, 2013

I confirm that, this is probably a regression due to the latest patch here:

#1634

May you check with IDE 1.5.4?

C

@cmaglie
Copy link
Member

cmaglie commented Dec 16, 2013

Argh, I've probably screwed up with git, I've committed the fix on my local copy but didn't pushed it on github, and when I've merged the pull request the fix didn't pass through :-(

May I ask you to do another thest with the IDE 1.5.5, and try to replace:

Arduino/hardware/arduino/sam/cores/arduino/wiring_analog.c

with the file here:

https://raw.github.com/arduino/Arduino/a1c48091051bfc7f3366cac6fc23212c4e4fb4a3/hardware/arduino/sam/cores/arduino/wiring_analog.c

and retry?

@cmaglie
Copy link
Member

cmaglie commented Dec 18, 2013

I changed the implementation again, the following should work in every situation:

https://raw.github.com/arduino/Arduino/b530742603439c87a06d2da9ddd60dd9f82f5082/hardware/arduino/sam/cores/arduino/wiring_analog.c

thanks to Mark for the suggestion:

http://forum.arduino.cc/index.php?topic=203322.msg1509907#msg1509907
C

@donelsonas
Copy link
Author

Cool, I haven't had a chance to try any of this out yet. I'll let you know
once I do, thanks for the help.

Don

On Wed, Dec 18, 2013 at 8:52 AM, Cristian Maglie
notifications@github.comwrote:

I changed the implementation again, the following should work in every
situation:

https://raw.github.com/arduino/Arduino/b530742603439c87a06d2da9ddd60dd9f82f5082/hardware/arduino/sam/cores/arduino/wiring_analog.c

thanks to Mark for the suggestion:

http://forum.arduino.cc/index.php?topic=203322.msg1509907#msg1509907
C


Reply to this email directly or view it on GitHubhttps://github.com//issues/1740#issuecomment-30847186
.

@donelsonas
Copy link
Author

Cristian, the only thing that worked for me was reverting to 1.5.4.
Neither of the new versions of wiring_analog.c worked with 1.5.5. I still
saw similar incorrect behavior from the ADC when switching between
different channels.

Don

On Wed, Dec 18, 2013 at 10:50 AM, Don Shannon donelson.shannon@gmail.comwrote:

Cool, I haven't had a chance to try any of this out yet. I'll let you
know once I do, thanks for the help.

Don

On Wed, Dec 18, 2013 at 8:52 AM, Cristian Maglie <notifications@github.com

wrote:

I changed the implementation again, the following should work in every
situation:

https://raw.github.com/arduino/Arduino/b530742603439c87a06d2da9ddd60dd9f82f5082/hardware/arduino/sam/cores/arduino/wiring_analog.c

thanks to Mark for the suggestion:

http://forum.arduino.cc/index.php?topic=203322.msg1509907#msg1509907
C


Reply to this email directly or view it on GitHubhttps://github.com//issues/1740#issuecomment-30847186
.

@ghost ghost assigned cmaglie Dec 19, 2013
@cmaglie
Copy link
Member

cmaglie commented Dec 20, 2013

@donelsonas
I've just tried the example you posted and I get consistent results from analog inputs. Also MarkT confirmed that the patch is working, may I ask you to check your files again? or maybe downloading the nightly build (that should contain the patch now) is the simplest method:

http://arduino.cc/en/Main/Software
(look for the "Nightly build" section)

C

@blueminerals
Copy link

        // Disable the corresponding channel
        //adc_disable_channel(ADC, ulChannel);

Line 168 was commented out in wiringanalog.c

@cmaglie
Copy link
Member

cmaglie commented Jan 15, 2014

@blueminerals
the line was moved in the channel selection logic:
https://github.com/arduino/Arduino/blob/ide-1.5.x/hardware/arduino/sam/cores/arduino/wiring_analog.c#L151

this change is scheduled for release in 1.5.6, and its already available in the nightly build for testing.

http://arduino.cc/en/Main/Software (look on the "Nightly build" section of the download page)

Any testing feedback is really welcome.

@blueminerals
Copy link

It looks like something else is broken. This compiled in 1.5.5.

Arduino: nightly (Windows 7), Board: "Arduino Due (Programming Port)"

In file included from sketch_ac_ino.ino:6:

C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:26: error: expected ')' before numeric constant

C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:26: error: expected ')' before numeric constant

C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:26: error: expected ';' before numeric constant

sketch_ac_ino:44: error: no matching function for call to 'Adafruit_MAX31855::Adafruit_MAX31855(int, int, int)'

C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:24: note: candidates are: Adafruit_MAX31855::Adafruit_MAX31855()

C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:24: note: Adafruit_MAX31855::Adafruit_MAX31855(const Adafruit_MAX31855&)

From: Cristian Maglie [mailto:notifications@github.com]
Sent: Wednesday, January 15, 2014 5:22 AM
To: arduino/Arduino
Cc: blueminerals
Subject: Re: [Arduino] Due analog read (#1740)

@blueminerals https://github.com/blueminerals
the line was moved in the channel selection logic:
https://github.com/arduino/Arduino/blob/ide-1.5.x/hardware/arduino/sam/cores/arduino/wiring_analog.c#L151

this change is scheduled for release in 1.5.6, and its already available in the nightly build for testing.

http://arduino.cc/en/Main/Software (look on the "Nightly build" section of the download page)

Any testing feedback is really welcome.


Reply to this email directly or view it on GitHub #1740 (comment) . https://github.com/notifications/beacon/6001430__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTMxNDEzMiwiZGF0YSI6eyJpZCI6MjIxMDUyODh9fQ==--10ad86d2220c8279be903b2d966d48a5fe5f4fb4.gif

@cmaglie
Copy link
Member

cmaglie commented Jan 21, 2014

@blueminerals,

your last error seems unrelated to analogRead(), but to MAX31855 library:

sketch_ac_ino:44: error: no matching function for call to 'Adafruit_MAX31855::Adafruit_MAX31855(int, int, int)'
C:\Users\JSweda\Documents\Arduino\libraries\Adafruit_MAX31855/Adafruit_MAX31855.h:24: 
   note: candidates are: Adafruit_MAX31855::Adafruit_MAX31855() 
   note: Adafruit_MAX31855::Adafruit_MAX31855(const Adafruit_MAX31855&)

more precisely I think that has something to do with: #758
Please follow up there for this particular issue.

@cmaglie
Copy link
Member

cmaglie commented Feb 21, 2014

@blueminerals may you retry with IDE 1.5.6?

@cmaglie
Copy link
Member

cmaglie commented Jul 2, 2014

Closing this one, feel free to reopen if if the problem persists.

@cmaglie cmaglie closed this as completed Jul 2, 2014
@blueminerals
Copy link

I have listed this issue on github and other places and have gotten no response. In the 1.5.x arduino ide, the javaw.exe uses 50 % of the cpu bandwidth. Can you help me or refer me to someone else who can tell me why this is happening? This happens in linux and the pc, perhaps not on the mac.

From: Cristian Maglie [mailto:notifications@github.com]
Sent: Friday, February 21, 2014 9:54 AM
To: arduino/Arduino
Cc: blueminerals
Subject: Re: [Arduino] Due analog read (#1740)

@blueminerals https://github.com/blueminerals may you retry with IDE 1.5.6?


Reply to this email directly or view it on GitHub #1740 (comment) .Image removed by sender.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Board: Arduino Due Applies only to the Due Component: Core Related to the code for the standard Arduino API
Projects
None yet
Development

No branches or pull requests

4 participants