## Pulse counter

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

### Pulse counter

Hi guys
I have downloaded the interrupt counter example from the Matrix website and am trying to fathom out how to be able to adapt this program to use on an anemometer? I merely would like to know at a certain wind speed what the number of revolutions the rotor head is making which I can compare with a calibrated anemometer.
I am using a reed switch in the anemometer housing with a small magnet in the revolving head.
Because I have never worked with interrupts before, I am not sure how to adapt the program so as to show the current number of pulses emanating from the rotor. The program simply counts the number of interrupts perfectly as it should and stores them as a total, but how does one read the pulses from the rotor to show the current number of revolutions using the interrupt method??
This is baffling me to no end.
Any help would be appreciated, thank you.
I am including the Matrix example program.

Regards
Ted
Attachments
INT_Pulse_Counter.fcfx

medelec35
Valued Contributor
Posts: 8604
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2476 times
Been thanked: 3558 times
Contact:

### Re: Pulse counter

Hi Ted,
its all down to timing.
What you will need to do is restart a timer and clear the number of pulses.
Start a timer interrupt or use a delay.
I prefer the former.
After a time has elapsed then you take the pulse value and use a multiplier if less then a second to get RPM.
For example if the timer *(or delay) is for 250ms then RPM = total pulses after 250ms * 4.
Assuming only 1 pulse per revolution.
Then if you used a float you can convert to m/s for example.
e.g :
m/s = r × RPM × 0.10472.

With the INT0 interrupt:
If you look at the properties if INT0 you will see its set for rising edge.
Every time INT0 pin changes from logic 0 to logic 1, no matter what part of the program is being executed, it will pause, run the interrupt service macro.
In the case of Int_Pulse_Counter it's INT_Interrupt macro.
Then when NT_Interrupt macro has exited then the progrom will carry on from where it was paused from.

Martin
These users thanked the author medelec35 for the post (total 2):
TedO (Mon Mar 19, 2018 3:54 pm) • Benj (Tue Mar 20, 2018 12:59 pm)
Rating: 10%

Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

### Re: Pulse counter

Hi Martin

Thanks for the help, sorry for only getting back to you now, was quite busy this side.
I understand what you are suggesting, will try and play around with it to get a grasp on the concept.

Much appreciated.

Regards
Ted
These users thanked the author TedO for the post:
Benj (Tue Mar 20, 2018 12:59 pm)
Rating: 5%