Giter VIP home page Giter VIP logo

Comments (7)

wollewald avatar wollewald commented on May 27, 2024 1

@rin67630 I have modified the library a bit and now you can call setVoltageRange_mV and immediately request voltages. The necessary delays are added in the background. The delays are adjusted to the conversion rate.

from ads1115_we.

wollewald avatar wollewald commented on May 27, 2024

Yes correct, there is no register for this to store the information. So you would have to work with an case/switch or if, like:

if(channel == ADS1115_COMP_0_1){setVoltageRange_mV(range)}

Another option is use setAutoRange(); when you change the channel.

Or you modify the general function to read the channels in the example sketch:

float readChannel(ADS1115_MUX channel) {
  float voltage = 0.0;
  adc.setCompareChannels(channel);
  voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
  return voltage;
}

to individual channels:

float readChannel_1() {
  float voltage = 0.0;
  adc.setCompareChannels(channel_1);
  setVoltageRange_mV(channel_1_range);
  voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
  return voltage;
}

or you extend the function to read the channel:

float readChannel(ADS1115_MUX channel, ADS1115_RANGE range) {
  float voltage = 0.0;
  adc.setCompareChannels(channel);
  setVoltageRange_mV(range);
  voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
  return voltage;
}

and call readChannel accordingly, for example:

readChannel(ADS1115_COMP_0_GND, ADS1115_RANGE_2048);

If I implement this in the library it will take some additional memory space for the variables. And the effort/complexity on your side does not differ much, since you still have to define somewhere which range you want to apply for which channel. But happy to hear your view. Maybe it would be an alternative to add this as another example sketch?

from ads1115_we.

rin67630 avatar rin67630 commented on May 27, 2024

Thank you.
Will it react to a change of setVoltageRange_mV(range); immediately or could a change immediately followed by an adc.getResult() lead to errors?
Could you change it in setAutoRange() without delay?

from ads1115_we.

wollewald avatar wollewald commented on May 27, 2024

setVoltageRange shouldn't need a delay. Why don't you just try it? And yes, you can use setAutoRange() instead. It changes into the full range, measures the voltage and then selects the lowest range in which the measured is below 80% of the maximum (to have some buffer). The only disadvantage is that it takes some conversion cycles. But you don't need to add a delay.

from ads1115_we.

wollewald avatar wollewald commented on May 27, 2024

I need to correct myself: setVoltageRange() needs a delay. But if you first change the range and then the channel, the delays I have implemented for the change of the channel are sufficient. So do it this way round or take the setAutoRange() function. Sorry for the confusion.

from ads1115_we.

rin67630 avatar rin67630 commented on May 27, 2024

Thank you. I wrote here to share our experience and let others benefit as well
I prefer not it use AutoRange to preserve performance (minimize the processing time).
Once I am through, maybe we could add an example?

from ads1115_we.

wollewald avatar wollewald commented on May 27, 2024

Yes, let's add an example. I'm also considering to add an automatic delay for the change of range.

from ads1115_we.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.