CN112101508A - Pulse transmission method, pulse transmission device, electronic device, and storage medium - Google Patents

Pulse transmission method, pulse transmission device, electronic device, and storage medium Download PDF

Info

Publication number
CN112101508A
CN112101508A CN202010875581.9A CN202010875581A CN112101508A CN 112101508 A CN112101508 A CN 112101508A CN 202010875581 A CN202010875581 A CN 202010875581A CN 112101508 A CN112101508 A CN 112101508A
Authority
CN
China
Prior art keywords
pulse
pulse signal
section
pulses
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.)
Pending
Application number
CN202010875581.9A
Other languages
Chinese (zh)
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.)
Shenzhen Samkoon Technology Corp ltd
Original Assignee
Shenzhen Samkoon Technology Corp ltd
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 Shenzhen Samkoon Technology Corp ltd filed Critical Shenzhen Samkoon Technology Corp ltd
Priority to CN202010875581.9A priority Critical patent/CN112101508A/en
Publication of CN112101508A publication Critical patent/CN112101508A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06MCOUNTING MECHANISMS; COUNTING OF OBJECTS NOT OTHERWISE PROVIDED FOR
    • G06M1/00Design features of general application
    • G06M1/08Design features of general application for actuating the drive
    • G06M1/10Design features of general application for actuating the drive by electric or magnetic means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06MCOUNTING MECHANISMS; COUNTING OF OBJECTS NOT OTHERWISE PROVIDED FOR
    • G06M3/00Counters with additional facilities
    • G06M3/08Counters with additional facilities for counting the input from several sources; for counting inputs of different amounts
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03KPULSE TECHNIQUE
    • H03K21/00Details of pulse counters or frequency dividers
    • H03K21/40Monitoring; Error detection; Preventing or correcting improper counter operation

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Control Of Stepping Motors (AREA)

Abstract

The invention discloses a pulse sending method, a pulse sending device, electronic equipment and a storage medium, and relates to the technical field of pulse control. The method comprises the following steps: sending the pulse signal of the segment; sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the pulse number of the lower section pulse signal and recording the pulse number as a second number; a lower segment pulse signal is transmitted that includes a third number of pulses, the third number being equal to the second number minus the first number. The invention sends the transition section pulse signal at the interval time of the pulse signal of the section and the lower section pulse signal, namely, when the multi-section pulse is switched, the pulse sending is not stopped, but after the middle calculation is finished, the pulse number sent in the middle calculation time is subtracted when the lower section pulse is sent, thereby not only ensuring the continuous sending of the pulse, but also avoiding the influence on the equipment driving caused by the stopping of the pulse.

Description

Pulse transmission method, pulse transmission device, electronic device, and storage medium
Technical Field
The present invention relates to the field of pulse control technologies, and in particular, to a pulse transmission method, an electronic device, and a storage medium.
Background
The pulse can control the servo motor, the stepping motor, the motion Controller and other devices to control the motion of the mechanical device, and the pulse transmission can be realized by a single chip microcomputer, a Programmable Logic Controller (PLC) and other chips. The pulse transmission process has continuity requirement, if stagnation is caused by chip operation or other reasons under a specific frequency, which is equivalent to that the time frequency is significantly reduced, and serious damage can be caused to mechanical equipment. The simple pulse without frequency change and numerical control can be sent to the end all the time after the frequency is configured by using the timer, intermediate calculation is not needed, and the method is easy to realize. But when quantity control, frequency adjustment or other more complex transmission procedures are required, intermediate calculation problems need to be dealt with.
The common scheme is that the pulse sending is stopped for calculation when each pulse section is switched, so that the sending number of each pulse section can be strictly sent according to the calculated value, and the control of the pulse number can be easily realized. For example, below 0.1ms for the median calculation time, a frequency of 10000Hz within the 0.1ms calculation time is insufficient to emit a complete pulse. Assuming that the number of short-shot pulses is less than 1 due to the calculation time, the system requirements can still be met. The upper limit of the pulse frequency provided by the scheme is 10000Hz, a chip with higher performance is needed to improve the upper limit, and the cost is greatly increased due to the improvement of the chip performance. Therefore, pulse continuous transmission cannot be achieved under the same chip performance support and with a higher pulse frequency.
Disclosure of Invention
The present invention is directed to solving at least one of the problems of the prior art. Therefore, the invention provides a pulse sending method, a pulse sending device, an electronic device and a storage medium, which can ensure continuous pulse sending.
The pulse transmitting method according to the embodiment of the first aspect of the present invention includes:
sending the pulse signal of the segment;
sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the number of pulses of the lower section pulse signal and recording the number as a second number;
transmitting a lower segment pulse signal comprising a third number of pulses, the third number equal to the second number minus the first number.
The pulse sending method provided by the embodiment of the invention at least has the following beneficial effects:
the embodiment of the invention transmits the transition segment pulse signal at the interval time of the pulse signal of the segment and the pulse signal of the lower segment, namely, the pulse transmission is not stopped when the multi-segment pulse is switched, but the pulse number transmitted in the middle calculation time is subtracted when the pulse signal of the lower segment is transmitted after the middle calculation is finished, thereby not only ensuring the continuous transmission of the pulse, but also avoiding the damage to the equipment and the influence on the equipment driving due to the stop of the pulse.
According to some embodiments of the invention, the transmitting the pulse signal comprises:
configuring a transmission timer for transmitting a pulse signal and a count timer for pulse counting to control pulse output, the transmission timer and the count timer each being configured in a repeated count mode;
and acquiring the value of the counting timer, interrupting the counting timer and clearing the counting timer when the value of the counting timer reaches the pulse number of the pulse signal of the section.
According to some embodiments of the invention, the transmitting the transition-period pulse signal in the interval period between the present-period pulse signal and the lower-period pulse signal includes:
counting continuously by using the count timer after zero clearing, and calculating to obtain the pulse number of the pulse signals at the lower section, and recording as a second number;
after the calculation is finished, acquiring the pulse number counted by using the count timer after zero clearing as the number of the transition segment pulse signals, and recording as a first number;
and configuring the counting timer to be in a single counting mode, and transmitting a transition segment pulse signal by using the transmitting timer according to the first number.
According to some embodiments of the invention, the transmitting a lower pulse signal comprising a third number of pulses comprises:
and after the transition segment pulse signals are sent, configuring the counting timer to be in a repeated counting mode, and sending a lower segment pulse signal comprising a third number of pulses, wherein the third number is equal to the second number minus the first number.
According to some embodiments of the present invention, after the transmitting the transition-segment pulse signal in the interval period between the present segment pulse signal and the lower segment pulse signal, the method further includes:
continuously transmitting a quantitative pulse signal by using the transmission timer, wherein the quantitative pulse signal comprises a fourth number of pulses, and the sum of the first number and the fourth number is recorded as a fifth number;
and after the quantitative pulse is sent, configuring the counting timer to be in a repeated counting mode, and sending a lower segment pulse signal comprising a third number of pulses, wherein the third number is equal to the second number minus the fifth number.
According to some embodiments of the invention, after configuring the sending timer and the counting timer, further comprising:
judging whether the pulse signal of the segment is the last pulse signal or not;
and if so, configuring the counting timer to be in a single counting mode, setting an end mark, and sending the pulse signal of the section by using the sending timer.
According to some embodiments of the invention, the pulse transmitting method further comprises:
setting driving parameters;
calculating the pulse number of each pulse section according to the driving parameters, and configuring a section number for each pulse section;
and sending pulses according to the section number and the pulse number of each section of pulses until a target parameter is reached.
A pulse transmission device according to an embodiment of a second aspect of the present invention includes:
the first sending module is used for sending the pulse signal of the section;
the second sending module is used for sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the number of pulses of the lower section pulse signal and recording the number as a second number;
a third sending module, configured to send a lower segment pulse signal including a third number of pulses, where the third number is equal to the second number minus the first number.
An electronic device according to an embodiment of the third aspect of the present invention includes:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the above-described pulse transmission method.
A computer-readable storage medium according to a fourth aspect of the present invention stores computer-executable instructions for causing a computer to perform the above-described pulse transmission method.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The above and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic flow chart of a pulse transmission method according to a first embodiment of the first aspect of the present invention;
fig. 2 is a schematic flow chart of a pulse transmission method according to another embodiment of the first aspect of the present invention;
fig. 3 is a schematic flow chart of a pulse transmission method according to another embodiment of the first aspect of the present invention;
fig. 4 is a schematic flow chart of a pulse transmission method according to another embodiment of the first aspect of the present invention;
fig. 5 is a schematic flow chart of a pulse transmission method according to another embodiment of the first aspect of the present invention;
fig. 6 is a schematic flow chart of a pulse transmission method according to another embodiment of the first aspect of the present invention;
fig. 7 is a flowchart illustrating a pulse transmitting method according to another embodiment of the first aspect of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
In the description of the present invention, it should be understood that the orientation or positional relationship referred to in the description of the orientation, such as the upper, lower, front, rear, left, right, etc., is based on the orientation or positional relationship shown in the drawings, and is only for convenience of description and simplification of description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention.
In the description of the present invention, the meaning of a plurality of means is one or more, the meaning of a plurality of means is two or more, and larger, smaller, larger, etc. are understood as excluding the number, and larger, smaller, inner, etc. are understood as including the number. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless otherwise explicitly limited, terms such as arrangement, installation, connection and the like should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific contents of the technical solutions.
The pulse can control the servo motor, the stepping motor, the motion Controller and other devices to control the motion of mechanical devices, the pulse sending can be realized by a single chip microcomputer, a Programmable Logic Controller (PLC) and other devices by means of a chip, the pulse frequency and the pulse number respectively correspond to the speed and the distance of the motion, the physical distance corresponding to one pulse is called as a pulse equivalent, the smaller the pulse equivalent is, the higher the achievable control precision is, and the higher the precision is, the higher the pulse frequency is, under the condition that the speed is not changed.
In industrial and domestic applications, in order to reduce cost, a chip with a lower price is adopted as much as possible, for example, the higher-performance F7 series of typical STM32 series chips have a higher operation capability by more than 10 times and a higher price by more than 10 times than the lower-performance F1 series, and accordingly, the pulse transmission function that can be realized is correspondingly limited.
The pulse can control the servo motor, the stepping motor, the motion Controller and other devices to control the motion of mechanical devices, the pulse sending can be realized by a single chip microcomputer, a Programmable Logic Controller (PLC) and other devices by means of a chip, the pulse frequency and the pulse number respectively correspond to the speed and the distance of the motion, the physical distance corresponding to one pulse is called as a pulse equivalent, the smaller the pulse equivalent is, the higher the achievable control precision is, and the higher the precision is, the higher the pulse frequency is, under the condition that the speed is not changed.
The pulse transmission process has continuity requirement, if stagnation is caused by chip operation or other reasons under a specific frequency, which is equivalent to that the time frequency is significantly reduced, and serious damage can be caused to mechanical equipment. The simple pulse without frequency change and numerical control can be sent to the end all the time after the frequency is configured by using the timer, intermediate calculation is not needed, and the method is easy to realize. But the problem of computation time is handled when quantity control, frequency adjustment or other more complex transmission procedures are required.
The common scheme is that pulse sending is stopped for calculation when each pulse section is switched, so that the sending number of each pulse section can be strictly sent according to a calculated value, and the control of the pulse number can be easily realized, for example, when the intermediate calculation time is less than 0.1ms, a complete pulse cannot be sent under the frequency of 10000Hz in the calculation time, and if the system requirement can still be met when the pulse number which is sent less in the calculation time is less than 1, the upper limit of the pulse frequency which can be provided by the scheme is 10000Hz, and a chip with higher performance is needed to be improved. When the scheme processes quantitative sending pulses or the sending process is complex and requires intermediate calculation, the upper limit of the pulse frequency capable of being continuously sent is limited by the calculation capacity of a chip due to the pulse dead time, and the cost is often greatly increased due to the improvement of the performance of the chip.
Based on the above, the present invention provides a pulse transmission method, a device, an electronic device, and a storage medium, wherein when switching between multiple pulses, the pulse transmission is not stopped, but after the intermediate calculation is completed, the number of pulses transmitted in the intermediate calculation time is subtracted from the next pulse transmission, thereby ensuring that the pulses are continuously transmitted without damaging the device, and avoiding the influence on the device driving due to the stop of the pulses.
In a first aspect, as shown in fig. 1, an embodiment of the present invention provides a pulse sending method, where the method includes:
step S100: sending the pulse signal of the segment;
step S200: sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the pulse number of the lower section pulse signal and recording the pulse number as a second number;
step S300: a lower segment pulse signal is transmitted that includes a third number of pulses, the third number being equal to the second number minus the first number.
In some embodiments, by sending the transition-segment pulse signal in the interval period between the present segment pulse signal and the lower segment pulse signal (i.e. the above-mentioned intermediate calculation time), i.e. when the multi-segment pulse is switched, the pulse sending is not stopped, but after the intermediate calculation is completed, the pulse number sent in the intermediate calculation time is subtracted when the lower segment pulse signal is sent, thereby ensuring that the pulses are sent continuously, the device is not damaged, and the influence on the driving of the device caused by the stopping of the pulses is avoided.
In some embodiments, as shown in fig. 2, step S100 includes:
step S110: configuring a transmission timer for transmitting pulses and a count timer for pulse counting to control pulse output, both the transmission timer and the count timer being configured in a repeat count mode;
in some embodiments, two timers are configured for transmission and counting, respectively, defined as a transmit timer for transmitting pulses and a count timer for counting pulses. The count timer and the AND gate together control the level output of the transmission timer to control the pulse output. The transmission timer and the count timer are each configured to repeat the count mode. The repetition count mode is a mode in which when counting and transmitting pulses to a set number of pulses, transmission is not stopped and transmission of pulses is resumed. After configuration, the pulse transmission is started.
Step S120: and acquiring the value of the counting timer, interrupting the counting timer and resetting the counting timer when the value of the counting timer reaches the pulse number of the pulse signal of the section.
In some embodiments, the value of the count timer is acquired in real time after the start of the transmission of the pulse. Wherein the value of the count timer is incremented by 1 each time a pulse is sent. The transmitted pulse is defined as the pulse signal of the current segment. When the pulse signal of the current segment is sent, the value of the counting timer reaches the pulse number of the pulse signal of the current segment, and the next segment of calculation is carried out through the interruption (called as one interruption) of the counting timer. The calculation of the next segment is mainly to calculate the pulse number (and/or pulse frequency) of the next segment pulse signal (the pulse signal after the pulse signal). Due to the repeated counting mode, the pulses are still being sent and not stopped during the intermediate counting time. Therefore, the counting timer needs to be cleared after the pulse signal of the current segment is sent, so that the counting timer counts the number of pulses sent within the middle calculation time, and the number of pulses is subtracted when the pulse signal of the next segment is sent, thereby ensuring continuous sending of the pulses, avoiding damage to equipment, and avoiding influence on equipment driving due to stopping of the pulses.
In some embodiments, as shown in fig. 3, step S200 includes:
step S210: counting continuously by using the count timer after zero clearing, and calculating to obtain the pulse number of the pulse signals at the lower section, and recording as a second number;
in some embodiments, during the intermediate calculation time, the pulse is still being sent, the number of pulses sent during the intermediate calculation time is counted by using a count timer after being cleared, and simultaneously the system calculates the number of pulses of the lower-stage pulse signal, which is recorded as the second number.
Step S220: after the calculation is finished, acquiring the pulse number counted by using the count timer after zero clearing as the number of the transition segment pulse signals, and recording as a first number;
in some embodiments, after the number of pulses of the lower segment pulse signal is calculated, the number of pulses sent in the middle calculation time counted by the counting timer is obtained as the number of transition segment pulse signals, and is recorded as the first number. The count timer is configured with an interrupt (referred to as a secondary interrupt) having a pulse number slightly greater than the first number currently counted.
Step S230: and configuring the counting timer to be in a single counting mode, and transmitting the transition segment pulse signals by using the transmission timer according to the first number.
In some embodiments, in the second interrupt, the count timer is configured to be in a single count mode, and the transition pulse signal is transmitted using the transmit timer according to the first number. The one-shot count mode refers to stopping transmission when counting and transmitting pulses to a set number of pulses.
In some embodiments, as shown in fig. 4, step S300 includes:
step S310: after the transition section pulse signal is sent, configuring a counting timer into a repeated counting mode;
step S320: a lower segment pulse signal is transmitted that includes a third number of pulses, the third number being equal to the second number minus the first number.
In some embodiments, after the transition segment pulse signal is sent, the counting timer is reconfigured to be in a repeated counting mode, and the lower segment pulse signal is sent. At this time, the number of pulses of the actually transmitted lower pulse signal is equal to the difference between the calculated number of pulses of the lower pulse signal and the number of pulses of the transition pulse signal, that is, the third number is equal to the difference between the second number and the first number. That is, in the second interruption, the number of pulses of the transition pulse signal is subtracted from the number of pulses of the lower pulse signal obtained by calculation, and the number of pulses actually transmitted in the lower stage is filled in the register, and then the transmission of the lower pulse signal is started. Therefore, not only is the continuous sending of the pulse ensured, the equipment cannot be damaged, but also the pulse is not sent in a small quantity, the total pulse number is accurate, and the driving of the equipment cannot be influenced. And because only subtraction operation is used, the performance requirement on the chip is not high, and the cost cannot be increased.
The technical solution of this embodiment is illustrated: the pulse number of the pulse signal of the segment is 100, and the pulse signal of the segment is sent after 100 pulses are sent. Assuming that 2 pulses are transmitted in the intermediate calculation time, the number of pulses of the lower pulse signal obtained by calculation is 110. Then, the number of pulses of the lower pulse signal actually transmitted is 110-2 to 108. Therefore, not only is the continuous sending of the pulse ensured, the equipment cannot be damaged, but also the pulse is not sent in a small quantity, the total pulse number is accurate, and the driving of the equipment cannot be influenced.
In some embodiments, since the operation time of modifying the counting mode of the timer is generally in the nanosecond level, and the pause during the second interrupt is shorter than the time of complex calculation of the first interrupt by more than 1 level, correspondingly, the pulse frequency can be increased by more than 10 times by using the embodiment, which has important values in saving resources, fully utilizing chip performance and reducing cost.
In some embodiments, as shown in fig. 5, after step S200, the method further includes:
step S400: continuously sending quantitative pulse signals by using a sending timer, wherein the quantitative pulse signals comprise a fourth number of pulses, and the sum of the first number and the fourth number is recorded as a fifth number;
step S500: after the fixed quantity pulse is sent, the counting timer is configured to be in a repeated counting mode, and a lower section pulse signal comprising a third number of pulses is sent, wherein the third number is equal to the second number minus the fifth number.
In some embodiments, ideally, just 2 pulses are transmitted within the intermediate calculation time, as described above, i.e., the 3 rd pulse has not yet begun to be transmitted, so that exactly 2 pulses are subtracted when the next pulse signal is transmitted. However, in some cases, the number of pulses transmitted in the middle of the counting time counted by the counting timer is 2, but actually the 3 rd pulse is already being transmitted, and if 2 pulses are subtracted, the lower pulse signal transmits 1 more pulse, which affects the device driving. Therefore, in order to avoid this, after the transition pulse signal is transmitted, a fixed amount of pulse signal is continuously transmitted using the one-shot counting mode, for example, 2 pulses are continuously transmitted (the number may be set to be slightly more than 2 pulses transmitted in the intermediate calculation time), so that the number of pulses of the transition pulse signal becomes 4 (referred to as the fifth number), and 4 is a value that can be calculated with certainty by the assurance program. And after the 4 pulses are sent, sending a lower-segment pulse signal. Also taking the above as an example, the number of pulses of the lower pulse signal transmitted at this time is 96. Thus, the accuracy of pulse transmission can be further improved on the basis of pulse continuous transmission.
In some embodiments, as shown in fig. 6, the method further comprises:
step S600: judging whether the pulse signal of the segment is the last pulse signal or not; if so, executing S700, otherwise, returning to the step S110, and executing the steps S110 to S300;
step S700: and configuring a counting timer to be in a single counting mode, setting an end mark, and sending the pulse signal of the section by using the sending timer.
In some embodiments, when the pulse signal is sent out or a certain interruption triggers, it is found that the last pulse to be sent has been reached, the counting timer is directly configured to be in a single-counting mode, an interruption with a target value being the number of remaining pulses is configured, and an end flag is set, so that the whole-process pulse sending can be directly ended in the secondary interruption, and the total number of pulses is also accurate.
The following describes the present embodiment with a specific application example:
application example 1: multi-segment pulse continuous transmission based on the method
The multistep motion control of the equipment needs quantitative sending of multiple sections of pulses, when the equipment needs to continuously operate without pause, the connection between each section of operation needs to be continuously and without stagnation, otherwise, mechanical jitter can be generated, and the scheme can be used for realizing the multistep motion control.
Firstly, configuring a sending timer and a counting timer, using the counting timer to control pulse output, and then calculating the pulse frequency and the pulse number sent in the first segment and corresponding register configuration.
If the pulse signal transmission of the present segment is finished (i.e., only one segment of pulse), the counting timer is configured to be in a single-counting mode, and the counting target value is set to the number of the pulse signal transmission of the present segment. Setting the ending mark, starting transmission and counting, wherein the configured interruption is secondary interruption, the pulse stops transmission after triggering the secondary interruption, the ending mark is set in the secondary interruption processing, the ending processing is directly carried out, and the consumed time is negligible.
If the pulse signal of the current segment is not the last pulse signal, the counting timer is set to be in a repeated counting mode, the counting target value is set to be the number of the sending pulses of the current segment, and counting and sending are started. The configured interrupt is an interrupt, after the interrupt is triggered, the pulse counting is restarted, but the transmission and counting are not stopped, and the next period of transmission pulse is calculated at the same time of the transmission pulse.
If the lower pulse signal is the last pulse signal, configuring a secondary interrupt to end the processing, otherwise not setting an end flag, configuring the counting timer in a single counting mode, where the target value is a current count value +2 (when the current count is read, the pulse is still being transmitted, and the count value may be +1 at this instant, so the target value is set to +2, thus ensuring that the set target value is greater than the current count value, that is, the number of pulses of the transition pulse signal is 2), continuing to count and transmit, and at this time, the configuration has been adjusted from the primary interrupt to the secondary interrupt. After the secondary interruption is triggered, because the counting timer is in a single-time counting mode, the pulse is stopped from being sent, the value sent by the secondary interruption is subtracted from the target value to serve as a lower-segment target value, the lower-segment target value is filled in a register for configuration, the interruption processing process has no complex calculation and short and negligible time consumption, the counting timer is modified into a repeated counting mode, the cycle of the primary interruption process can be started again after the counting and sending are started again until the last segment is sent, the target value is configured to be a calculated value-a secondary interruption sending value, and the counting and sending are started.
In some embodiments, as shown in fig. 7, the method further comprises:
step S800: setting driving parameters;
step S900: calculating the pulse number of each pulse section according to the driving parameters, and configuring a section number for each pulse section;
step S1000: and sending the pulses according to the section number and the pulse number of each section of pulses until the target parameters are reached.
In some embodiments, during the power-on and operation of the device, the device may be driven to accelerate, decelerate, etc. according to the actual situation. At the moment, driving parameters of each section of acceleration process and each section of deceleration process are required to be set, the pulse number of each section of pulse is calculated according to the driving parameters, a section number is configured for each section of pulse, and the pulse is sent according to the section number and the pulse number of each section of pulse until the target parameters (namely the requirements of acceleration and deceleration) are met, so that the normal work of the equipment is ensured.
The present embodiment is described below with two specific application examples:
application example 2: pulse transmission accelerated from 0 to target frequency based on application example 1
When the equipment is started and stopped, due to the fact that inertia is large or limited by the limitation of torque and rated power, instantaneous switching between high speed and stopping cannot be conducted, and at the moment, a pulse for providing motion control needs to plan an acceleration and deceleration process. Taking the acceleration process at the time of starting as an example, the present embodiment provides the following processing schemes:
firstly, setting driving parameters (acceleration time, distance, acceleration, process motion curve and the like) of an acceleration process according to actual requirements, and then calculating the pulse number of each section in the acceleration process. If parameters of all paragraphs are calculated at one time, the calculation amount of the paragraph connection part is reduced, and the sending continuity can also be increased, but the calculation amount is huge here, and meanwhile, the calculation is needed again every time of dynamic adjustment, the adjustment process in operation becomes very difficult, and the embodiment supports that the relationship between the paragraph number (or time) and the pulse number is reserved first, and the calculation is carried out before each pulse is sent.
Specifically, the pulse number of the first stage of acceleration process is calculated, one interrupt is configured to start sending, one interrupt is triggered after the first stage of sending is completed, the pulse number of the next stage of acceleration process is calculated at this time, and a secondary interrupt is configured and sent after the calculation is completed. In the second interruption, the number of pulses in the current segment calculated in the first interruption minus the number of pulses sent by the second interruption configuration is used as a target value to be filled in a register, the first interruption is reconfigured to be sent until a target parameter (such as a target speed) is reached when the first interruption is triggered at a certain time, the number of pulses sent by the target parameter is calculated in the first interruption, the second interruption is configured after the calculation is completed, the target pulse number is corrected in the second interruption, and the sending of the subsequent segments is the same as the process of the application example 1.
Application example 3: real-time adjustment of frequency based on application example 1
In the application of a hand-operated wheel, an electronic cam and the like, the requirement of speed or position following is often existed, and the value of a following object can change in real time when a pulse is sent, so that the requirement of dynamically adjusting the frequency of the pulse or the target sending number can be met, the sending continuity can be ensured, and the pulse stagnation caused by the calculation of frequency conversion and the like can be avoided. Taking real-time adjustment of the frequency as an example, the present embodiment provides the following processing schemes:
firstly, related parameters (current frequency, target frequency, acceleration and deceleration time, acceleration and deceleration curve and the like) of frequency conversion calculation are obtained, and then the relation between a frequency conversion process section and the pulse number is calculated. And checking the current state, counting the current count value into a total count if the current state is in the primary interrupt period, clearing the count value of the counting timer to 0, calculating the first section of frequency conversion pulse configuration according to the current total count, and modifying the primary interrupt into secondary interrupt after the calculation is finished. Configuring a counting timer into a single counting mode, wherein the target value is a current counting value + 2; and if the current total count is in the secondary interruption period, directly calculating the first frequency conversion pulse configuration according to the current total count. After triggering of secondary interruption, subtracting multiple pulses in the secondary interruption period from the calculated target pulse number, configuring primary interruption and starting transmission again; and after triggering the primary interruption, checking whether the target frequency is reached, if not, continuing to calculate the lower segment acceleration pulse and configuring the secondary interruption, wherein in the secondary interruption, the primary interruption is configured until the target frequency is reached.
If the target frequency is reached when one interruption is triggered at a time, the number of pulses at the target frequency is calculated, then secondary interruption is configured, the number of pulses sent at the target frequency in the first section is corrected in the secondary interruption processing, one-time interruption sending is started, and the subsequent process is the same as that in application example 1.
When the next frequency adjustment signal comes, the process of application example 3 may be performed again.
It is understood that the combined use of multiple stages of quantitative transmission processes such as acceleration and deceleration, frequency conversion, and similar target position adjustment described in application examples 1 to 3 can improve the continuity of pulse transmission in a more complicated control process, and the specific embodiment will not be described in detail.
In a second aspect, an embodiment of the present invention provides a pulse transmitting apparatus, including:
the first sending module is used for sending the pulse signal of the section;
the second sending module is used for sending the transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the pulse number of the lower section pulse signal and recording the pulse number as a second number;
and the third sending module is used for sending a lower segment pulse signal comprising a third number of pulses, wherein the third number is equal to the second number minus the first number.
For the working process of the pulse transmitting apparatus, please refer to the description of the pulse transmitting method according to the first aspect, which is not described herein again.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of pulsing according to the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer-executable instructions are stored, and the computer-executable instructions are configured to cause a computer to execute the pulse sending method according to the first aspect.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the gist of the present invention.
The above-described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may also be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
One of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples" or the like mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims (10)

1. A pulse transmission method is characterized by comprising the following steps:
sending the pulse signal of the segment;
sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the number of pulses of the lower section pulse signal and recording the number as a second number;
transmitting a lower segment pulse signal comprising a third number of pulses, the third number equal to the second number minus the first number.
2. The method according to claim 1, wherein the transmitting the pulse signal of the present segment includes:
configuring a transmission timer for transmitting a pulse signal and a count timer for pulse counting to control pulse output, the transmission timer and the count timer each being configured in a repeated count mode;
and acquiring the value of the counting timer, interrupting the counting timer and clearing the counting timer when the value of the counting timer reaches the pulse number of the pulse signal of the section.
3. The pulse transmitting method according to claim 2, wherein the transmitting of the transition-period pulse signal in the interval period between the present-period pulse signal and the lower-period pulse signal includes:
counting continuously by using the count timer after zero clearing, and calculating to obtain the pulse number of the pulse signals at the lower section, and recording as a second number;
after the calculation is finished, acquiring the pulse number counted by using the count timer after zero clearing as the number of the transition segment pulse signals, and recording as a first number;
and configuring the counting timer to be in a single counting mode, and transmitting a transition segment pulse signal by using the transmitting timer according to the first number.
4. The method according to claim 3, wherein said transmitting a lower pulse signal including a third number of pulses comprises:
after the transition section pulse signal is sent, configuring the counting timer to be in a repeated counting mode;
transmitting a lower segment pulse signal comprising a third number of pulses, the third number equal to the second number minus the first number.
5. The pulse transmitting method according to claim 2, wherein after the transmission of the transition-segment pulse signal in the interval period between the present-segment pulse signal and the lower-segment pulse signal, the method further comprises:
continuously transmitting a quantitative pulse signal by using the transmission timer, wherein the quantitative pulse signal comprises a fourth number of pulses, and the sum of the first number and the fourth number is recorded as a fifth number;
and after the quantitative pulse is sent, configuring the counting timer to be in a repeated counting mode, and sending a lower segment pulse signal comprising a third number of pulses, wherein the third number is equal to the second number minus the fifth number.
6. The method for transmitting pulses according to claim 2, wherein after the configuration of the transmission timer and the count timer, further comprising:
judging whether the pulse signal of the segment is the last pulse signal or not;
and if so, configuring the counting timer to be in a single counting mode, setting an end mark, and sending the pulse signal of the section by using the sending timer.
7. The pulse transmission method according to claim 1, further comprising:
setting driving parameters;
calculating the pulse number of each pulse section according to the driving parameters, and configuring a section number for each pulse section;
and sending pulses according to the section number and the pulse number of each section of pulses until a target parameter is reached.
8. A pulse transmission device, comprising:
the first sending module is used for sending the pulse signal of the section;
the second sending module is used for sending a transition section pulse signal at the interval time of the pulse signal of the current section and the pulse signal of the lower section; the transition section pulse signal comprises a first number of pulses, and the interval time period is used for calculating the lower section pulse signal to obtain the number of pulses of the lower section pulse signal and recording the number as a second number;
a third sending module, configured to send a lower segment pulse signal including a third number of pulses, where the third number is equal to the second number minus the first number.
9. An electronic device, comprising:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to cause the at least one processor to perform:
the pulse transmission method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer-executable instructions stored thereon for causing a computer to perform:
the pulse transmission method according to any one of claims 1 to 7.
CN202010875581.9A 2020-08-27 2020-08-27 Pulse transmission method, pulse transmission device, electronic device, and storage medium Pending CN112101508A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010875581.9A CN112101508A (en) 2020-08-27 2020-08-27 Pulse transmission method, pulse transmission device, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010875581.9A CN112101508A (en) 2020-08-27 2020-08-27 Pulse transmission method, pulse transmission device, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
CN112101508A true CN112101508A (en) 2020-12-18

Family

ID=73757856

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010875581.9A Pending CN112101508A (en) 2020-08-27 2020-08-27 Pulse transmission method, pulse transmission device, electronic device, and storage medium

Country Status (1)

Country Link
CN (1) CN112101508A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116011563A (en) * 2023-03-28 2023-04-25 之江实验室 High-performance pulse transmission simulation method and device for pulse relay

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001211692A (en) * 2000-01-20 2001-08-03 Fuji Photo Optical Co Ltd Camera platform controller
CN102347727A (en) * 2010-07-29 2012-02-08 深圳市汇川技术股份有限公司 Motor fixed length control system and method
CN104635538A (en) * 2014-12-29 2015-05-20 常熟市九洲电器设备有限公司 Fixed length control system
CN110535380A (en) * 2018-05-23 2019-12-03 杭州海康威视数字技术股份有限公司 A kind of method for controlling stepping motor, device, system and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001211692A (en) * 2000-01-20 2001-08-03 Fuji Photo Optical Co Ltd Camera platform controller
CN102347727A (en) * 2010-07-29 2012-02-08 深圳市汇川技术股份有限公司 Motor fixed length control system and method
CN104635538A (en) * 2014-12-29 2015-05-20 常熟市九洲电器设备有限公司 Fixed length control system
CN110535380A (en) * 2018-05-23 2019-12-03 杭州海康威视数字技术股份有限公司 A kind of method for controlling stepping motor, device, system and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116011563A (en) * 2023-03-28 2023-04-25 之江实验室 High-performance pulse transmission simulation method and device for pulse relay

Similar Documents

Publication Publication Date Title
EP1052560B1 (en) Numerical control system
CN112101508A (en) Pulse transmission method, pulse transmission device, electronic device, and storage medium
US20210208561A1 (en) Method for data processing and programmable logic controller
US20210058957A1 (en) Method and apparatus for performing scheduling request
CN107734404B (en) FPGA-based wave division equipment electrical layer protection implementation system and method
CN108292236B (en) Information processing method and device
CN111030552A (en) Synchronous control method of servo driver and servo driver
US20130253668A1 (en) Positioning apparatus and plc system using same
WO2017203776A1 (en) Motor drive system, motor control system, and self-propelled robot
CN107809193A (en) A kind of progress control method of motor, device and motor driver
CN109909733B (en) Screw locking control method, control device, storage medium and processor
CN114679249B (en) EtherCAT communication synchronization method and device
CN112995060B (en) Flow control method based on hardware counter
CN114546926B (en) Core cluster synchronization, control method, data processing method, core, device and medium
CN109862651B (en) One-line dimming method, circuit, chip and system
US7002485B1 (en) Method for the quasi-continuous transmission of a temporally modifiable variable
CN111092575A (en) T-type acceleration and deceleration control method based on singlechip-controlled stepping motor
CN112631368A (en) Timing method and device of processor
CN115016559B (en) Full closed loop multi-path planning line feeding method and device
CN114489562A (en) Pulse transmission method and storage medium
US20200279592A1 (en) Data acquisition method and data acquisition apparatus
CN115001325B (en) Timed interrupt control method and multi-step motor synchronous control system and method
CN108510614B (en) Piece counting method and system
CN118282262A (en) Control method and control system of stepping motor, electronic equipment and storage medium
CN203800849U (en) Stepping motor control device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20201218

RJ01 Rejection of invention patent application after publication