humberto-garza / SparkFunEdisonADC

SparkFun Block for Intel® Edison - ADC Arduino and C Libraries
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Two inputs #3

Open AlexGHancock opened 8 years ago

AlexGHancock commented 8 years ago

Very helpful contribution - thank you!

I'm obviously doing something dumb but I'm trying to read Ain1 and Ain3 by creating two Adc objects (same bus and address) and then setting the input multiplexer to 0b101 and 0b111 respectively. However this results in the values from the two channels swapping around randomly.

What am I missing?

Thanks

Alex

humberto-garza commented 8 years ago

Hi! Maybe could you share your code? I could be more useful then :P

regards!

AlexGHancock commented 8 years ago

Hi Jose

I’ve actually switched to using the sample code on Sparkfun’s site (which works well) and so removed the code using your library.

However, all I did was to declare two instances

Adc ain1(1, 0x48);

Adc ain3(1, 0x48);

Then called set_config_command for each one with the input_multiplexer set to 0b101 for ain1 and 0b111 for ain3 (obviously using inputs 1 and 3).

Then I called adc_read for ain1 and ain3.

ain1 should have been about 60 with ain3 about 1600 but the results weresomething like this –

ain1        ain3

60           1600

60           60

60           60

1600       60

60           1600

etc – more random than this but you should get the idea.

If I commented out the code for one channel the other worked as expected, they just wouldn’t work together.

Regards

Alex

From: Jose Humberto Garza Rosado notifications@github.com Reply-To: humberto-garza/SparkFunEdisonADC reply@reply.github.com Date: Friday, 17 June 2016 at 15:08 To: humberto-garza/SparkFunEdisonADC SparkFunEdisonADC@noreply.github.com Cc: Alex Hancock alex@daboom.com, Author author@noreply.github.com Subject: Re: [humberto-garza/SparkFunEdisonADC] Two inputs (#3)

Hi! Maybe could you share your code? I could be more useful then :P

regards!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.