I am trying to determine the frequency of a pulsing input, which is tacho feedback of a pump. I have tried to create two timers which are a second each, and counts up every time there is rising edge. Based on the number of rising edges in a second, I can calculate the frequency. Sadly I couldn't find a function or function block. Any help on generating a function would be fantastic!
Also I have attached the code I have tried to use, but doesn't seem to work - I think some fresh eyes might be able to spot something I have missed.
tonPressureTachoFeedback1(IN:=,PT:=T#1S,Q=>,ET=>); (*Pressure Side Tacho Timer 1*)
tonPressureTachoFeedback2(IN:=,PT:=T#1S,Q=>,ET=>); (*Pressure Side Tacho Timer 2*)
IF stPRessurePump.iTachoFeedbackRAW>900 (*Threshold to cross to be counted as a rising edge*)
AND tonPressureTachoFeedback1.Q=FALSE
AND tonPressureTachoFeedback2.IN=FALSE THEN
tonPressureTachoFeedback2.IN:=FALSE;
iPressureRECount1:=iPressureRECount1+1; (*Increment Counter*)
ELSIF tonPressureTachoFeedback1.Q THEN
tonPressureTachoFeedback2.IN:=TRUE;
rPRessureRPM:=iPressureRECount1*10; (*Generate RPM*)
END_IF
IF stPRessurePump.iTachoFeedbackRAW>900 (*Threshold to cross to be counted as a rising edge*)
AND tonPressureTachoFeedback2.Q=FALSE
AND tonPressureTachoFeedback1.IN=FALSE THEN
tonPressureTachoFeedback1.IN:=FALSE;
iPressureRECount2:=iPressureRECount2+1; (*Increment Counter*)
ELSIF tonPressureTachoFeedback2.Q THEN
tonPressureTachoFeedback1.IN:=TRUE;
rPRessureRPM:=iPressureRECount2*10; (*Calculate RPM*)
END_IF