Summary of the invention
The technical problem to be solved in the present invention is, for the drawbacks described above of prior art, it is provided that a kind of PLC
Programmable filter.
The technical solution adopted for the present invention to solve the technical problems is: a kind of PLC programmable filter of structure
Device, including the digital integration device being connected with the input port of PLC, all with described digital integration device electricity
Property connect threshold value comparison means and positive and negative saturated comparison means and respectively with described digital integration device, threshold
The parameter read-in device that value comparison means and described positive and negative saturated comparison means are electrically connected with, and described threshold ratio
Relatively device includes selection subelement and the output subelement being electrically connected with successively;
Described digital integration device is for inputting from the numeral of external reception according to the input port via PLC
Signal is integrated computing, and integral operation result exports described threshold value comparison means and described positive and negative full
And comparison means;
Described positive and negative saturated comparison means for by described digital integration device export integral operation result with
Positive saturation value and the negative saturation value preset compare, and are used for controlling described numeral according to comparative result output
Integrating gear is integrated computing or out-of-work first control signal;
Described selection subelement compares first for the second control signal according to described output subelement feedback
Relatively result or the second comparative result output subelement, wherein said first comparative result is described numeral
The integral operation result of integrating gear output and the comparative result of the high-level threshold preset, described second compares
Result is the integral operation result comparison knot with the low level threshold value preset of described digital integration device output
Really;
Described output subelement is for producing the second control signal conduct according to the output of described selection subelement
The output of PLC programmable filter;
Described parameter read-in device for programming arrange integral constant and described default high-level threshold and
Low level threshold value, default positive saturation value and negative saturation value.
In above-mentioned PLC programmable filter, described first control signal includes the first high level and first
Low level two states, described digital integration device is when described first control signal is the first high level state
Quit work, be integrated computing when described first control signal is the first low level state.
In above-mentioned PLC programmable filter, described second control signal includes the second high level and second
Low level two states, described selection subelement will when described second control signal is the second high level state
Second comparative result output subelement, when described second control signal is the second low level state,
By the first comparative result output subelement.
In above-mentioned PLC programmable filter, described digital integration device include the first data selector,
Second data selector, adder and depositor;Two inputs of described first data selector all connect
Connecing described parameter read-in device, the end that controls of described first data selector connects numeral input to be filtered
Signal;One input of described second data selector connect described first data selector outfan,
The input value of another input is 0, and the control end of described second data selector connects described positive and negative saturated
The outfan of comparison means;Two inputs of described adder connect described second data selector respectively
Outfan and the outfan of described depositor;The outfan of described adder connects the input of described depositor
End.
In above-mentioned PLC programmable filter, described depositor includes multiple first be sequentially connected in series
Trigger.
In above-mentioned PLC programmable filter, described selection subelement includes the first comparator, the second ratio
Relatively device and the 3rd data selector, described output subelement includes the second trigger;Described first comparator
Two inputs and described second comparator two inputs respectively with the outfan of described depositor
Connect with described parameter read-in device, the outfan of described first comparator and the output of described second comparator
End two inputs with described 3rd data selector respectively are connected, the output of described 3rd data selector
End is connected with the input of described second trigger, the outfan of described second trigger and described 3rd data
The control end of selector connects.
In above-mentioned PLC programmable filter, described first trigger and described second trigger are same
Step d type flip flop.
In above-mentioned PLC programmable filter, described positive and negative saturated comparison means include the 3rd comparator,
4th comparator and or door;Two inputs of described 3rd comparator and two of described 4th comparator
Input is connected with the outfan of described digital integration device and described parameter read-in device respectively, and described
The outfan of three comparators and the outfan of described 4th comparator respectively with described or two inputs of door
Connecting, described or door outfan is connected with described digital integration device.
Implement the PLC programmable filter of the present invention, have the advantages that by using dual threshold
Comparator, it is achieved that a kind of sluggish input effect, reached jamproof feature;Filled by parameter read-in
Put the positive saturation value so that presetting and the negative saturation value preset and default high-level threshold low with preset
Level threshold can separate and individually programs setting, it is achieved that the flexible configuration of filtering, can control filter capacity
And the contradiction of response rapidity;And the positive integral constant preset and the negative integral constant preset can be compiled respectively
Journey is arranged, it is achieved that high level and low level different disposal.
Detailed description of the invention
In order to be more clearly understood from the technical characteristic of the present invention, purpose and effect, now comparison accompanying drawing is detailed
Describe the detailed description of the invention of the bright present invention in detail.
The block diagram of the PLC programmable filter that the preferred embodiment that Fig. 1 is the present invention provides,
Including digital integration device 10, threshold value comparison means 20, positive and negative saturated comparison means 30 and parameter read-in
Device 40, wherein, digital integration device 10 is connected with the input port of PLC, the input of this PLC
Mouth is for the digital input signals that need to be filtered from external reception, and digital integration device 10 is for via described
The input port of PLC from the digital input signals that need to be filtered of external reception and inputs according to this numeral
Signal is integrated computing, and exports integral operation result to threshold value comparison means 20 and positive and negative saturation ratio
Relatively device 30, and threshold value comparison means 20 includes again selecting subelement 21 and output subelement 22.
Positive and negative saturated comparison means 30 is for the operation result exported by digital integration device 10 and just presets
Saturation value and negative saturation value compare, and export the first predetermined control signal according to comparative result.Wherein,
First control signal has the first high level and the first low level two states, and digital integration device 10 is first
Control signal is to quit work during the first high level state, when the first control signal is the first low level state
It is integrated computing.
Select subelement 21 for comparing knot according to the second control signal of output subelement 22 feedback by first
Fruit or the second comparative result output subelement 22, wherein the first comparative result is digital integration device
The integral operation result of 10 outputs and the comparative result of the high-level threshold preset, the second comparative result is number
The integral operation result of word integrating gear 10 output and the comparative result of the low level threshold value preset;Output
Unit 22 is for producing the second control signal as PLC filter able to programme according to the output selecting subelement 21
The output of ripple device.Second control signal includes the second high level and the second low level two states, selects son single
Second comparative result is exported subelement when the second control signal is the second high level state by unit 21
22, when the second control signal is the second low level state, by the first comparative result output subelement
22。
Parameter read-in device 40 respectively with digital integration device 10, threshold value comparison means 20 and positive and negative saturated
Comparison means 30 connects, and arranges integral constant and above-mentioned default high-level threshold and low for programming
Level threshold, default positive saturation value and negative saturation value.Wherein, integral constant includes again the positive integration preset
Constant and the negative integral constant preset.
Digital integration device 10 includes again first data selector the 101, second data selector 102, addition
Device 103 and depositor 104, as in figure 2 it is shown, two inputs of the first data selector 101 all connect
Connect parameter read-in device 40, for positive integral constant+N that parameter read-in device 40 output is preset with
Negative integral constant-M processes, N Yu M is positive number, can be identical value or different value, the first number
Connecting digital input signals to be filtered according to the end that controls of selector 101, digital input signals has high level
With low level both states, it is assumed that digital input signals significant level is high level, at this numeral input letter
When number being high level state, the first data selector 101 selects the positive integral constant+N output preset;?
When this digital input signals is low level state, the first data selector 102 now selects the negative integration preset
Constant-M exports.
One input of the second data selector 102 connects the outfan of the first data selector 101, another
The value of one input input is 0, and the control end of the second data selector 102 connects positive and negative saturation ratio and relatively fills
Putting the outfan of 30, positive and negative saturated comparison means 30 exports the first control signal, relatively fills in positive and negative saturation ratio
Putting the first control signal of 30 outputs when being the first low level state, the second data selector 102 is controlled at it
The control of end processed selects down the input value output being connected with the outfan of the first data selector 101;Positive and negative
When first control signal of saturation device 30 output is the first high level state, the second data selector 102
The input output selecting input value to be 0 under it controls the control of end, the most now stops integral operation, number
Word integrating gear 10 quits work.Two inputs of adder 103 connect the second data selector respectively
The outfan of 102 and the outfan of depositor 104, the outfan of adder 103 connects depositor 104
Input, i.e. depositor 104 and adder 103 are equivalent to an enumerator, simulate long-pending with this enumerator
Dividing device, therefore digital integration device 10 achieves a kind of integral action.Wherein, depositor 104 is by multiple
First trigger is connected in series composition, and such as, if including K position the first trigger, then depositor 104 is K
Bit register.
First comparator the 201, second comparator 202 and the 3rd data select to select subelement 21 to include
Device 203;Output subelement 22 includes the second trigger 204, as it is shown on figure 3, the first comparator 201
Two inputs and the second comparator 202 two inputs respectively with the outfan of depositor 104 and
Parameter read-in device 40 connects.First comparator 201 is high level comparator, for filling parameter read-in
The high-level threshold preset putting 40 outputs processes, and it is the most digital with the output valve of depositor 104
The operation result of integrating gear 10 output compares, if the operation result of digital integration device 10 output is big
In default high-level threshold, then the first comparator 201 exports high level;Second comparator 202 is low electricity
Flat comparator, processes, by it for the low level threshold value presetting parameter read-in device 40 output
Compare with the operation result of digital integration device 10 output, if the computing of digital integration device 10 output
Result is less than the low level threshold value preset, then the second comparator 202 output low level.First comparator 201
Outfan and the second comparator 202 outfan respectively with two inputs of the 3rd data selector 203
Connecting, the outfan of the 3rd data selector 203 and the input of the second trigger 204 connect, and second touches
Send out the outfan i.e. outfan of threshold value comparison means 20 and the control of the 3rd data selector 203 of device 204
End connects.Threshold value comparison means 30 exports the second control signal, i.e. output subelement 22 according to selecting son single
The output of unit 21 produces the output as PLC programmable filter of second control signal, selects subelement 21
The second control signal further according to output subelement 22 feedback carries out selecting output.Specifically, the 3rd data
Selector 203, when the second control signal is the second high level state, selects subelement 21 to compare second
Result output subelement 22, the i.e. the 3rd data selector 203 selects under it controls the control of end
The output valve output of the second comparator 202;When the second control signal is low level state, select subelement
21 by the first comparative result output subelement 22, and the i.e. the 3rd data selector 203 controls end at it
Control the lower output valve output selecting the first comparator 201.Therefore dual threshold comparator is used, it is achieved that
The effect that one band sluggishness compares.
Positive and negative saturated comparison means 30 includes again the 3rd comparator the 301, the 4th comparator 302 and or door
303, as shown in Figure 4, two inputs of the 3rd comparator 301 and two of the 4th comparator 302 defeated
Enter end to be connected with outfan and the parameter read-in device 40 of digital integration device 10 respectively.3rd comparator
301 is the most saturated comparator, at the positive saturation value presetting parameter read-in device 40 output
Reason, compares the operation result that itself and digital integration device 10 export, if digital integration device 10
When the operation result of output is more than or equal to the positive saturation value preset, the 3rd comparator 301 exports high level;
4th comparator 302 is negative saturated comparator, negative full for preset parameter read-in device 40 output
Process with value, the operation result that itself and digital integration device 10 export is compared, if numeral is long-pending
When the operation result of separating device 10 output is less than or equal to negative saturation value, the 4th comparator 302 exports high electricity
Flat.The outfan of the 3rd comparator 301 and the outfan of the 4th comparator 302 respectively with or the two of door 303
Individual input connects, or the outfan of the most positive and negative saturated comparison means 30 of outfan of door 303 connects numeral
The control end of the second data selector 102 in integrating gear 10, if the 3rd comparator 301 and the 4th
When the output valve of comparator 302 has one to be high level, or door 303 output valve is high level, the most positive and negative full
It is the first high level state with the first control signal of comparison means 30 output, now controls digital integration dress
Put the input output that the second data selector 102 in 10 selects input value to be 0, digital integration device
10 quit work, and keep initial value.
First trigger and the second trigger 204 are synchronization d type flip flop, all with the rising of clock pulses
Along triggering, depositor 104 and the clock signal (Clk) of the second trigger 204 and reset signal (nRST)
Derive from inside PLC system.
The operation principle that a kind of PLC programmable filter that the present invention provide now is discussed in detail is as follows:
1) such as the digital integration device in Fig. 2, wherein there is a multi-bit register (by multiple trigger groups
Become) with adder (Add) constitute an enumerator, carry out analogue integrator with this enumerator, counting time
Clock derives from inside PLC system, and the operand 1 that wherein an input of adder is corresponding comes from many
Bit register, the operand 2 that another input of adder is corresponding comes from second data selector
(Mux), when depositor unsaturation, operand 2 is+N, or-M, depends on input signal, false
If input signal significant level is high level, when input signal is high level for+N, for during low level being
-M, when counting reaches saturated (output valve of multi-bit register more than or equal to preset positive saturation value or
Negative saturation value less than or equal to presetting), now control the second data selector and be output as 0, be i.e. operand 2
It is 0, stops doing integral operation.Therefore digital integration device achieves a kind of integral action, the constant of integration
All can be realized the programming of M, N by parameter read-in device, thus realize inputting low and high level signal
Different filter effects.
2) such as the threshold value comparison means in Fig. 3, it realizes the comparison of low and high level by two comparators.
One of them is low-level comparator, and one is high level comparator, when the computing of digital integration device output
When result is more than the high-level threshold preset, high level comparator output high level;When digital integration device is defeated
When the operation result gone out is less than the low level threshold value preset, low-level comparator output low level;When numeral is amassed
The operation result of separating device output, when default high-level threshold and low level threshold interval, keeps the last time
The level state of threshold value comparison means output.Specifically, high level comparator and low-level comparator export
Two signals enter into a synchronizer trigger (Flip-Flop), data by data selector (Mux)
The control signal of selector is the second control signal of output subelement output, when the second control signal is second
During high level state, the 3rd data selector selects the second comparative result output of low-level comparator output, when
When second control signal is the second low level state, the 3rd data selector selects the first of high level comparator
Comparative result exports.Achieve, by the two comparator, the effect that a band sluggishness compares, reached anti-dry
The feature disturbed, the in addition high-level threshold preset in the operand of two comparators and low level threshold value
With by arranging as the parameter read-in device in Fig. 1 programs.
3) such as the positive and negative saturated comparison means in Fig. 4, digital integration device exports to positive and negative in output simultaneously
Saturated comparison means, this positive and negative saturated comparison means includes the most saturated comparator and negative saturated comparator, when
When the output valve of digital integration device is more than or equal to the positive saturation value preset, the high electricity of the most saturated comparator output
Flat, otherwise export the most saturated comparator output low level;When the output valve of digital integration device is less than or equal to
During the negative saturation value preset, negative saturated comparator output high level, otherwise bear saturated comparator output low level.
The two comparator is by one or exports the data selector in digital integration device behind the door.The merit realized
Can be, when the operation result of digital integration device output reaches default positive saturation value or default negative saturated
During value, it is possible to achieve digital integration device quits work, keep initial value.In addition the positive saturation value preset is with pre-
If negative saturation value all can by parameter read-in device programming arrange.
4) such as the parameter read-in device in Fig. 1, it can allow PLC system in house software write parameters,
Such as the dotted arrow part in Fig. 1, such that it is able to realize arranging different parameters in different application.Such as,
The high level burr produced in data input signal needs different filtering time from low level burr, overall
The corresponding time, all can by parameter read-in device programming arrange.Wherein, positive pulse is usually required
Signal, but after usually having had interference, can there is persistent period the shortest negative burr in positive pulse, this is
To be removed, and negative pulse is also required, if but having had interference, when meeting superposition continues in negative pulse
Between the shortest positive burr, be also to need to remove.Additionally, the positive saturation value preset and the negative saturation value preset
Separately be separately provided with default high-level threshold and low level threshold value, preset positive integral constant with preset
Negative integral constant can individually program setting, it is achieved thereby that filter function the most flexibly.And can lead to
Cross and change these parameter values, it is achieved pulse separates with continuous impulse filter effect, the high electricity in input signal
Flat low level filter effect separates, to reach best filter effect in the case of different application.
Fig. 5 is the oscillogram of the first preferred embodiment of the present invention a kind of PLC programmable filter, at this
In embodiment, by the programming of parameter read-in device arrange default positive integral constant be 1, the negative integration preset
It is often-1, i.e. N=1, M=1, default high-level threshold PT(Positive Threshold is set) be 3,
Low level threshold value NT (Negative Threshold) preset is 2, arranges default positive saturation value PS
The negative saturation value NS(Negative saturation that (Positive saturation) be 6, presets) it is 0.
This oscillogram includes digital input signals Input, the output signal Out i.e. threshold value comparison means that need to be filtered
Second control signal of output, clock signal Ref_Clk, output valve i.e. count value Counter of depositor
And the count curve figure corresponding with count value.Wherein, the value represented by count curve figure with count value is
The same, simply curve is illustrated for convenience, and interference signal is the negative hair of a period of time of arrow indication in figure
Thorn.
As it can be seen, input signal is low level when starting, i.e. input integral value is 0, and once input is
High level, starts to do integral operation with PLC system internal reference clock, when counting i.e. digital integration device
When the operation result of output increases to default high-level threshold 3, now the first comparator output high level,
3rd data selector selects the high level output of the first comparator output, after the second trigger, threshold value
Second control signal of comparison means output is the second high level state, and then counting continues to increase, each time
The amplitude increased is N, as it can be seen, counting increases to 5 from 1, and (should when running into input for low level
Low level is after the high level in input signal runs into interference, the negative hair that persistent period of generation is the shortest
Thorn), count and start to reduce from 5, the amplitude reduced each time is M, now counts and not up to presets
Low level threshold value 2, the second control signal is also to maintain the second high level state, and counting reduces to 3 from 5.
Input signal is high level afterwards, and counting continues to start to increase from 3, until counting increases to pre-from 3
If positive saturation value 6, after increasing to default positive saturation value 6, positive and negative saturated comparison means output
First control signal is the first high level state, and now controlling the second data selector output valve is 0, stops
Integral operation, counting holding 6 is constant.Input signal is low level afterwards, and counting starts again to reduce, until
Count from 6 be reduced to low level threshold value 2 after, now the second comparator output low level, the 3rd data select
Device selects the low level output of the second comparator output, and after the second trigger, threshold value comparison means exports
The second control signal be the second low level state, then counting continue drop to negative saturated integrated value 0 from 1.
Visible interference signal in input signal is i.e. born burr can play good filtration result.
Therefore, a kind of PLC programmable filter that the present invention provides, use the comparator of dual threshold, i.e.
Exporting after one value is made two, such as, the operation result in the output of digital integration device is
Count value is now the more than the second control signal of the high-level threshold then threshold value comparison means output preset
Two high level states, less than preset low level threshold value then threshold value comparison means output the second control signal this
Time be the second low level state, at default high-level threshold and low level threshold interval, then threshold ratio relatively fills
The second control signal putting output keeps the level state of last time.It is achieved thereby that a kind of sluggish input effect
Really, even if to the interference signal produced at Near Threshold, being also not result in misoperation, reached jamproof
Characteristic.And changed the value of parameter by parameter read-in device for special application scenario, it is possible to achieve no
Same filter effect, such as: when system is applied to low velocity pulse, it is assumed that system clock frequency is
1MHz, the input signal proximity switch that need to be filtered i.e. received from the input port of PLC inputs, switch
Being low level when being typically in disconnection, switch Guan Bi is high level, and input signal significant level is high level,
As shown in Figure 6, i.e. when input signal is high level, counting increases.Time is about 20ms, to
Detect this input signal, and to filter the interference signal (positive burr) less than 10ms, then NS=0 can be set,
The frequency of PT=10000, NT=0, N=1, M=10000(1MHz is 10ms when count value is 10000),
If now inputting the disturbing pulse signal of a 9ms, will be filtered out.Therefore the positive saturation value preset
Separately it is separately provided with the high-level threshold preset and low level threshold value with default negative saturation value, such that it is able to
Control filter capacity and the contradiction of response rapidity, it is achieved that the flexible configuration of filtering;The positive integration preset
Constant and the negative integral constant preset can individually program setting by parameter read-in device, such that it is able to real
The filter effect that existing positive pulse is different from negative pulse processes;I.e. can realize single by the value changing these parameters
Pulse separates with continuous impulse filter effect, the separation of the high level low level filter effect of input signal,
And go for high speed, the input of low speed.
Above in conjunction with accompanying drawing, embodiments of the invention are described, but the invention is not limited in above-mentioned
Detailed description of the invention, above-mentioned detailed description of the invention is only schematic rather than restrictive, this
The those of ordinary skill in field, under the enlightenment of the present invention, is being protected without departing from present inventive concept and claim
Under the ambit protected, it may also be made that a lot of form, within these belong to the protection of the present invention.