Arduino Swissflow Meter












1















We've hooked up a Swissflow sf800 flow meter to our Arudino Uno. The system works, our interrupt callback is triggered and as water flows through the metre, it counts up. The issue is, that the pulse rate is supposed to be 5600/L and we get exactly double that, so we get 5600 per 500ml.



The code is:



if(millis() - lastTime >= 1000) 
{
noInterrupts();
totalCount = pulseCount;
lastTime = millis();
interrupts();

if (totalCount >= 5600)
{
// Here we have 500ml of water, not the expected litre....?
}
}

void InterruptCallback()
{
++pulseCount;
}


For sake of brevity, I've left out variable declarations and globals etc but the code is working as "expected". Is the pulse count not correctly counted in the interrupt callback? We're both fairly new to this, but it seems to be the way people have implemented it in other examples. If it helps, the interrupt is set to trigger on RISING.



Link to the flow meter and spec:



http://www.swissflow.com/sf800.html



http://www.hemomatik.se/PDF/Datasheet_SF-800-3-8_2012_h.pdf



Interrupt code:



attachInterrupt(digitalPinToInterrupt(2), InterruptCallback, RISING);


The interrupt is being triggered and the count increases.










share|improve this question













migrated from stackoverflow.com Nov 26 '18 at 17:21


This question came from our site for professional and enthusiast programmers.











  • 2





    Without seeing the specs of your flow meter it's hard to answer.

    – Jabberwocky
    Nov 20 '18 at 8:18






  • 2





    And the initialization of the interrupt.

    – Mike
    Nov 20 '18 at 10:09
















1















We've hooked up a Swissflow sf800 flow meter to our Arudino Uno. The system works, our interrupt callback is triggered and as water flows through the metre, it counts up. The issue is, that the pulse rate is supposed to be 5600/L and we get exactly double that, so we get 5600 per 500ml.



The code is:



if(millis() - lastTime >= 1000) 
{
noInterrupts();
totalCount = pulseCount;
lastTime = millis();
interrupts();

if (totalCount >= 5600)
{
// Here we have 500ml of water, not the expected litre....?
}
}

void InterruptCallback()
{
++pulseCount;
}


For sake of brevity, I've left out variable declarations and globals etc but the code is working as "expected". Is the pulse count not correctly counted in the interrupt callback? We're both fairly new to this, but it seems to be the way people have implemented it in other examples. If it helps, the interrupt is set to trigger on RISING.



Link to the flow meter and spec:



http://www.swissflow.com/sf800.html



http://www.hemomatik.se/PDF/Datasheet_SF-800-3-8_2012_h.pdf



Interrupt code:



attachInterrupt(digitalPinToInterrupt(2), InterruptCallback, RISING);


The interrupt is being triggered and the count increases.










share|improve this question













migrated from stackoverflow.com Nov 26 '18 at 17:21


This question came from our site for professional and enthusiast programmers.











  • 2





    Without seeing the specs of your flow meter it's hard to answer.

    – Jabberwocky
    Nov 20 '18 at 8:18






  • 2





    And the initialization of the interrupt.

    – Mike
    Nov 20 '18 at 10:09














1












1








1








We've hooked up a Swissflow sf800 flow meter to our Arudino Uno. The system works, our interrupt callback is triggered and as water flows through the metre, it counts up. The issue is, that the pulse rate is supposed to be 5600/L and we get exactly double that, so we get 5600 per 500ml.



The code is:



if(millis() - lastTime >= 1000) 
{
noInterrupts();
totalCount = pulseCount;
lastTime = millis();
interrupts();

if (totalCount >= 5600)
{
// Here we have 500ml of water, not the expected litre....?
}
}

void InterruptCallback()
{
++pulseCount;
}


For sake of brevity, I've left out variable declarations and globals etc but the code is working as "expected". Is the pulse count not correctly counted in the interrupt callback? We're both fairly new to this, but it seems to be the way people have implemented it in other examples. If it helps, the interrupt is set to trigger on RISING.



Link to the flow meter and spec:



http://www.swissflow.com/sf800.html



http://www.hemomatik.se/PDF/Datasheet_SF-800-3-8_2012_h.pdf



Interrupt code:



attachInterrupt(digitalPinToInterrupt(2), InterruptCallback, RISING);


The interrupt is being triggered and the count increases.










share|improve this question














We've hooked up a Swissflow sf800 flow meter to our Arudino Uno. The system works, our interrupt callback is triggered and as water flows through the metre, it counts up. The issue is, that the pulse rate is supposed to be 5600/L and we get exactly double that, so we get 5600 per 500ml.



The code is:



if(millis() - lastTime >= 1000) 
{
noInterrupts();
totalCount = pulseCount;
lastTime = millis();
interrupts();

if (totalCount >= 5600)
{
// Here we have 500ml of water, not the expected litre....?
}
}

void InterruptCallback()
{
++pulseCount;
}


For sake of brevity, I've left out variable declarations and globals etc but the code is working as "expected". Is the pulse count not correctly counted in the interrupt callback? We're both fairly new to this, but it seems to be the way people have implemented it in other examples. If it helps, the interrupt is set to trigger on RISING.



Link to the flow meter and spec:



http://www.swissflow.com/sf800.html



http://www.hemomatik.se/PDF/Datasheet_SF-800-3-8_2012_h.pdf



Interrupt code:



attachInterrupt(digitalPinToInterrupt(2), InterruptCallback, RISING);


The interrupt is being triggered and the count increases.







interrupt arduino-uno






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 8:09







pma07pg











migrated from stackoverflow.com Nov 26 '18 at 17:21


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Nov 26 '18 at 17:21


This question came from our site for professional and enthusiast programmers.










  • 2





    Without seeing the specs of your flow meter it's hard to answer.

    – Jabberwocky
    Nov 20 '18 at 8:18






  • 2





    And the initialization of the interrupt.

    – Mike
    Nov 20 '18 at 10:09














  • 2





    Without seeing the specs of your flow meter it's hard to answer.

    – Jabberwocky
    Nov 20 '18 at 8:18






  • 2





    And the initialization of the interrupt.

    – Mike
    Nov 20 '18 at 10:09








2




2





Without seeing the specs of your flow meter it's hard to answer.

– Jabberwocky
Nov 20 '18 at 8:18





Without seeing the specs of your flow meter it's hard to answer.

– Jabberwocky
Nov 20 '18 at 8:18




2




2





And the initialization of the interrupt.

– Mike
Nov 20 '18 at 10:09





And the initialization of the interrupt.

– Mike
Nov 20 '18 at 10:09










0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "540"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58217%2farduino-swissflow-meter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Arduino Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58217%2farduino-swissflow-meter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

Npm cannot find a required file even through it is in the searched directory

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith