update Code
This commit is contained in:
parent
3c47103b39
commit
a641fad56c
119 changed files with 10997 additions and 5 deletions
|
@ -0,0 +1,48 @@
|
|||
#include <FlowMeter.h> // https://github.com/sekdiy/FlowMeter
|
||||
|
||||
// enter your own sensor properties here, including calibration points
|
||||
FlowSensorProperties MySensor = {60.0f, 5.5f, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
|
||||
FlowMeter Meter = FlowMeter(2, MySensor);
|
||||
|
||||
// timekeeping variables
|
||||
long period = 1000; // one second (in milliseconds)
|
||||
long lastTime = 0;
|
||||
|
||||
// define an 'interrupt service routine' (ISR)
|
||||
void MeterISR() {
|
||||
// let our flow meter count the pulses
|
||||
Meter.count();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// prepare serial communication
|
||||
Serial.begin(9600);
|
||||
|
||||
// enable a call to the 'interrupt service handler' (ISR) on every rising edge at the interrupt pin
|
||||
attachInterrupt(INT0, MeterISR, RISING);
|
||||
|
||||
// sometimes initializing the gear generates some pulses that we should ignore
|
||||
Meter.reset();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// do some timekeeping
|
||||
long currentTime = millis();
|
||||
long duration = currentTime - lastTime;
|
||||
|
||||
// wait between display updates
|
||||
if (duration >= period) {
|
||||
|
||||
// process the counted ticks
|
||||
Meter.tick(duration);
|
||||
|
||||
// output some measurement result
|
||||
Serial.println("FlowMeter - current flow rate: " + String(Meter.getCurrentFlowrate()) + " l/min, " +
|
||||
"nominal volume: " + String(Meter.getTotalVolume()) + " l, " +
|
||||
"compensated error: " + String(Meter.getCurrentError()) + " %, " +
|
||||
"duration: " + String(Meter.getTotalDuration() / 1000) + " s.");
|
||||
|
||||
// prepare for next cycle
|
||||
lastTime = currentTime;
|
||||
}
|
||||
}
|
51
libraries/FlowMeter-master/examples/Multi/Multi.ino
Normal file
51
libraries/FlowMeter-master/examples/Multi/Multi.ino
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include <FlowMeter.h> // https://github.com/sekdiy/FlowMeter
|
||||
|
||||
// connect a flow meter to an interrupt pin (see notes on your Arduino model for pin numbers)
|
||||
FlowMeter Meter1 = FlowMeter(2);
|
||||
FlowMeter Meter2 = FlowMeter(3);
|
||||
|
||||
// set the measurement update period to 1s (1000 ms)
|
||||
const unsigned long period = 1000;
|
||||
|
||||
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
|
||||
void Meter1ISR() {
|
||||
// let our flow meter count the pulses
|
||||
Meter1.count();
|
||||
}
|
||||
|
||||
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
|
||||
void Meter2ISR() {
|
||||
// let our flow meter count the pulses
|
||||
Meter2.count();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// prepare serial communication
|
||||
Serial.begin(9600);
|
||||
|
||||
// enable a call to the 'interrupt service handler' (ISR) on every rising edge at the interrupt pin
|
||||
// do this setup step for every ISR you have defined, depending on how many interrupts you use
|
||||
attachInterrupt(INT0, Meter1ISR, RISING);
|
||||
attachInterrupt(INT1, Meter2ISR, RISING);
|
||||
|
||||
// sometimes initializing the gear generates some pulses that we should ignore
|
||||
Meter1.reset();
|
||||
Meter2.reset();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// wait between output updates
|
||||
delay(period);
|
||||
|
||||
// process the (possibly) counted ticks
|
||||
Meter1.tick(period);
|
||||
Meter2.tick(period);
|
||||
|
||||
// output some measurement result
|
||||
Serial.println("Meter 1 currently " + String(Meter1.getCurrentFlowrate()) + " l/min, " + String(Meter1.getTotalVolume())+ " l total.");
|
||||
Serial.println("Meter 2 currently " + String(Meter2.getCurrentFlowrate()) + " l/min, " + String(Meter2.getTotalVolume())+ " l total.");
|
||||
|
||||
//
|
||||
// any other code can go here
|
||||
//
|
||||
}
|
40
libraries/FlowMeter-master/examples/Simple/Simple.ino
Normal file
40
libraries/FlowMeter-master/examples/Simple/Simple.ino
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <FlowMeter.h> // https://github.com/sekdiy/FlowMeter
|
||||
|
||||
// connect a flow meter to an interrupt pin (see notes on your Arduino model for pin numbers)
|
||||
FlowMeter Meter = FlowMeter(2);
|
||||
|
||||
// set the measurement update period to 1s (1000 ms)
|
||||
const unsigned long period = 1000;
|
||||
|
||||
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
|
||||
void MeterISR() {
|
||||
// let our flow meter count the pulses
|
||||
Meter.count();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// prepare serial communication
|
||||
Serial.begin(9600);
|
||||
|
||||
// enable a call to the 'interrupt service handler' (ISR) on every rising edge at the interrupt pin
|
||||
// do this setup step for every ISR you have defined, depending on how many interrupts you use
|
||||
attachInterrupt(INT0, MeterISR, RISING);
|
||||
|
||||
// sometimes initializing the gear generates some pulses that we should ignore
|
||||
Meter.reset();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// wait between output updates
|
||||
delay(period);
|
||||
|
||||
// process the (possibly) counted ticks
|
||||
Meter.tick(period);
|
||||
|
||||
// output some measurement result
|
||||
Serial.println("Currently " + String(Meter.getCurrentFlowrate()) + " l/min, " + String(Meter.getTotalVolume())+ " l total.");
|
||||
|
||||
//
|
||||
// any other code can go here
|
||||
//
|
||||
}
|
43
libraries/FlowMeter-master/examples/Simulator/Simulator.ino
Normal file
43
libraries/FlowMeter-master/examples/Simulator/Simulator.ino
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <FlowMeter.h> // https://github.com/sekdiy/FlowMeter
|
||||
|
||||
// let's provide our own sensor properties, including calibration points for error correction
|
||||
FlowSensorProperties MySensor = {60.0f, 4.5f, {1.2, 1.1, 1.05, 1, 1, 1, 1, 0.95, 0.9, 0.8}};
|
||||
|
||||
// let's pretend there's a flow sensor connected to pin 3
|
||||
FlowMeter Meter = FlowMeter(3, MySensor);
|
||||
|
||||
void setup() {
|
||||
// prepare serial communication
|
||||
Serial.begin(9600);
|
||||
|
||||
// sometimes initializing the gear generates some pulses that we should ignore
|
||||
Meter.reset();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// randomly change simulation period and pulse rate
|
||||
long frequency = random(MySensor.capacity * MySensor.kFactor); // Hz
|
||||
long period = random(3 * frequency, 5000); // ms
|
||||
|
||||
// simulate random flow meter pulses within a random period
|
||||
for (long i = 0; i < (long) ((float) period * (float) frequency / 1000.0f); i++) {
|
||||
Meter.count();
|
||||
}
|
||||
|
||||
// wait that random period
|
||||
delay(period);
|
||||
|
||||
// process the counted ticks
|
||||
Meter.tick(period);
|
||||
|
||||
// output some measurement result
|
||||
Serial.println("FlowMeter - period: " + String(Meter.getCurrentDuration() / 1000.0f, 3) + "s, " +
|
||||
"frequency: " + String(Meter.getCurrentFrequency(), 0) + "Hz, " +
|
||||
"volume: " + Meter.getCurrentVolume() + "l, " +
|
||||
"flow rate: " + Meter.getCurrentFlowrate() + "l/min, " +
|
||||
"error: " + Meter.getCurrentError() + "%, " +
|
||||
"total duration: " + Meter.getTotalDuration() / 1000.0f + "s, " +
|
||||
"total volume: " + Meter.getTotalVolume() + "l, " +
|
||||
"average flow rate: " + Meter.getTotalFlowrate() + "l/min, " +
|
||||
"average error: " + Meter.getTotalError() + "%.");
|
||||
}
|
19
libraries/FlowMeter-master/examples/platformio.ini
Normal file
19
libraries/FlowMeter-master/examples/platformio.ini
Normal file
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Project Configuration File
|
||||
#
|
||||
# A detailed documentation with the EXAMPLES is located here:
|
||||
# http://docs.platformio.org/en/latest/projectconf.html
|
||||
#
|
||||
|
||||
[env:2009]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = diecimilaatmega328
|
||||
|
||||
[env:pro8]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = pro8MHzatmega328
|
||||
|
||||
# Automatic targets - enable auto-uploading
|
||||
targets = upload
|
Loading…
Add table
Add a link
Reference in a new issue