CN104698286B - A kind of PWM ripple acquisition methods based on timer - Google Patents

A kind of PWM ripple acquisition methods based on timer Download PDF

Info

Publication number
CN104698286B
CN104698286B CN201510089728.0A CN201510089728A CN104698286B CN 104698286 B CN104698286 B CN 104698286B CN 201510089728 A CN201510089728 A CN 201510089728A CN 104698286 B CN104698286 B CN 104698286B
Authority
CN
China
Prior art keywords
timer
pwm
count
value
cycle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201510089728.0A
Other languages
Chinese (zh)
Other versions
CN104698286A (en
Inventor
蒙志君
王凯鹏
陈旭智
林子豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ningbo Lefeng New Energy Co ltd
Original Assignee
Beihang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beihang University filed Critical Beihang University
Priority to CN201510089728.0A priority Critical patent/CN104698286B/en
Publication of CN104698286A publication Critical patent/CN104698286A/en
Application granted granted Critical
Publication of CN104698286B publication Critical patent/CN104698286B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention is a kind of PWM ripple acquisition methods based on timer, and its step is as follows:One:It is cycle count mode of operation to set a timer, and each cycle triggers a tick interrupt;Two:It is provided for the timer of PWM ripples collection and triggers the mode of operation that subtrahend is counted for high level, the input of PWM ripples collection timer is connected with the PWM ripple signals to be gathered;Three:Interruption service function is write, tick interrupt is responded after each cycle count terminates.PWM ripple acquisition methods of the invention based on timer, the acquisition mode of timer count rather than pulse capture is triggered as a result of high level, such as burr or other bounces are occurred in that even in signal, collection result is not also almost influenceed, so as to substantially increase the antijamming capability of PWM collections.

Description

A kind of PWM ripple acquisition methods based on timer
Technical field
The present invention provides a kind of PWM ripple acquisition methods based on timer, and it is long that it is related to a kind of pulsewidth based on timer Spend the acquisition method of modulated signal PWM ripples, it is proposed that a kind of method for the collection that PWM ripples are realized using timer.This base In the PWM ripple acquisition methods of timer, the collection that pwm signal is realized in various types of timers can be generalized to, it is adaptable to A variety of industrial control fields.Example explanation is carried out by example of CDT2000 boards in the present invention, the PWM ripples gathered are to use Come the 14ms cycle PWM ripples of the motor-driven work of control flaps, 1.1~1.9ms of pulsewidth length range.
Background technology
PWM ripples (PWM, i.e. Pulse Width Modulation, pulse width modulation) are a kind of industry of technology maturation Control signal, in terms of being widely used in the Industry Controls such as motor speed control, actuator Stroke Control, be using numeral output come A kind of very effective technology being controlled to analog circuit.
The oscillogram of PWM ripples is shown in Fig. 1, tcFor pulse period, t1、t2To characterize the pulsewidth length of PWM ripple effective informations.This The described PWM ripples of invention derive from the demand of steering wheel start control, it is necessary to gather a kind of cycle 14ms, the scope of pulsewidth length 1.1~1.9ms pulse-width signal.
The collection of PWM ripples is carried out, the pulsewidth measurement of length of PWM ripples is exactly realized using some equipment.
Traditional PWM ripple acquisition methods, using respectively record pulse width signal rising edge and trailing edge the generation moment, then Two moment are made the difference and try to achieve pulsewidth length.The shortcoming of this method is the spread of voltage or jagged when pulse width signal When, error occurs in the judgement of rising edge and trailing edge, causes signal acquisition to make a mistake.
PWM ripple acquisition methods used in the present invention, using PWM ripples signal as the trigger source of timer, set timer Triggered for high level, then take design to interrupt the count value that timer is read in service function timing.Utilize the meter in timer The variable quantity of numerical value calculates the duration of high level, the interference that will not thus be brought by spread of voltage and burr, With very strong antijamming capability.
The content of the invention
<1>Goal of the invention
Present invention aims at a kind of acquisition method of the PWM ripples based on timer is designed, using timer as main hardware Equipment, by certain physical connection and interrupts the coding of service function, realizes and is applicable to various different cycles and pulsewidth The collection of PWM ripples.
<2>Technical scheme
A kind of PWM ripple acquisition methods based on timer of the present invention, its step is as follows:
Step one:It is cycle count mode of operation to set a timer, and each cycle triggers a tick interrupt;
Step 2:It is provided for the timer of PWM ripples collection and triggers the mode of operation that subtrahend is counted, PWM ripples for high level The input of collection timer is connected with the PWM ripple signals to be gathered;
Step 3:Interruption service function is write, tick interrupt is responded after each cycle count terminates.Wherein, in step " mode of operation that high level triggering subtrahend is counted " described in two, is another mode of operation that can be set of timer, should The function of mode of operation is:Timing can be triggered when the high level that the input that PWM ripples gather timer is PWM ripple signals arrives Terminate to subtract certainly when device progress subtracts certainly, low level arrives.
Wherein, " the cycle count mode of operation " described in step one, is a kind of work that can be configured of timer Operation mode, gives a setting value, and then it can turn again to this value and continue to subtract certainly from this value from reducing to zero, Zhou Erfu Begin, cycle count period=setting value/cycle count timer clock frequency;When triggering one when counting and reducing to zero certainly every time Clock is interrupted;In order to realize the collection of PWM ripples, cycle count period is necessarily less than the two of PWM ripple low duration minimum values / mono-, so just can ensure that " interruption service function " described in step 3 can read described in step 2 " PWM ripples are adopted Collection timer " counts count value when stopping.
Wherein, " the interruption service function " described in step 3, is at the end of each cycle count timer period A called function is interrupted in triggering, and its function is:Each cycle count timer period reads a PWM ripples collection timing The count value of device, judges that the PWM ripples in two neighboring cycle gather the count value of timer;If the PWM ripples in continuous two cycles The count value of collection timer is equal and when being not equal to initial count value, shows that pulse high level is over, pulsewidth length =(initial count value-PWM ripples of PWM ripples collection timer gather the counting end value of timer)/PWM ripples collection timing Device clock frequency, reads pulsewidth length value, and PWM ripples are gathered into timer heavy duty;Otherwise it is without any processing.
The timing diagram of PWM ripples is gathered with timer as shown in Figure 2.
<3>Advantage effect
PWM ripple acquisition methods based on timer, timer count rather than pulse capture are triggered as a result of high level Acquisition mode, even in signal occur in that such as burr or other bounce, on collection result also almost do not influence so that significantly Improve the antijamming capability of PWM collections.
Brief description of the drawings
The present invention is further described below in conjunction with the accompanying drawings.
Fig. 1 is a kind of waveform diagram of PWM ripples.
Fig. 2 is the timing diagram that PWM ripples are gathered with timer, the explanation for having correlated variables in remarks;Wherein, 1, circulation Counter timer counts cycle T0It is necessarily less than 1/2nd of PWM ripple low level length maximums;2nd, in continuous two interruptions Inside read identical and be not equal to TmaxCount value, then it is assumed that high level has terminated;3rd, the interruption that high level terminates is being determined It is interior, read PWM ripple pulsewidths t1=(Tmax-T1)/fTimer clock frequency, the count value of heavily loaded PWM ripples collection timer is Tmax
Fig. 3 is that the circuit and signal for realizing the collection of PWM ripples using CDT2000 timer function in application example are connected Figure.
Fig. 4 is using CDT2000 timer function to carry out the timing diagram of PWM ripple collections in application example.
Fig. 5 the method for the invention FB(flow block)s.
Embodiment
Implementation steps
As Figure 1-5, a kind of PWM ripple acquisition methods based on timer of the present invention, as shown in Figure 5, its step is as follows:
Step one:It is cycle count mode of operation to set a timer, and each cycle triggers a tick interrupt, circulation meter It is necessarily less than 1/2nd of PWM ripple low duration minimum values one number time.
Step 2:It is the counting of high level triggering subtrahend, rising edge flip-flop number weight to be provided for the timer of PWM ripples collection The mode of operation of load, the input of PWM ripples collection timer is connected with the PWM ripple signals to be gathered.
Step 3:Interruption service function is write, tick interrupt is responded after each cycle count terminates;Interrupt service function Each cycle reads the count value that a PWM ripple gathers timer, judges the timer value in two neighboring cycle;If continuous two The numerical value in individual cycle is equal and when being not equal to initial count value, shows that pulse high level is over, pulsewidth length=(initial Count value-counting end value)/timer clock frequency, reads pulsewidth length value, and the collection timing of PWM ripples is thought highly of Carry.
Application example
The example explained below comes from actual application case, using CDT2000 boards as timer device, with PC/104 Embedded computer realizes the response for interrupting service function.In this case, it is necessary to gather 6 road PWM ripples.6 road PWM of collection Both from the remote signal of Futaba receivers, wherein it is original servos control letter that 1 tunnel, which is mode switching signal, 5 road PWM ripples, Number.
The PWM ripples for needing collection are a kind of cycle 14ms, 1.1~1.9ms of pulsewidth length range pulse-width signal.
Specific practice is as follows:
1st, runs pattern is set
Four 82C54 timing controllers of CDT2000 boards, it is each that there are three independent timers, 12 are obtained altogether Individual independent timer, carries out the collection of PWM ripples and has only used wherein seven timers, as shown in Figure 4.The connection of each timer and The setting of working method is expressed as follows:
Timer 1-0:Counted by loop cycle of 2ms, and produce interruption.
Timer 3-0~timer 4-2:GATE mouthfuls start counting up when being high level, and low level stops counting.
Wherein, timer 1-0 is as the triggering timer for interrupting service function, and the setting work period is 2ms, i.e., weekly Phase initial count value is set as 16000.
2nd, the description of service function function is interrupted
The principle gathered on PWM ripples in service function is interrupted to be expressed as follows (timing diagram of PWM ripples collection is shown in Fig. 5):
1) PWM collection timers 3-0~timer 4-2 count value is read by the cycle of 2ms;
If 2) count results are not 65535 and equal to continuous adjacent twice, the pulsewidth that this count value is T, then PWM ripples is remembered As t=(65535-T)/(8 × 106), it is maximum (65535) by the heavy duty of this timer;
If 3) count results are unequal twice for continuous adjacent, without any processing.

Claims (4)

1. a kind of PWM ripple acquisition methods based on timer, it is characterised in that:Its step is as follows:
Step one:It is cycle count mode of operation to set a timer, and each cycle triggers a tick interrupt;
Step 2:It is provided for the timer of PWM ripples collection and triggers the mode of operation that subtrahend is counted, the collection of PWM ripples for high level The input of timer is connected with the PWM ripple signals to be gathered;
Step 3:Interruption service function is write, tick interrupt is responded after each cycle count terminates.
2. a kind of PWM ripple acquisition methods based on timer according to claim 1, it is characterised in that:In step 2 Described " mode of operation that high level triggering subtrahend is counted ", is another mode of operation that can be set of timer, the work The function of pattern is:Timer can be triggered when the high level that the input that PWM ripples gather timer is PWM ripple signals arrives to enter Terminate to subtract certainly when row subtracts certainly, low level arrives.
3. a kind of PWM ripple acquisition methods based on timer according to claim 2, it is characterised in that:In step one Described " cycle count mode of operation ", is a kind of mode of operation that can be configured of timer, gives a setting value, it It can then turn again to this value from this value from reducing to zero and continue, from subtracting, to go round and begin again, cycle count period=setting value/ Cycle count timer clock frequency;Every time a tick interrupt is triggered when counting and reducing to zero certainly;In order to realize adopting for PWM ripples Collection, cycle count period is necessarily less than 1/2nd of PWM ripple low duration minimum values, so just can ensure that step 3 Described in " interruption service function " " the PWM ripples gather timer " that can read described in step 2 count counting when stopping Value.
4. a kind of PWM ripple acquisition methods based on timer according to claim 1, it is characterised in that:In step 3 Described " interruption service function ", is that a called letter is interrupted in triggering at the end of each cycle count timer period Count, its function is:Each cycle count timer period reads the count value that a PWM ripple gathers timer, judges adjacent two The PWM ripples in individual cycle gather the count value of timer;If the count value of the PWM ripples collection timer in continuous two cycles is equal And when being not equal to initial count value, show that pulse high level is over, pulsewidth length=(PWM ripples gather the first of timer Beginning count value-PWM ripple gathers the counting end value of timer)/PWM ripples collection timer clock frequency, reads pulsewidth length Numerical value, and PWM ripples are gathered into timer heavy duty;Otherwise it is without any processing.
CN201510089728.0A 2014-07-24 2015-02-27 A kind of PWM ripple acquisition methods based on timer Expired - Fee Related CN104698286B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510089728.0A CN104698286B (en) 2014-07-24 2015-02-27 A kind of PWM ripple acquisition methods based on timer

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN2014103542967 2014-07-24
CN201410354296 2014-07-24
CN201510089728.0A CN104698286B (en) 2014-07-24 2015-02-27 A kind of PWM ripple acquisition methods based on timer

Publications (2)

Publication Number Publication Date
CN104698286A CN104698286A (en) 2015-06-10
CN104698286B true CN104698286B (en) 2017-10-03

Family

ID=53345616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510089728.0A Expired - Fee Related CN104698286B (en) 2014-07-24 2015-02-27 A kind of PWM ripple acquisition methods based on timer

Country Status (1)

Country Link
CN (1) CN104698286B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107256033B (en) * 2017-07-10 2020-12-22 重庆大学 Unmanned aerial vehicle remote control signal conversion equipment
CN111220843A (en) * 2020-01-18 2020-06-02 惠州华阳通用电子有限公司 Signal level duration time measuring method and device
CN112242828A (en) * 2020-09-11 2021-01-19 深圳市杉川机器人有限公司 Method, device and equipment for capturing pulse width modulation signal
CN112904090A (en) * 2021-01-25 2021-06-04 珠海格力电器股份有限公司 Signal duration acquisition method

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101567658A (en) * 2009-06-05 2009-10-28 中国兵器工业第二○六研究所 Rotating transformer exciting circuit based on sinusoidal pulse width modulation (SPWM)
CN102103168A (en) * 2009-12-22 2011-06-22 比亚迪股份有限公司 PWM (Pulse-Width Modulation) wave detecting method and device
KR20110098291A (en) * 2010-02-26 2011-09-01 (주)모토닉 Method for period and duty measuring of pwm pulse
CN102298095A (en) * 2011-06-27 2011-12-28 中国国土资源航空物探遥感中心 Method for ensuring accurate measurement on pulse width in multi-task singlechip system and device
CN102833905A (en) * 2011-06-17 2012-12-19 博西华电器(江苏)有限公司 PWM (pulse width modulation) dimming method and device for LED (light-emitting diode)
CN103870421A (en) * 2012-12-10 2014-06-18 上海工程技术大学 FPGA (Field Programmable Gate Array) based serial interface and PWM (Pulse Width Modulation) combined application IP (Intellectual Property) core
CN103873035A (en) * 2014-03-07 2014-06-18 电子科技大学 Timer-based PWM (Pulse-Width Modulation) control signal system for generating adjustable dead zone

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8564365B2 (en) * 2012-01-20 2013-10-22 Qualcomm Incorporated Wide input bit-rate, power efficient PWM decoder
KR101367681B1 (en) * 2012-05-30 2014-02-26 삼성전기주식회사 Detector for duty of signal and driving apparatus for motor having the same

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101567658A (en) * 2009-06-05 2009-10-28 中国兵器工业第二○六研究所 Rotating transformer exciting circuit based on sinusoidal pulse width modulation (SPWM)
CN102103168A (en) * 2009-12-22 2011-06-22 比亚迪股份有限公司 PWM (Pulse-Width Modulation) wave detecting method and device
KR20110098291A (en) * 2010-02-26 2011-09-01 (주)모토닉 Method for period and duty measuring of pwm pulse
CN102833905A (en) * 2011-06-17 2012-12-19 博西华电器(江苏)有限公司 PWM (pulse width modulation) dimming method and device for LED (light-emitting diode)
CN102298095A (en) * 2011-06-27 2011-12-28 中国国土资源航空物探遥感中心 Method for ensuring accurate measurement on pulse width in multi-task singlechip system and device
CN103870421A (en) * 2012-12-10 2014-06-18 上海工程技术大学 FPGA (Field Programmable Gate Array) based serial interface and PWM (Pulse Width Modulation) combined application IP (Intellectual Property) core
CN103873035A (en) * 2014-03-07 2014-06-18 电子科技大学 Timer-based PWM (Pulse-Width Modulation) control signal system for generating adjustable dead zone

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
MCS-51单片机对连续脉冲宽度测量的实现;朱玉红;《自动化与仪器仪表》;20030125;全文 *
基于FPGA生成PWM波的实现;苏荣锋 等;《核技术》;20120610(第6期);全文 *
转速转差率的数字化测量方法;罗盛波 等;《电工技术》;20020410(第4期);第1页第1段以及第7段 *

Also Published As

Publication number Publication date
CN104698286A (en) 2015-06-10

Similar Documents

Publication Publication Date Title
CN104698286B (en) A kind of PWM ripple acquisition methods based on timer
US10114053B2 (en) Pulse frequency measurement device and method and control system
CN100550631C (en) Pulse width modulation device
CN103560783B (en) Digital event generator, comparator, switching mode energy transducer and method
JP6444251B2 (en) Computer-implemented method for real-time inspection of control equipment
CN106411193A (en) Method to control a switched reluctance motor
CN103828237B (en) Maintain pulse width modulation data set coherence
CN102959841A (en) Power factor control of a cyclo-converter
CN107643705A (en) Control device and analog-to-digital conversion control method
CN204442725U (en) The zero passage of electromagnetic heating system and breaker in middle pipe thereof opens checkout gear
CN105682271A (en) PPG drive frequency detection system for induction cooker
RU2017130756A (en) EXCITATION CIRCUIT WAY TO CONTROL USE OF THE SURFACE PROTECTION DEVICE
CN103576081B (en) The real-time diagnosis method of a kind of pulse width modulating switch circuit
CN104702251B (en) Timer-based PWM (Pulse Width Modulation) wave generation method
CN104092417A (en) Self-adaptive processing method and device for motor rotor position signals and control system
CN103197577B (en) Robot controller impulsive synchronization method of adjustment and device
CN204442724U (en) The zero passage of electromagnetic heating system and breaker in middle pipe thereof opens checkout gear
CN103885848B (en) The deadlock of a kind of microprocessor, the protection circuit of program fleet fault and implementation method
CN105305932A (en) Motor speed regulation control method and apparatus, and smoke ventilator
US20140258580A1 (en) Motor control apparatus and motor control method
CN209231361U (en) Speed detector, processing circuit and chip based on pwm signal
CN103929179A (en) Anti-interference method for sampling of aircraft electric braking system
CN203313152U (en) Combined switch push-pull pulse output unit
CN106452045B (en) PWM waveform production method and device in interleaving PFC circuit
US20220224319A1 (en) Circuit arrangement and method for monitoring a signal formed by alternating voltage

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20210128

Address after: 315199 b-211-47, Kexin building, 655 bachelor Road, Yinzhou District, Ningbo City, Zhejiang Province

Patentee after: NINGBO ZHIZHENG WEIYING INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 100191 No. 37, Haidian District, Beijing, Xueyuan Road

Patentee before: BEIHANG University

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230308

Address after: 315799 Industrial Park, Sizhoutou Town, Xiangshan County, Ningbo City, Zhejiang Province

Patentee after: Ningbo Lefeng new energy Co.,Ltd.

Address before: 315199 b-211-47, Kexin building, 655 bachelor Road, Yinzhou District, Ningbo City, Zhejiang Province

Patentee before: NINGBO ZHIZHENG WEIYING INFORMATION TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20171003

CF01 Termination of patent right due to non-payment of annual fee