CN104702251B - Timer-based PWM (Pulse Width Modulation) wave generation method - Google Patents

Timer-based PWM (Pulse Width Modulation) wave generation method Download PDF

Info

Publication number
CN104702251B
CN104702251B CN201510089189.0A CN201510089189A CN104702251B CN 104702251 B CN104702251 B CN 104702251B CN 201510089189 A CN201510089189 A CN 201510089189A CN 104702251 B CN104702251 B CN 104702251B
Authority
CN
China
Prior art keywords
intervalometer
cycle
pwm
count
timer
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.)
Active
Application number
CN201510089189.0A
Other languages
Chinese (zh)
Other versions
CN104702251A (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.)
Beihang University
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 CN201510089189.0A priority Critical patent/CN104702251B/en
Publication of CN104702251A publication Critical patent/CN104702251A/en
Application granted granted Critical
Publication of CN104702251B publication Critical patent/CN104702251B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Measurement Of Unknown Time Intervals (AREA)
  • Measurement Of Predetermined Time Intervals (AREA)

Abstract

The invention discloses a timer-based PWM (Pulse Width Modulation) wave generation method. The method comprises the following steps: I, setting one timer in a cycle count working mode, wherein one clock interrupt is triggered and one negative pulse is output in each cycle; an output end of the cycle count timer is connected with an input end of a PWM wave generation timer; II, setting the timer for generating the PWM wave in the working mode of high level reductional count trigger, rising edge count heavy load trigger, low level output when the count value is not zero and high level output after the count value is reduced to be zero, wherein the output end of the PWM wave generation timer can generate the PWM wave; III, writing an interruption service function, and responding clock interruption after the count of each cycle is ended. According to the timer-based PWM wave generation method, since the timer is loaded in next interruption after the initial value is written, the pulse width and the cycle accuracy of the generated PWM wave are not affected even though the interruption response of the cycle count timer has time delay.

Description

A kind of PWM ripple generation methods based on intervalometer
Technical field
The present invention provides a kind of PWM ripple generation methods based on intervalometer, and it is long that it is related to a kind of pulsewidth based on intervalometer A kind of generation method of degree modulated signal PWM ripple, it is proposed that method of the generation that PWM ripples are realized using intervalometer.This base In the generation method of the PWM ripples of intervalometer, the generation that pwm signal is realized in various types of intervalometers is can be generalized to, be suitable for In various industrial control fields.In the present invention example explanation is carried out by example of CDT2000 boards, the PWM ripples for being generated are For the 14ms cycle PWM ripples of the motor-driven work of control flaps, pulsewidth 1.1~1.9ms of 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, be widely used in the Industry Controls such as motor speed control, actuator Stroke Control aspect, be using numeral output come A kind of very effective technology that analog circuit is controlled.
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 need to generate a kind of cycle 14ms, the scope of pulsewidth length from the demand of steering wheel start control The pulsewidth length modulated signal of 1.1~1.9ms.
The generation of PWM ripples is carried out, exactly can be carried out manually using some equipment generation this fixed cycles, pulsewidth length The pulsewidth length modulated signal of setting.
Traditional PWM ripple generation methods, using the system clock carried in piece, by I/O equipment according to certain clock Length alternately exports high level and low level, and this method is easily subject to shadow of other softwares to system resource occupancy in system Ring, PWM periods of wave or effective pulsewidth length can be caused unstable.
PWM ripple generating modes used in the present invention, are matched using service function is interrupted, accurate to the cycle of PWM ripples Really property can be controlled strictly, and can easily generate the PWM ripples of various different cycles, with very strong versatility and can Operability.
The content of the invention
<1>Goal of the invention
Present invention aim at a kind of PWM ripple generation methods based on intervalometer of design, set by main hardware of intervalometer Standby, by certain physical connection and the coding of interruption service function, realization is applicable to the PWM of various different cycles and pulsewidth The generation of ripple.
<2>Technical scheme
A kind of PWM ripple generation methods based on intervalometer of the present invention, its step is as follows:
Step one:It is cycle count mode of operation to arrange an intervalometer, and each cycle triggers a tick interrupt, output one Secondary negative pulse, the input that the outfan of cycle count intervalometer generates intervalometer with PWM ripples is connected;
Step 2:The intervalometer for being provided for the generation of PWM ripples is high level triggering subtrahend counting, rising edge flip-flop number weight Export low level, count value when load, count value non-zero to be kept to after zero export the mode of operation of high level, PWM ripples generate intervalometer Outfan can generate PWM ripples;
Step 3:Interruption service function is write, after each cycle count terminates tick interrupt is responded.
Wherein, " the cycle count mode of operation " described in step one, is a kind of work being configured of intervalometer Pattern, gives a setting value, and then it can turn again to this value and continue, from subtracting, to go round and begin again from this value from reducing to zero, Cycle count period=setting value/timer clock frequency.Cycle count period must divide exactly PWM periods of wave and long more than pulsewidth The maximum of degree, so just can guarantee that the accuracy of PWM periods of wave, ensures that each probable value of PWM ripple pulsewidths can be given birth to Into.
Wherein, " high level triggering subtrahend counting, rising edge flip-flop number heavy duty, the count value non-zero described in step 2 When export low level, count value and be kept to after zero export the mode of operation of high level ", be work that the another kind of intervalometer can be arranged Pattern, its function is:At the end of each cycle count period, PWM ripples generate intervalometer input all can receive from The negative pulse of cycle count timer output end cause count value occur heavy duty, and lasting high level cause subtrahend counting after Continuous work.
Wherein, " the interruption service function " described in step 3, is that triggering is interrupted at the end of each cycle count period The function for being called, its function is:Counting is circulated inside function, the inner loop counting cycle is exactly PWM ripples The quotient of cycle and cycle count timer period, the intervalometer that a cycle of each inner loop generates in PWM ripples Count value is rewritten as (the cycle count timer period-PWM ripple pulsewidth length to be generated)/timer clock frequency, so exists Intervalometer certainty counting terminates in the cycle, and so as to produce the high level with the time such as pulsewidth length, what is internally circulated connects Other process are not done in the several cycles got off.
With intervalometer generate PWM ripples sequential chart as shown in Figure 2.
<3>Advantage effect
Based on the PWM ripple generation methods of intervalometer, due to being loaded in interruption next time of the intervalometer after write initial value, Even if therefore the interrupt response of cycle count intervalometer have time delay do not interfere with yet the PWM ripples of generation pulsewidth and the cycle it is accurate Property.
Description of the drawings
Below in conjunction with the accompanying drawings the present invention is further described.
Fig. 1 is a kind of waveform diagram of PWM ripples.
Fig. 2 is the sequential chart that PWM ripples are generated with intervalometer, there is the explanation of correlated variabless in remarks.Note:1st, circulation meter The number timer count cycle must be divided exactly period of wave by PWM, and more than pulsewidth length maximum;2nd, cycle count intervalometer output End generates intervalometer input and is connected with PWM ripples;3rd, input permanent High level causes PWM ripples generation timer count value to continue Successively decrease, it is Tmax that the rising edge of negative pulse causes count value heavy duty;4th, it is T1 that count value is changed in interruption, then count after terminating (T0-T1) clock in persistently export high level, high pulse width t1=(T0-T1)/f timer clock frequencies.
Fig. 3 is to realize circuit and the signal connection of the generation of PWM ripples using the timer function of CDT2000 in application example Figure.
Fig. 4 is that the timer function in application example using CDT2000 carries out the sequential chart of PWM ripple generations.
Fig. 5 the method for the invention FB(flow block)s.
Specific embodiment:
As Figure 1-5, a kind of PWM ripple generation methods based on intervalometer of the present invention, as shown in Figure 5, its step is as follows:
Step one:It is cycle count mode of operation to arrange an intervalometer, and each cycle triggers a tick interrupt, output one Secondary negative pulse, the input that the outfan of cycle count intervalometer generates intervalometer with PWM ripples is connected;Cycle count period must Must be divided exactly and more than the maximum of pulsewidth length period of wave by PWM.
Step 2:The intervalometer for being provided for the generation of PWM ripples is high level triggering subtrahend counting, rising edge flip-flop number weight Output low level, counting export the mode of operation of high level, the output of PWM ripples generation intervalometer in load, gate time after terminating End can generate PWM ripples.
Step 3:Interruption service function is write, tick interrupt is responded after each cycle count terminates, interrupt service function Inner loop counting is carried out, the counting cycle is exactly the quotient of PWM periods of wave and cycle count timer period, each circulation the The count value of the intervalometer that a cycle generates in PWM ripples is rewritten as the (cycle count timer period-PWM ripple arteries and veins to be generated Wide length)/timer clock frequency, intervalometer certainty counting terminates to produce and the time such as pulsewidth length so within this cycle High level, next be left intact in each circulation several cycles.
Application example
The example explained below comes from actual application case, with CDT2000 boards as timer device, with PC/104 Embedded computer is realized interrupting the response of service function.In this case, need to generate 5 road PWM ripples.The 5 road PWM for generating Ripple signal is used to drive steering wheel executor's generation action.
The PWM ripples for generating are needed to be a kind of cycle 14ms, the pulsewidth length modulated of pulsewidth 1.1~1.9ms of length range is believed Number.
Specific practice is as follows:
1st, runs pattern is arranged
Four 82C54 timing controllers of CDT2000 boards, each has three independent timers, 12 is obtained altogether Six of which intervalometer has only been used in individual independent intervalometer, the generation for carrying out PWM ripples, as shown in Figure 3.The connection of each intervalometer It is expressed as follows with the setting of working method:
Intervalometer 1-0:Count by loop cycle of 2ms, and produce interruption, OUT port produces negative arteries and veins in each counting cycle Punching.
Intervalometer 1-1~timer 2-2:The input of GATE mouths rising edge makes intervalometer heavy duty, OUT port when counting for low, Counting is high after terminating.
Wherein, used as the triggering intervalometer for interrupting service function, the setting working cycle is 2ms to intervalometer 1-0, i.e., weekly Phase initial count value is set as 16000.
2nd, the description of service function function is interrupted
Interrupt the principle generated with regard to PWM ripples in service function to be expressed as follows (sequential chart of PWM ripples collection is shown in Fig. 4):
1) to generate the PWM ripples that the cycle is 14ms needs to experience 7 interrupt cycles;
2) the 1st cycle, generate intervalometer to PWM and be loaded into T1=(2ms-t0)/(8 × 106) count value, t0 schedules to last The PWM ripple pulsewidths that prestige is obtained, then in first 2ms, PWM generates intervalometer can be after (2ms-t0) counting terminates in OUT Mouth produces the pulse of t0 length;
3) ensuing continuous 6 cycles, PWM generates intervalometer and is loaded into maximum (65535), the OUT of intervalometer again Mouthful output low level, afterwards 6 2ms cycles keep low level.

Claims (3)

1. a kind of PWM ripple generation methods based on intervalometer, it is characterised in that:Its step is as follows:
Step one:It is cycle count mode of operation to arrange an intervalometer, and each cycle triggers a tick interrupt, output and once bears Pulse, the input that the outfan of cycle count intervalometer generates intervalometer with PWM ripples is connected;
Step 2:The intervalometer for being provided for the generation of PWM ripples is high level triggering subtrahend counting, rising edge flip-flop number is heavily loaded, Export low level, count value during count value non-zero to be kept to after zero export the mode of operation of high level, PWM ripples generate the defeated of intervalometer Going out end can generate PWM ripples;
Step 3:Interruption service function is write, after each cycle count terminates tick interrupt is responded;
Described interruption service function is that a called function, its work(are interrupted in triggering at the end of each cycle count period Can be:Counting is circulated inside function, the inner loop counting cycle is exactly PWM periods of wave and cycle count intervalometer week The quotient of phase, the count value of the intervalometer that a cycle of each inner loop generates in PWM ripples is rewritten as that (cycle count is fixed When device cycle-PWM ripple pulsewidth length to be generated)/cycle count timer clock frequency, so in first inner loop PWM ripples generate intervalometer certainty counting and terminate in the counting cycle, so as to produce the high level with the time such as pulsewidth length, including Portion's circulation is left intact in other cycles in addition to the period 1.
2. a kind of PWM ripple generation methods based on intervalometer according to claim 1, it is characterised in that:In step Described " cycle count mode of operation ", is a kind of mode of operation that can be configured of intervalometer, gives a setting value, it Can then turn again to this value and continue, from subtracting, to go round and begin again from this value from reducing to zero, cycle count period=setting value/ Timer clock frequency;Cycle count period must divide exactly PWM periods of wave and more than the maximum of pulsewidth length, so could protect Demonstrate,prove the accuracy of PWM periods of wave, ensure that each probable value of PWM ripple pulsewidths can be generated.
3. a kind of PWM ripple generation methods based on intervalometer according to claim 1, it is characterised in that:In step 2 Described " exports low level, count value to subtract when high level triggering subtrahend counting, rising edge flip-flop number heavy duty, count value non-zero It is the mode of operation that high level is exported after zero ", it is mode of operation that the another kind of intervalometer can be arranged, its function is:At each At the end of cycle count period, PWM ripples generate the input of intervalometer and all can receive from cycle count timer output end Negative pulse cause count value occur heavy duty, and lasting high level cause subtrahend counting work on.
CN201510089189.0A 2014-07-24 2015-02-27 Timer-based PWM (Pulse Width Modulation) wave generation method Active CN104702251B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510089189.0A CN104702251B (en) 2014-07-24 2015-02-27 Timer-based PWM (Pulse Width Modulation) wave generation method

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN201410355615 2014-07-24
CN2014103556156 2014-07-24
CN201510089189.0A CN104702251B (en) 2014-07-24 2015-02-27 Timer-based PWM (Pulse Width Modulation) wave generation method

Publications (2)

Publication Number Publication Date
CN104702251A CN104702251A (en) 2015-06-10
CN104702251B true CN104702251B (en) 2017-04-19

Family

ID=53349072

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510089189.0A Active CN104702251B (en) 2014-07-24 2015-02-27 Timer-based PWM (Pulse Width Modulation) wave generation method

Country Status (1)

Country Link
CN (1) CN104702251B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113552843A (en) * 2021-07-08 2021-10-26 武汉雄韬氢雄燃料电池科技有限公司 High-precision fixed-point output method for numerical control machine tool
CN115001325B (en) * 2022-04-20 2023-03-24 北京瑞祺皓迪技术股份有限公司 Timed interrupt control method and multi-step motor synchronous control system and method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103168A (en) * 2009-12-22 2011-06-22 比亚迪股份有限公司 PWM (Pulse-Width Modulation) wave detecting method and device
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 (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013149079A (en) * 2012-01-19 2013-08-01 Makita Corp Random number generating device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103168A (en) * 2009-12-22 2011-06-22 比亚迪股份有限公司 PWM (Pulse-Width Modulation) wave detecting method and device
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 (2)

* Cited by examiner, † Cited by third party
Title
利用单片机定时器实现信号采样和PWM控制;李宁等;《微型机与应用》;20040720;第15-17页 *
采用单片机定时器设计PWM实现廉价的高分辨率D/A 转换器;梁伟等;《吉林化工学院学报》;20020915;第19卷(第3期);第36-38页 *

Also Published As

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

Similar Documents

Publication Publication Date Title
US11876474B2 (en) Linear resonant device, and braking method for same
WO2002027931A3 (en) Method and apparatus for asynchronously controlling state information within a circuit
JP6081734B2 (en) Semiconductor device, electronic device, and control signal generation method
JP6101463B2 (en) Controller for DC / DC converter
CN104702251B (en) Timer-based PWM (Pulse Width Modulation) wave generation method
CN104919704B (en) Complementary output generator block
CN103828237B (en) Maintain pulse width modulation data set coherence
US9448581B2 (en) Timer unit circuit having plurality of output modes and method of using the same
CN104698286B (en) A kind of PWM ripple acquisition methods based on timer
CN107643705A (en) Control device and analog-to-digital conversion control method
CN103675373A (en) Digital signal generation method achieved in FPGA
JP2012044514A (en) Driving device of semiconductor switching element and driving method of semiconductor switching element
CN103916104A (en) PWM signal generating circuit, printer, and PWM signal generating method
CN104205634B (en) High Resolution pulse width modulation device
US20140001992A1 (en) Control Circuit with Frequency Hopping for Permanent Magnet Motor Control
US9356579B2 (en) Waveform generation
CN105375904B (en) It is a kind of to generate rapid exponential type pulse output method with ARM single-chip microcontroller
CN108181988B (en) Control method and device for LRA motor driving chip
JP2005339245A (en) Interruption generation circuit
CN105513584A (en) Buzz output method and device
Kurokawa et al. Performance characteristics of digital peak current-injected control DC-DC converter using FPGA
CN103309278B (en) A kind of method improving fixed cycle digital control system sampling antijamming capability
KR101683893B1 (en) Scheduling device for vehicles and scheduling method for electric control of vehicles
CN114583924A (en) Circuit control method, terminal and storage medium
CN101777869A (en) Alternating current variable frequency control method suitable for vibration ageing

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