-
Notifications
You must be signed in to change notification settings - Fork 146
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
On quickly changing voltages and currents, the values are uncorrelated to each other #18
Comments
hmm can you try getPower_mW()? |
@ladyada : My remaining issue is that every value read is uncorrelated to its siblings in time. When I read voltage and current, they are read at different times. Is the INA219 capable of taking one measurement then let you read the voltage and current registers without causing another measurement? I could not find in the Datasheet how to trigger a measurement, I'm guessing reading triggers a new set of measurements? If that is so, then then I think it's impossible to do. The following code makes me think that reading a register triggers (or would trigger) a measurement for every register read. You have to start a read by writing the register pointer:
It would still be useful to have a triggered mode for power savings and synchronization to external events. Thanks! |
I just found a nugget of valuable information in the INA219 datasheet (SBOS448G –AUGUST 2008–REVISED DECEMBER 2015), page 9, heading 8.3.1, at the very bottom:
I guess the INA219 CAN be triggered and ALL measurements be read before triggering another one! Correlated data is possible! Martin |
Hi, Every read of a register adds 1 ms delay which is only in very rare cases helpful.I can only assume this is to have a converted value ready (as conversion time is by default 532uS). But this really makes no sense in most cases. In continuous mode it will just add 1ms of wait, but as conversion start is not synchronized with register read, it does not add any value. We would get an equally up to date value without wait. Writing the register addr every time not always requiredIf the last read from the INA219 was from the same register and there was no reset in between, there is no need to write the register address again to the INA219. I would be willing to provide a PR which implements:
It will need 3 more bytes of data (for remembering the conversion mode and the last register) and a few bytes of code. Time-wise the impact in the backward compatible mode should be only very, very few cycles ( if(doWait) { ... } ). @ladyada: My question before doing all of this (which would include migrating my application to use the Adafruit INA219 library from working INA219 code) is: Is there a good chance that this PR (assuming it meets the quality / code style requirements ) gets integrated quickly, i.e. my effort is not wasted with a sufficiently high probability? |
Hi @hogthrob, When needed, the program would trigger, wait, copy the array of correlated values, or simply trigger after reading if freshness is not an issue. If correlation is not important, the auto-trigger flag would be set to auto and the values read as needed from the array, like it is now. Of course, it might be a new function in the library, as Adafruit has mentioned that backwards compatibility is critical. I'm only a beginner, but I believe a Pro could implement it with backward compatibility. Even if it lives only as a pull-request and never gets pulled in, it will be useful to others. Many great features live only in pull requests. My guess is that they want to keep code size and memory requirements to a minimum for small micro-controllers. I might be able to dig back in this next week if you need me, Martin |
we'd take a clean PR that requests both at once and places the values into pointers, ideally it would take two Adafruit_Sensor objects and set one to VOLTAGE and one to CURRENT type, then they could be timestamped as well. see https://github.com/adafruit/Adafruit_LSM6DSOX/blob/master/Adafruit_LSM6DSOX.cpp#L190 |
I have seen this also and I think paragraph 8.3.1.1 of the datasheets states why, at least when it does power measurement itself... I think the same holds true when you are doing it also. |
Issue:
Each measurement is made separately. In fast changing voltage and current situations, the reading of voltage is not synchronized with it's current measurement. Power calculation is difficult because of this.
Suggestion:
Allow a triggered measurement instead of continous. The user code would Trigger, Wait for the measurement, and Read the synchronized values.
The changes involved:
OR
Thanks!
Martin Boissonneault
The text was updated successfully, but these errors were encountered: