On the Internet to see the data found that most of the use of CNT (counting instructions) to do the speed, found that the instruction count of the rate of time (or the number of acquisition times) requirements are relatively high and need to write reset signal time program, the error is relatively large, and real-time display speed effect is not good.
The formula for calculating the speed of the CNT instruction: rotational speed = 60/Time point x number of counts
The reason for the error amplification: The number of the number difference one or two, the error amplification 60/time point times.
After several tests, found that the use of CNT instructions can not meet the real-time speed measurement requirements, so change the speed measurement method, the use of measuring a pulse period of time (T), and then use the 60000/pulse period, this method of measurement error is relatively small, the cause of the error, one is the instruction execution cycle, Another count of non-floating-point division caused by the decimal point ellipsis problem, resulting in greater error. When the velocity changes, its pulse period changes.
Speed Calculation formula: Speed = #60000/T
The cause of the error: Time measurement accuracy, non-floating-point division omit the number after the decimal point.
Here are the programs:
' Initialize
Ldnot W2.00
MOV (021) &0 D0
MOV (021) #0 D10
MOV (021) #0 D2
' The duration of a pulse is measured by the duration of the pulse, which is removed by #60000 (1min), which calculates how many pulses a minute has, that is, its speed.
LD W2.00
Out TR0
@AND 0.00
SET 2.00
@++ (590) D0
LD TR0
and 2.00
TMHH (540) 0000 #9999
LD TR0
And= (+) D0 &2
-B (414) #9999 T0 D2
RSET 2.00
/BL (435) #60000 D2 D10
MOV (021) &0 D0
About using Ormon cp1h plc Speed measurement problem