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

Multisensor Code Ready for Testing #158

Merged
merged 10 commits into from
Jan 21, 2015
Merged

Multisensor Code Ready for Testing #158

merged 10 commits into from
Jan 21, 2015

Conversation

timburke
Copy link
Contributor

I revised and updated the multisensor code. The current version has changes to make it more robust. It differs from the previous version in the following ways:

  • It counts the total amount of water that has passed through the flow meter (i.e. it functions as an accumulator). It does this by sampling the flow rate for 0.1 seconds every 4 seconds.
  • It sets up a callback currently every 1 minute to report the accumulated flow in the past minute. It corrects the flow rate for the fact that it is only sampling 1/40th of the time so it multiplies the count of pulses that it has by the ratio of the total time it's reporting for / its on time.
  • It has verified sleep power consumption of 30 uA and run consumption of 4.6 mA. This is detailed in Issue Momo Power Consumption #112. The average consumption is ~150 uA, which would translate to almost 300 day runtime (without counting GSM transmission consumption).

This is for review, comments and testing. It needs to be squashed for merging.

#include <xc.h>


uint16_t counter;
uint16_t periods;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is ever explicitly initialized to 0, as counter is in the module's initialization() function.

@amcgee
Copy link
Member

amcgee commented Jan 13, 2015

Should the mib12_reflash changes be included here?

@@ -174,17 +195,14 @@ void acquire_pulse()

void read_pulses()
{
mib_buffer[0] = pulse_count() & 0xFF;
mib_buffer[1] = pulse_count() >> 8;
mib_buffer[0] = counter & 0xFF;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this cause unpredictable values if called after a few periods have past? For instance, if the board is acquiring pulses every 4 seconds and reporting them every minute, then somebody tries to inspect the pulse count after 30 seconds, the caller will get 30 seconds worth of pulses (with no indication of the period) and then the counter will be reset.

An alternative:
return both the counter and periods values, don't reset the counter, and compute the pulse/second value dynamically on the receiving (python) side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed in the new code version. There are separate mib calls now for reading the current state of the counters and clearing them.

timburke added a commit that referenced this pull request Jan 21, 2015
@timburke timburke merged commit 07fd31a into WellDone:dev Jan 21, 2015
@timburke timburke deleted the feature-update-multisensor branch January 21, 2015 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants