Page 1 of 1

Pulse counter

Posted: Fri Mar 09, 2018 1:53 pm
by TedO
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

Re: Pulse counter

Posted: Mon Mar 12, 2018 11:00 pm
by medelec35
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

Re: Pulse counter

Posted: Mon Mar 19, 2018 3:52 pm
by TedO
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