我正在尝试确定脉冲输入的频率,即泵的转速反馈。我试图创建两个计时器,每个计时器为一秒,并且每次出现上升沿时计数。根据一秒钟内上升沿的数量,我可以计算出频率。遗憾的是我找不到功能或功能块。任何关于生成函数的帮助都会很棒!
我还附上了我尝试使用但似乎不起作用的代码 - 我认为一些新鲜的眼睛可能能够发现我错过的东西。
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