Skip to content
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

ADS1X15 Continuous Mode AND differential (0_1) & (2_3) #29

Closed
NovaJeff opened this issue Oct 6, 2021 · 16 comments
Closed

ADS1X15 Continuous Mode AND differential (0_1) & (2_3) #29

NovaJeff opened this issue Oct 6, 2021 · 16 comments
Assignees
Labels
question Further information is requested

Comments

@NovaJeff
Copy link

NovaJeff commented Oct 6, 2021

Hi Rob, thanks for your libraries, I've been using many of them for years.

Is there a way to get both differential values (0_1 AND 2_3) on continuous mode?

I've been able to get.Value() on either, depending on the trigger read in setup(), but for the life of me I can't find a way to do it on both channels simultaneously...

Is there something obvious I'm missing?

Thank you Rob.

@RobTillaart
Copy link
Owner

It is rather late now (here) and I need to do some reading about the details to see if it is possible. can take a few days.

@RobTillaart RobTillaart self-assigned this Oct 7, 2021
@RobTillaart RobTillaart added the question Further information is requested label Oct 7, 2021
@RobTillaart
Copy link
Owner

RobTillaart commented Oct 7, 2021

A quick look did not reveal a solution, could code below be an option for you?

uint8_t pair = 01;

void setup()
{
  // setup stuff here incl. continuous mode gain etc.
  pair = 01;
  ADS.requestADC_Differential_0_1();
}

void loop()
{
  if (ADS.isReady())
  {
    if (pair == 01)
    {
      val_01 = ADS.getValue();
      pair = 23;
      ADS.requestADC_Differential_2_3();
    }
    else if (pair == 23)
    {
      val_23 = ADS.getValue();
      pair = 01;
      ADS.requestADC_Differential_0_1();
    }
  }
  // do other things here
}

code is a not working snippet, just to get the idea

@RobTillaart
Copy link
Owner

A second option is to read the 4 channels in continuous mode - see examples - and do the math yourself.

@RobTillaart
Copy link
Owner

@NovaJeff
FYI, I created a develop branch as I saw I need to fix the build-CI and some small readme updates.
Also added an example for continuous -differential reading. Could you test that for me?
It is not a PR yet

See - https://github.com/RobTillaart/ADS1X15/tree/develop

@NovaJeff
Copy link
Author

NovaJeff commented Oct 7, 2021

Hello Rob, that was quick!
Unfortunately, for a reason I don't get yet, the handle_conversion() function never returns true.
To make sure I used a Serial.print debug line right after if (ADS.isReady()) and the line never printed.
I also tried if (!ADS.isBusy) with same outcome, as I expected...
Strange because I really think this approach is clever.
Tried this thru both your develop branch and the code snippet.

@NovaJeff
Copy link
Author

NovaJeff commented Oct 7, 2021

Rob I just tried with ADS.setMode(1) in setup() and now handle_conversion() returns true.

@RobTillaart
Copy link
Owner

RobTillaart commented Oct 7, 2021

Thanks for testing and fixing.
Although it is not continuous mode, does this method solve your project need?

(I will change the example name and code so it is a working one - ADS_async_differential.ino

@RobTillaart
Copy link
Owner

Example adjusted and renamed.

@NovaJeff
Copy link
Author

NovaJeff commented Oct 7, 2021

It works great for my project since it's non-blocking and more than fast enough. I really appreciate your swift replies and solutions.

@RobTillaart
Copy link
Owner

Thanx, good to hear it solves the issue. I will investigate if I can get continuous differential working, if so I'll let you know.

Until that investigation is done I keep this issue open as a reminder for me.

@RobTillaart
Copy link
Owner

insight.
In continuous mode the flag that indicates that the ADC is NOT_BUSY is always false.
This results in the isBusy() is always true and isReady() always false.

So to get a real continuous mode version I need to add the RDY (interrupt) pin. (so far theory / hypothesis :)

@RobTillaart
Copy link
Owner

RobTillaart commented Oct 7, 2021

  • Found the hardware needed to setup a test.
  • rewrite code for continuous differential with RDY / interrupt
  • test
  • release

@NovaJeff
Copy link
Author

NovaJeff commented Oct 7, 2021

"In continuous mode the flag that indicates that the ADC is NOT_BUSY is always false."

This explains that then... I'm sure the workaround with RDY / interrupt will be a success.

Thx Rob!

@RobTillaart
Copy link
Owner

Works!
Example code is in the develop branch, and I'll review changes tomorrow to see if it still makes sense :)

Anyway it will be a PR for release 0.3.2

@NovaJeff
Copy link
Author

NovaJeff commented Oct 7, 2021

Awesome Rob! Thanks for your time on all these nice libraries.

@RobTillaart
Copy link
Owner

0.3.2 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants