Method for monitoring PWM pulse number by using IO port interrupt feedback

文档序号:1601079 发布日期:2020-01-07 浏览:17次 中文

阅读说明:本技术 一种使用io口中断反馈来监控pwm脉冲数的方法 (Method for monitoring PWM pulse number by using IO port interrupt feedback ) 是由 杨君宜 徐祥铭 周围 刘威 于 2019-09-06 设计创作,主要内容包括:本发明涉及一种使用IO口中断反馈来监控PWM脉冲数的方法,属于计算机领域。该方法包括以下步骤:在硬件电路上以将通道1的PWM波接到MCU的中断IO口上,通道2的PWM波作为输出信号给到外部需要控制的具体系统上;当MCU产生PWM波时,从两个通道同时发出相位、频率和占空比一致的PWM波;其中通道1通过外部中断接回MCU,通过中断记数,准确判断当前发出的PWM脉冲数。在利用MCU控制步进电机的工控系统中,由于步进电机的运行角度是跟脉冲数量相关的;通过对PWM的反馈监控,达到了准确控制步进电机按指定步进角工作的目的。(The invention relates to a method for monitoring the pulse number of PWM by using IO port interrupt feedback, belonging to the field of computers. The method comprises the following steps: connecting the PWM wave of the channel 1 to an interrupt IO port of the MCU on a hardware circuit, and taking the PWM wave of the channel 2 as an output signal to a specific external system needing to be controlled; when the MCU generates PWM waves, the two channels simultaneously emit the PWM waves with consistent phase, frequency and duty ratio; wherein, the channel 1 is connected back to the MCU through external interruption, and the number of the PWM pulses sent out at present is accurately judged through interruption counting. In an industrial control system which utilizes an MCU to control a stepping motor, the operation angle of the stepping motor is related to the number of pulses; through the feedback monitoring of the PWM, the purpose of accurately controlling the stepping motor to work according to the specified stepping angle is achieved.)

1. A method for monitoring the number of PWM pulses using IO port interrupt feedback, comprising: the method comprises the following steps:

connecting the PWM wave of the channel 1 to an interrupt IO port of the MCU on a hardware circuit, and taking the PWM wave of the channel 2 as an output signal to a specific external system needing to be controlled;

when the MCU generates PWM waves, the two channels simultaneously emit the PWM waves with consistent phase, frequency and duty ratio;

wherein, the channel 1 is connected back to the MCU through external interruption, and the number of the PWM pulses sent out at present is accurately judged through interruption counting.

2. An electronic device, characterized in that: the electronic device comprises a processor and a memory, the memory having stored therein at least one instruction that is loaded and executed by the processor to perform the operations performed by the method of claim 1.

3. A computer-readable storage medium characterized by: the computer readable storage medium having stored therein instructions which, when executed on a computer, cause the computer to perform the method of claim 1.

Technical Field

The invention belongs to the field of computers, and relates to a method for monitoring the pulse number of PWM by using IO port interrupt feedback.

Background

The motor control system and the like must have a PWM control function, that is, the system runs a specified distance according to the number of received pulses. It is generally desirable for the position control system to have precise control over how many pulses the system sends out.

The existing pulse number monitoring method is based on a PWM (pulse-width modulation) generation mechanism of an MCU (microprogrammed control Unit), a counter is added in the MCU, and the counter is increased by one when a pulse is sent out.

But this method can only monitor the number of PWM generated from within the MCU; but it is not known to the outside of the MCU whether a specified number of PWMs are coming out of the PIN PINs.

Disclosure of Invention

In view of this, the present invention provides a method for monitoring the number of PWM pulses by using IO port interrupt feedback, in which the output PWM is used as an external trigger signal, so as to more accurately record the number of pulses actually sent by a system. The problem that the number of pulses actually generated outside the MCU cannot be accurately known by counting the number of the timers inside the MCU when the number of the PWM pulses is monitored can be solved. Through external interrupt monitoring, the pulse number generated by the system is accurately controlled, and therefore the purpose of accurately controlling the position is achieved.

In order to achieve the purpose, the invention provides the following technical scheme:

a method of monitoring the number of PWM pulses using IO port interrupt feedback, the method comprising the steps of:

connecting the PWM wave of the channel 1 to an interrupt IO port of the MCU on a hardware circuit, and taking the PWM wave of the channel 2 as an output signal to a specific external system needing to be controlled;

when the MCU generates PWM waves, the two channels simultaneously emit the PWM waves with consistent phase, frequency and duty ratio;

wherein, the channel 1 is connected back to the MCU through external interruption, and the number of the PWM pulses sent out at present is accurately judged through interruption counting.

An electronic device comprising a processor and a memory, the memory having stored therein at least one instruction that is loaded and executed by the processor to perform operations performed by the method.

A computer-readable storage medium having stored therein instructions which, when executed on a computer, cause the computer to perform the method.

The invention has the beneficial effects that: in an industrial control system which utilizes an MCU to control a stepping motor, the operation angle of the stepping motor is related to the number of pulses; through the feedback monitoring of the PWM, the purpose of accurately controlling the stepping motor to work according to the specified stepping angle is achieved.

Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention may be realized and attained by the means of the instrumentalities and combinations particularly pointed out hereinafter.

Drawings

For the purposes of promoting a better understanding of the objects, aspects and advantages of the invention, reference will now be made to the following detailed description taken in conjunction with the accompanying drawings in which:

FIG. 1 is a diagram of an application scenario of the present invention;

FIG. 2 is a flow chart of the present invention.

Detailed Description

The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention in a schematic way, and the features in the following embodiments and examples may be combined with each other without conflict.

Wherein the showings are for the purpose of illustrating the invention only and not for the purpose of limiting the same, and in which there is shown by way of illustration only and not in the drawings in which there is no intention to limit the invention thereto; to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of an actual product; it will be understood by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.

The same or similar reference numerals in the drawings of the embodiments of the present invention correspond to the same or similar components; in the description of the present invention, it should be understood that if there is an orientation or positional relationship indicated by terms such as "upper", "lower", "left", "right", "front", "rear", etc., based on the orientation or positional relationship shown in the drawings, it is only for convenience of description and simplification of description, but it is not an indication or suggestion that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and therefore, the terms describing the positional relationship in the drawings are only used for illustrative purposes, and are not to be construed as limiting the present invention, and the specific meaning of the terms may be understood by those skilled in the art according to specific situations.

Referring to fig. 1-2, a method for monitoring the number of PWM pulses using IO port interrupt feedback is shown.

The MCU in the current market has a function of outputting PWM waves, and usually there are several output channels for a certain PWM wave (the output channels can be set to have the same PWM wave).

Then, on the hardware circuit, the PWM wave of the channel 1 may be connected to an interrupt IO port (corresponding to a certain interrupt line) of the MCU, and the PWM wave of the channel 2 is used as an output signal to a specific external system to be controlled.

When the MCU generates the PWM waves, the PWM waves with consistent phase, frequency and duty ratio can be simultaneously emitted from the two channels. Wherein, the channel 1 is connected back to the MCU through external interruption, and the number of the PWM pulses sent out at present is accurately judged through interruption counting. Thereby achieving the purpose of accurately controlling the system. The invention can improve the accuracy of the system and ensure that the output PWM waves are required number.

It should be recognized that embodiments of the present invention can be realized and implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The methods may be implemented in a computer program using standard programming techniques, including a non-transitory computer-readable storage medium configured with the computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner, according to the methods and figures described in the detailed description. Each program may be implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language. Furthermore, the program can be run on a programmed application specific integrated circuit for this purpose.

Further, the operations of processes described herein can be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and/or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) collectively executed on one or more processors, by hardware, or combinations thereof. The computer program includes a plurality of instructions executable by one or more processors.

Alternatively, the method may be implemented in any type of computing platform operatively connected to a suitable connection, including but not limited to a personal computer, mini computer, mainframe, workstation, networked or distributed computing environment, separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, and the like. Aspects of the invention may be embodied in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optically read and/or write storage medium, RAM, ROM, or the like, such that it may be read by a programmable computer, which when read by the storage medium or device, is operative to configure and operate the computer to perform the procedures described herein. Further, the machine-readable code, or portions thereof, may be transmitted over a wired or wireless network. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. The invention also includes the computer itself when programmed with a method and technique for monitoring the number of PWM pulses using IO port interrupt feedback according to the invention. A computer program can be applied to input data to perform the functions described herein to transform the input data to generate output data that is stored to non-volatile memory. The output information may also be applied to one or more output devices, such as a display. In a preferred embodiment of the invention, the transformed data represents physical and tangible objects, including particular visual depictions of physical and tangible objects produced on a display.

Finally, the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it will be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions, and all of them should be covered by the claims of the present invention.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种航空用宽变频交流发电机的数字调压装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!