A cam control method, apparatus, device and medium
By extracting the target segment path length parameter of the cam table on the FPGA and updating it with a counter, the slave axis pulse output is controlled in real time. This solves the problems of high resource consumption and stability risks in cam table parameter processing, and improves master-slave synchronization performance and ensures accuracy and real-time performance.
Patent Information
- Application Number
- CN202211716160.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In existing technologies, cam meter parameter processing consumes a lot of resources on a field-programmable gate array (FPGA), and there are potential problems with stability and speed performance.
By extracting the length parameter of the target segment path from the cam table, the displacement counts of the master and slave axes are updated using a counter. The number of pulses required to be output by the slave axis is determined based on the count ratio, and the pulse processing is controlled in real time. A counter is used to determine whether the process is complete, and then the process jumps to the next target parameter processing.
While reducing FPGA resource consumption, it improves the fast response capability of the slave axis to the master axis input, enhances master-slave synchronization performance, and improves accuracy and real-time performance while ensuring stability and speed performance.
Smart Images

Figure CN115951628B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of mechanical automation control, and in particular to a cam control method, device, equipment and medium. Background Technology
[0002] Today, production automation is becoming increasingly common. Electronic cams are developed based on mechanical cams. Traditional mechanical cams achieve non-linear machining trajectories through cams, while electronic cams directly input the trajectory points into the driver and perform servo control through a set calculation method to achieve the same machining purpose as mechanical gears, realizing a periodic reciprocating motion.
[0003] In software control, a set of cam table parameters is typically provided by the host computer. These parameters simulate the actual profile sampling node information of the cam, giving the motion relationship between the master and slave axes at each position. The processor then processes these parameters and, under the control of the master shaft input pulses, outputs slave shaft pulses that conform to the master-slave pulse ratio relationship of the cam table parameters. By controlling the frequency and number of pulses, the speed and distance of the motor movement can be controlled, thereby achieving the purpose of production application.
[0004] In existing technologies, the parameters in the cam meter are position data. Based on the position difference, the slave axis pulses are output under the control of the master axis pulses. In FPGA (Field Programmable Gate Array) implementations, this consumes significant resources, which can pose risks to the stability and speed performance of the FPGA system. Furthermore, the accuracy and real-time performance of the cam meter parameter processing are also important metrics that need to be evaluated.
[0005] As can be seen from the above, in the process of cam table parameter processing, how to solve the problem of high FPGA resource consumption and potential stability and speed performance issues in the existing technology is a problem that needs to be solved in this field. Summary of the Invention
[0006] In view of this, the purpose of this invention is to provide a cam control method, device, equipment, and medium that can reduce FPGA resource consumption while enabling the slave axis to respond quickly and accurately to the master axis input, improving master-slave synchronization performance, and maximizing the guarantee of both stability and speed performance, as well as accuracy and real-time performance. The specific solution is as follows:
[0007] In a first aspect, this application discloses a cam control method applied to a field-programmable gate array, comprising:
[0008] Extract target parameters from the cam table to characterize the length of the target segment path, and update the first counter for counting the master axis displacement and the second counter for counting the slave axis displacement based on the target parameters;
[0009] The target number of pulses required to be output from the slave axis is determined by using the counting ratio between the current first counter and the current second counter.
[0010] If a pulse input is detected on the main spindle, the first counter is updated, the slave axis is controlled to output the target pulse several pulses, and the second counter is updated;
[0011] Based on the current counts of the first counter and the second counter, determine whether the pulse processing for the target parameter has been completed;
[0012] If not completed, proceed to the step of determining the target number of pulses required to be output from the slave axis using the counting ratio between the current first counter and the current second counter.
[0013] Optionally, extracting the target parameters from the cam table to characterize the length of the target segment path includes:
[0014] When a cam parameter processing command is received, a target parameter for characterizing the length of the target segment path is extracted from the cam table; wherein the length of the target segment path is determined based on the length of the target segment path of the master axis and the length of the target segment path of the slave axis.
[0015] Optionally, updating the first counter for counting the master shaft displacement and the second counter for counting the slave shaft displacement based on the target parameter includes:
[0016] The length of the target segment subpath of the main spindle is assigned to a first counter used to count the displacement of the main spindle, and the length of the target segment subpath of the slave spindle is assigned to a second counter used to count the displacement of the slave spindle.
[0017] Accordingly, the process of updating the first counter if a pulse input is detected on the main spindle, controlling the slave axis to output the target pulse several pulses and updating the second counter includes:
[0018] Whenever a pulse input is detected on the main spindle, the value in the first counter is decremented by one; whenever the slave axis is controlled to output a pulse, the value in the second counter is decremented by one.
[0019] Optionally, after determining whether pulse processing for the target parameter has been completed based on the current counts of the first counter and the second counter, the method further includes:
[0020] If pulse processing for the target parameter has been completed, then determine whether the target parameter is the last parameter in the cam table sorted in a preset order;
[0021] If the target parameter is not the last parameter, then the next parameter of the target parameter is taken as the current target parameter and the process jumps to the step of extracting the target parameter used to characterize the length of the target segment path from the cam table, until all the target parameters in the cam table have been processed.
[0022] Optionally, determining the target number of pulses to be output from the slave axis using the counting ratio between the current first counter and the current second counter includes:
[0023] The pulse period width of the current slave axis is determined by the count ratio between the current value in the first counter and the current value in the second counter used to count the slave axis displacement, and the target number of pulses required to be output by the slave axis is determined by the count ratio.
[0024] Accordingly, controlling the slave axis to output the target pulses includes:
[0025] The slave axis outputs the target number of pulses according to the pulse period width of the current slave axis.
[0026] Optionally, determining the pulse period width of the current slave axis using the counting ratio between the current value in the first counter and the current value in the second counter used to count the slave axis displacement, and determining the target number of pulses to be output by the slave axis using the counting ratio, includes:
[0027] The value obtained by comparing the current value in the first counter with the current value in the second counter used to count the displacement of the shaft is taken as the first ratio, and the value obtained by comparing the current value in the second counter with the current value in the first counter is taken as the second ratio.
[0028] The pulse period width of the slave axis is determined by using the period width of the most recent pulse received by the master axis and the first ratio, and the target number of pulses to be output by the slave axis corresponding to the master axis is determined by using the second ratio.
[0029] Optionally, before extracting the target parameter from the cam table to characterize the length of the target segment path, the method further includes:
[0030] A third counter is set up to calculate the number of spindle pulses that have not yet been processed, so that the third counter is updated when there is a pulse input to the spindle;
[0031] Accordingly, updating the first counter if a pulse input is detected on the spindle includes:
[0032] When the value in the third counter is detected to be a value representing the number of unprocessed pulses on the spindle, the first counter used to count spindle displacement is updated.
[0033] Secondly, this application discloses a cam control device applied to a field-programmable gate array, comprising:
[0034] The parameter extraction module is used to extract target parameters from the cam table to characterize the length of the target segment path, and update the first counter for counting the master axis displacement and the second counter for counting the slave axis displacement based on the target parameters;
[0035] The pulse count determination module is used to determine the target number of pulses required to be output from the slave axis by utilizing the counting ratio relationship between the current first counter and the current second counter.
[0036] A pulse output module is used to update the first counter if a pulse input is detected on the main spindle, control the slave axis to output the target pulse several pulses and update the second counter;
[0037] The pulse processing judgment module is used to determine whether the pulse processing for the target parameter has been completed based on the current counts of the first counter and the second counter.
[0038] The jump execution module is used to jump to the step of determining the target number of pulses to be output from the slave axis by using the counting ratio relationship between the current first counter and the current second counter if the step is not completed.
[0039] Thirdly, this application discloses an electronic device, including:
[0040] Memory, used to store computer programs;
[0041] A processor is used to execute the computer program to implement the aforementioned cam control method.
[0042] Fourthly, this application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed cam control method.
[0043] This application utilizes a field-programmable gate array (FPGA) to extract target parameters characterizing the length of a target segment sub-path from a cam table, and updates a first counter for counting spindle displacement and a second counter for counting slave axis displacement based on these target parameters. The target number of pulses required to be output by the slave axis is determined using the counting ratio between the current first and second counters. If a pulse input is detected on the spindle, the first counter is updated, the slave axis is controlled to output the target number of pulses, and the second counter is updated. The pulse processing for the target parameters is determined based on the current counts of the first and second counters. If not, the process jumps to the step of determining the target number of pulses required to be output by the slave axis using the counting ratio between the current first and second counters. In this way, by extracting the target parameters characterizing the length of the target segment sub-path to process the cam table parameters, the consumption of logic resources on the FPGA can be greatly reduced, costs can be lowered, and system stability and processing speed can be improved. Furthermore, by setting a counter, this invention uses the completion of the current sub-path length as the control criterion to achieve real-time control of the pulse, enabling the slave axis to respond quickly and accurately to the input of the master axis, improving master-slave synchronization performance, and ensuring the stability and speed performance while maximizing the guarantee of accuracy and real-time performance. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0045] Figure 1 A flowchart of a cam control method provided in this application;
[0046] Figure 2 A flowchart of a specific cam control method provided in this application;
[0047] Figure 3 A detailed operation flowchart of a cam control method provided in this application;
[0048] Figure 4 A structural schematic diagram provided for this application;
[0049] Figure 5 A schematic diagram of a cam control device provided in this application;
[0050] Figure 6This application provides a structural diagram of an electronic device. Detailed Implementation
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] In existing technologies, the processing of cam table parameters consumes significant FPGA resources and poses risks to stability and speed performance. This application addresses this issue by reducing FPGA resource consumption while enabling the slave axis to respond quickly and accurately to the master axis input, thus improving master-slave synchronization performance. This approach maximizes the assurance of both stability and speed performance, while also ensuring high accuracy and real-time performance.
[0053] This invention discloses a cam control method applied to field-programmable gate arrays (FPGAs). See [link to relevant documentation]. Figure 1 The method includes:
[0054] Step S11: Extract the target parameter from the cam table to characterize the length of the target segment path, and update the first counter for counting the master axis displacement and the second counter for counting the slave axis displacement based on the target parameter.
[0055] In this embodiment, the cam table stores a parameter P[k], where k = 0 to n, used to represent the length of a sub-path. Specifically, P[k] = (X[k] / Y[k]), where P[k] represents the length of the k-th sub-path segment, X[k] represents the length of the k-th sub-path segment on the master axis, and Y[k] represents the length of the k-th sub-path segment on the slave axis. That is, the numerator of the target parameter can be used as the length of the target sub-path segment on the master axis, and the denominator can be used as the length of the target sub-path segment on the slave axis.
[0056] In this embodiment, extracting the target parameter from the cam table to characterize the length of the target segment path may include: when a parameter processing instruction is received, setting a first counter cnt_rx for counting the main axis displacement and a second counter cnt_tx for counting the slave axis displacement, and then extracting the target parameter from the cam table to characterize the length of the target segment path.
[0057] In this embodiment, after extracting the target parameters, the first counter used to count the spindle displacement and the second counter used to count the slave shaft displacement are updated based on the target parameters. It can be understood that the value in the first counter in this embodiment can also be understood as the spindle displacement count, and the value in the second counter can also be understood as the slave shaft displacement count.
[0058] Step S12: Determine the target number of pulses required to be output from the slave axis using the counting ratio between the current first counter and the current second counter.
[0059] In this embodiment, the value in the first counter is the spindle displacement count, and the value in the second counter is the slave axis displacement count. The target number of pulses to be output by the slave axis can be determined by using the counting ratio between the first counter and the current second counter.
[0060] Step S13: If a pulse input is detected on the main spindle, update the first counter, control the slave axis to output the target pulse several pulses, and update the second counter.
[0061] In this embodiment, an external device is pre-set to input pulses to the spindle. After continuously receiving pulses, the spindle outputs pulses to the FPGA. In this embodiment, the FPGA monitors the pulses output from the spindle. If the FPGA detects pulses input from the spindle, the spindle pulses need to be processed, triggering subsequent spindle pulse processing procedures. Specifically, in this embodiment, the spindle pulse processing procedure is as follows: update the first counter used to count the spindle displacement, then control the output of the target number of pulses determined in step S12, and then update the second counter.
[0062] In this embodiment, updating the first counter for counting spindle displacement and the second counter for counting slave axis displacement based on the target parameters may include: assigning the length of the target segment sub-path of the spindle to the first counter for counting spindle displacement, and assigning the length of the target segment sub-path of the slave axis to the second counter for counting slave axis displacement; correspondingly, updating the first counter if a pulse input is detected on the spindle, controlling the slave axis to output the target pulse several pulses and updating the second counter may include: decrementing the value in the first counter by one whenever a pulse input is detected on the spindle, and decrementing the value in the second counter by one whenever the slave axis is controlled to output a pulse.
[0063] In other words, in a specific implementation, after extracting the target parameter representing the length of the target segment path from the cam table, the length of the main spindle target segment path from the target parameter is directly assigned to the first counter used to count the main spindle displacement, and the length of the slave spindle target segment path is assigned to the second counter used to count the slave spindle displacement, thus initializing the first and second counters. At this time, the values in the first and second counters will be the maximum values when processing the current target parameter. Correspondingly, during subsequent pulse processing, whenever a pulse input is detected on the main spindle, the value in the first counter is decremented by one, and whenever the slave spindle is controlled to output a pulse, the value in the second counter is decremented by one. That is, during pulse processing, the values in the first and second counters will gradually decrease as the pulse processing progresses. In a specific implementation, the value in the second counter is decremented by one after each pulse output. Therefore, when processing each main spindle pulse, the value in the first counter is decremented by one, and after the slave spindle outputs a number of target pulses, the value in the second counter will decrease by the target pulse number.
[0064] In this embodiment, determining the target number of pulses to be output by the slave axis using the counting ratio between the current first counter and the current second counter, and controlling the slave axis to output the target number of pulses, may include: determining the pulse period width of the current slave axis using the counting ratio between the value in the current first counter and the value in the current second counter used to count the displacement of the slave axis, determining the target number of pulses to be output by the slave axis using the counting ratio, and then controlling the slave axis to output the target number of pulses according to the pulse period width of the current slave axis.
[0065] That is, in this embodiment, the pulse period width of the current slave axis is first determined based on the counting ratio between the values in the first counter and the second counter, then the target number of pulses to be output by the slave axis is determined, and finally the slave axis is controlled to output the target number of pulses according to the pulse period width of the slave axis.
[0066] Step S14: Determine whether the pulse processing for the target parameter has been completed based on the current counts of the first counter and the second counter.
[0067] In this embodiment, the value in the first counter corresponds to the spindle displacement count, and the value in the second counter corresponds to the slave axis displacement count. During the processing of the target parameter, as each spindle pulse processing cycle proceeds, the first and second counters are continuously updated. Based on the spindle displacement count and the slave axis displacement count, it can be determined whether the processing of the current target parameter has been completed.
[0068] In a specific implementation, after extracting the target parameter representing the length of the target segment sub-path from the cam table, the length of the main spindle target segment sub-path in the target parameter can be directly assigned to a first counter used to count the main spindle displacement, and the length of the slave axis target segment sub-path can be assigned to a second counter used to count the slave axis displacement. With the input of the main spindle pulse, the FPGA will complete a series of main spindle pulse processing steps, and the values in the first and second counters will gradually decrease during the pulse processing. Therefore, the step of determining whether the pulse processing for the target parameter has been completed based on the current counts of the first and second counters can include: determining whether the current counts of both the first and second counters are 0. That is, when the current counts of both the first and second counters are 0, it indicates that the processing for the current target parameter has been completed.
[0069] Step S15: If not completed, proceed to the step of determining the target number of pulses required to be output from the slave axis using the counting ratio relationship between the current first counter and the current second counter.
[0070] It is understood that in this embodiment, if the pulse processing for the target parameter is not completed based on the current counts of the first counter and the second counter, the FPGA will continuously use the current count ratio between the first counter and the second counter to determine the target number of pulses required to be output by the slave axis, and wait for the spindle to input pulses. If a pulse input is detected from the spindle, the first counter is updated, the slave axis is controlled to output the target number of pulses, and the second counter is updated. After each update of the second counter, that is, after each spindle pulse processing process is completed, it is determined whether the pulse processing for the target parameter has been completed based on the current counts of the first counter and the second counter. If it has not been completed, the above process is repeated until the current counts of the first counter and the second counter are values indicating that the pulse processing for the current target parameter has been completed. It is understood that if the current counts of the first counter and the second counter are values indicating that the pulse processing for the current target parameter has been completed, it means that the spindle has input all pulses corresponding to the current parameter into the FPGA and all spindle pulse processing processes for the current parameter have been completed.
[0071] Throughout the entire processing of this invention, it is necessary to ensure that no spindle pulse is missed. Therefore, in this embodiment, before extracting the target parameter representing the length of the target segment path from the cam table, it may further include: setting a third counter for calculating the number of spindle pulses that have not yet been processed, so that the third counter is updated when there is a pulse input on the spindle; correspondingly, updating the first counter if a pulse input on the spindle is detected may include: updating the first counter for counting spindle displacement when the value in the third counter is detected to be a value representing the number of unprocessed pulses on the spindle.
[0072] In a specific implementation, a third counter can be set to count the number of unprocessed pulses on the spindle. The initial value of the third counter is 0. Whenever a pulse is detected input to the FPGA from the spindle, the value of the third counter is incremented by one. The third counter always retains the accumulated processing result, which serves as the basis for determining whether there are any unprocessed spindle pulses. If the value of the third counter is not 0, it indicates that there are unprocessed pulses on the spindle. This triggers the updating of the first counter, controlling the slave axis to output the target number of pulses and updating the second counter, which is the same spindle pulse processing process as described above. When the slave axis finishes outputting the target number of pulses, the value of the third counter is decremented by one, indicating that the spindle pulse processing process for this time has ended and the number of unprocessed pulses on the spindle has decreased by one. It can be understood that if the current counts of both the first and second counters are 0, it indicates that the pulse processing for the current target parameter has been completed; if they are not both 0, it indicates that the pulse processing for the current target parameter has not been completed, and the value of the third counter continues to be monitored to continue processing the current target parameter.
[0073] In this embodiment, using the sub-path length as a parameter in the cam parameter table reduces FPGA resource usage and costs, thereby improving system stability and processing speed. Following the master spindle pulse, a slave spindle pulse is output for each master spindle pulse, employing an advanced slave spindle pulse output control algorithm. This significantly improves the synchronization and accuracy of the master and slave axes. Furthermore, using whether the current sub-path length has been traversed as the control criterion maximizes real-time performance and synchronization.
[0074] In this embodiment, a field-programmable gate array (FPGA) is used to extract target parameters representing the length of the target segment sub-path from the cam table. Based on these target parameters, a first counter for counting the master axis displacement and a second counter for counting the slave axis displacement are updated. The target number of pulses required to be output by the slave axis is determined using the counting ratio between the current first and second counters. If a pulse input is detected on the master axis, the first counter is updated, the slave axis is controlled to output the target number of pulses, and the second counter is updated. The pulse processing for the target parameter is determined based on the current counts of the first and second counters. If not, the process jumps to the step of determining the target number of pulses required to be output by the slave axis using the counting ratio between the current first and second counters. In this way, by extracting the target parameters representing the length of the target segment sub-path to process the cam table parameters, the consumption of logic resources on the FPGA can be greatly reduced, costs can be lowered, and system stability and processing speed can be improved. Furthermore, by setting a counter, this invention uses the completion of the current sub-path length as the control criterion to achieve real-time control of the pulse, enabling the slave axis to respond quickly and accurately to the input of the master axis, improving master-slave synchronization performance, and ensuring the stability and speed performance while maximizing the guarantee of accuracy and real-time performance.
[0075] Figure 2 A flowchart illustrating a specific cam control method provided in this application embodiment. See also... Figure 2 As shown, the method includes:
[0076] Step S21: When a cam parameter processing command is received, the target parameter for characterizing the length of the target segment path is extracted from the cam table, and the first counter for counting the main shaft displacement and the second counter for counting the slave shaft displacement are updated based on the target parameter.
[0077] Under normal circumstances, when a cam parameter processing instruction is received, P[0] is first extracted from the cam table as the target parameter, and then the cam parameters are processed in sequence according to the subsequent steps in this embodiment.
[0078] Step S22: Use the value in the first counter at present to the value in the second counter at present used to count the displacement of the shaft as a first ratio, and use the value in the second counter at present to the value in the first counter at present as a second ratio.
[0079] It is understood that in this embodiment, a first ratio of the current master spindle subpath displacement count to the slave spindle subpath displacement count and a second ratio of the slave spindle subpath displacement count to the master spindle subpath displacement count are predefined.
[0080] Step S23: Determine the pulse period width of the slave axis using the period width of the most recent pulse received by the main axis and the first ratio, and determine the target number of pulses to be output by the slave axis corresponding to the main axis using the second ratio.
[0081] In this embodiment, the pulse period width of the slave axis is determined based on the period width of the most recent pulse received by the master axis and the first ratio, that is, based on the period width of the most recent pulse received by the master axis and the value obtained by comparing the current value in the first counter with the current value in the second counter. The target number of pulses to be output by the slave axis is determined based on the second ratio, that is, based on the value calculated by comparing the current value in the second counter with the current value in the first counter. In a specific implementation, if the pulse period width of the master axis is denoted as Txk, the pulse period width of the slave axis is denoted as Tyk, the first ratio is denoted as PPk, and the second ratio is denoted as PPki, then Tyk = Txk * PPk, and nk = PPki pulses (rounded to the nearest integer).
[0082] Step S24: If a pulse input is detected on the main spindle, update the first counter, control the slave axis to output the target number of pulses according to the pulse period width of the current slave axis, and update the second counter.
[0083] In this embodiment, the equivalent spindle pulses can be issued sequentially according to the corresponding cycle width, where the equivalent spindle pulses refer to the number of slave axis pulses corresponding to one spindle pulse. Therefore, the synchronization and accuracy of the master and slave axes can be greatly improved.
[0084] Step S25: Based on the current counts of the first counter and the second counter, determine whether the pulse processing for the target parameter has been completed. If not, proceed to the step of determining the target number of pulses to be output from the shaft using the current count ratio between the first counter and the second counter. If completed, determine whether the target parameter is the last parameter in the cam table ordered in a preset order.
[0085] In this embodiment, the value in the first counter is equivalent to the spindle displacement count, and the value in the second counter is equivalent to the slave axis displacement count. Based on the spindle displacement count and the slave axis displacement count, it can be determined whether the processing of the current target parameter has been completed. If it has not been completed, the relevant process in step S15 will be performed. If it has been completed, it is determined whether the current target parameter is the last parameter P[n] in the P[k] sort (i.e., P[0], P[1]...P[n]).
[0086] Step S26: If the target parameter is not the last parameter, then the next parameter of the target parameter is taken as the current target parameter and the process jumps to the step of extracting the target parameter used to characterize the length of the target segment path from the cam table, until all the target parameters in the cam table have been processed.
[0087] In this embodiment, if the target parameter being processed is P[n], it means that the processing task for this parameter processing command has been completed, and the system waits for the next parameter processing command to start the next round of cam table parameter processing task; if the target parameter being processed is not P[n], the next parameter of the target parameter is taken as the current target parameter and the system jumps to the step of extracting the target parameter used to characterize the length of the target segment path from the cam table, until all the target parameters in the cam table have been processed.
[0088] That is, in the specific implementation of this embodiment, after receiving the cam parameter processing instruction, P[0] in the cam table can be directly used as the first target parameter to complete the parameter processing for P[0]. After the parameter processing for P[0] is completed, P[1] is determined as the next target parameter according to the sorting of P[k] in the cam table for processing. Then, the target parameters are extracted and processed in sequence according to the sorting order of P[2], P[3]...P[n] until P[n] is processed. It can be understood that when P[n] is processed, it indicates that the parameter processing for the cam table in this round is completed, and the next cam parameter processing instruction can be waited for.
[0089] It is understandable that the above-described process of sequentially processing the P[k] parameter can be understood as a process of cyclically processing the P[k] parameter. In a specific implementation, the above-described process of cyclically processing the P[k] parameter can be implemented using a counter. That is, in a specific implementation, when a parameter processing instruction is received, while setting a first counter cnt_rx for counting the spindle displacement and a second counter cnt_tx for counting the slave shaft displacement, a fourth counter k for counting the sub-path segment order is set, and the value of the fourth counter is set to 0. In each loop, based on the value of the fourth counter, it can be determined whether the target parameter is the last parameter in the cam table sorted in a preset order. If k is not the final parameter, then k++ is used to perform the subsequent parameter extraction and parameter processing process.
[0090] In this embodiment, using the sub-path length as a parameter in the cam parameter table reduces FPGA resource usage and costs, thereby improving system stability and processing speed. Precise pulse processing down to the individual spindle is achieved through a counter, enabling control of master-slave pulse transmission and reception. This invention follows the spindle pulse, sending the equivalent spindle pulse of the current pulse sequentially according to the corresponding period width, ensuring that a slave pulse is output for every incoming spindle pulse. An advanced slave pulse output control algorithm is employed, significantly improving the synchronization and accuracy of the master and slave axes. This invention uses whether the current sub-path length has been traversed as the control criterion, maximizing real-time performance and synchronization. Furthermore, this embodiment includes a cyclic processing procedure for the P[k] parameter. Upon receiving a cam parameter processing command, all parameters in the cam table are automatically processed sequentially, stopping after processing and awaiting the next cam parameter processing command. This automates cam parameter processing, ensuring high efficiency in cam processing.
[0091] like Figure 3 This invention provides a detailed operation flowchart for application in FPGA, and the specific process is as follows:
[0092] At the control entry point, the FPGA monitors and waits for the start of a new round of cam parameter processing. Once the start is successful, it jumps to the first step.
[0093] The first step involves setting up four counters: a first counter `cnt_rx` for counting spindle displacement, a second counter `cnt_tx` for counting slave axis displacement, a third counter `cnt_pulse` for counting the number of unprocessed spindle pulses, and a fourth counter `k` for counting the sub-path segment sequence. Then, initialize `cnt_pulse = 0` and `k = 0`. Next, set five variables: `Txk`, `Tyk`, `PPk`, `PPki`, and `nk`. `Txk` is the calculated spindle pulse period width for sub-path X[k] segment, `Tyk` is the calculated slave axis pulse period width for sub-path Y[k] segment, `PPk` is the ratio of the numerator to the denominator of parameter `P[k]`, `PPki` is the ratio of the denominator to the numerator of parameter `P[k]`, and `nk` is the number of slave axis pulses required to output for the currently processed spindle pulse. Proceed to the second step.
[0094] The second step involves the FPGA retrieving the k-th sub-path P[k] = (X[k] / Y[k]), assigning cnt_rx = X[k] and cnt_tx = Y[k]. Then, proceed to the third step.
[0095] Third step, count PPk = cnt_rx / cnt_tx, PPki = cnt_tx / cnt_rx. Jump to fourth step.
[0096] The fourth step is to determine if cnt_pulse is greater than 0. If cnt_pulse > 0, proceed directly to the fifth step. If cnt_pulse = 0, wait to monitor the spindle pulse; if a spindle pulse is detected, proceed to the fifth step.
[0097] Step 5: Use counter cnt_rx-- to calculate the pulse period width Tyk = Txk * PPk of the slave axis, and determine the number of pulses required for the slave axis to output as nk = PPki (rounded to the nearest integer). Jump to step 6.
[0098] Step 6: Output nk slave axis pulses according to the Tyk cycle. cnt_tx is decremented after each slave axis pulse is output. After outputting nk slave axis pulses, cnt_pulse is decremented, and then proceed to step 7.
[0099] Step 7: Determine the values of cnt_rx and cnt_tx. If cnt_rx = 0 and cnt_tx = 0, then parameter P[k] can be considered to have been processed, and proceed to step 8; otherwise, parameter P[k] has not been processed, and you need to jump back to step 3.
[0100] Step 8: Determine if all parameters of the cam table have been processed. If k is already at its maximum value, the current round of processing ends, and the system jumps back to the control entry point to wait for the next round of cam table execution. If k has not reached its maximum value, increment k and jump back to step 2.
[0101] In addition to the aforementioned control operations, a parallel control path also needs to be set up to calculate the number of received spindle pulses and the period width of the most recent spindle pulse. If a pulse is received, cnt_pulse++ is executed, and the period width of that spindle pulse is recorded in Txk.
[0102] like Figure 4 The diagram shows a structural schematic of the present invention. The algorithm control module of the cam control method proposed in this invention is located inside an FPGA, surrounded by a cam table and a host computer processor. The cam table can be located inside or outside the FPGA (for example, it can also be located inside the processor), but most commonly it is located inside the FPGA. The host computer processor can be implemented by a CPU (Central Processing Unit), ARM (Advanced RISC Machines), MCU (Microcontroller Unit), DSP (Digital Signal Processor), or other processors. The spindle pulse is input to the control module of this invention, processed, and then output as a slave axis pulse.
[0103] See Figure 5As shown in the figure, this application discloses a cam control device, which may specifically include:
[0104] The parameter extraction module 11 is used to extract target parameters from the cam table to characterize the length of the target segment path, and update the first counter for counting the main axis displacement and the second counter for counting the slave axis displacement based on the target parameters.
[0105] The pulse count determination module 12 is used to determine the target number of pulses required to be output from the slave axis by utilizing the counting ratio relationship between the current first counter and the current second counter.
[0106] The pulse output module 13 is used to update the first counter if a pulse input is detected on the main spindle, control the slave axis to output the target pulse several pulses and update the second counter;
[0107] The pulse processing judgment module 14 is used to determine whether the pulse processing for the target parameter has been completed based on the current counts of the first counter and the second counter;
[0108] The jump execution module 15 is used to jump to the step of determining the target number of pulses required to be output from the slave axis by utilizing the counting ratio relationship between the current first counter and the current second counter if the step is not completed.
[0109] This invention utilizes a field-programmable gate array (FPGA) to extract target parameters characterizing the length of a target segment path from a cam table. Based on these target parameters, it updates a first counter for counting spindle displacement and a second counter for counting slave axis displacement. The target number of pulses required to be output by the slave axis is determined using the current counting ratio between the first and second counters. If a pulse input is detected on the spindle, the first counter is updated, the slave axis is controlled to output the target number of pulses, and the second counter is updated. The current counts of the first and second counters are used to determine whether pulse processing for the target parameters has been completed. If not, the process jumps to the step of determining the target number of pulses required to be output by the slave axis using the current counting ratio between the first and second counters. In this way, by extracting the target parameters characterizing the length of the target segment path to process the cam table parameters, the consumption of logic resources on an FPGA can be greatly reduced, costs can be lowered, and system stability and processing speed can be improved. Furthermore, by setting a counter, this invention uses the completion of the current sub-path length as the control criterion to achieve real-time control of the pulse, enabling the slave axis to respond quickly and accurately to the input of the master axis, improving master-slave synchronization performance, and ensuring the stability and speed performance while maximizing the guarantee of accuracy and real-time performance.
[0110] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of use of this application.
[0111] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a display screen 24, an input / output interface 25, a communication interface 26, and a communication bus 27. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the cam control method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0112] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 26 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0113] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored on it can include an operating system 221, computer programs 222, and virtual machine data 223, etc. The virtual machine data 223 can include various types of data. The storage method can be temporary storage or permanent storage.
[0114] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the cam control method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0115] Furthermore, this application also discloses a computer-readable storage medium, which includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, magnetic disks, optical disks, or any other form of storage medium known in the art. The computer program, when executed by a processor, implements the aforementioned cam control method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0116] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatuses disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section. Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of functionality. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0117] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0118] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0119] The cam control method, apparatus, device, and storage medium provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A cam control method characterized by, The application is applied to a field programmable logic gate array, comprising: extracting a target parameter for representing the length of a target segment sub-path from a cam table, and updating a first counter for counting the displacement of a main shaft and a second counter for counting the displacement of a slave shaft based on the target parameter; determining the target number of pulses required to be output by the slave shaft by using the ratio of the counts between the current first counter and the current second counter; wherein the value in the current second counter is the second ratio compared with the value in the current first counter; the target number of pulses required to be output by the slave shaft is determined according to the second ratio; updating the first counter if the pulse input of the main shaft is monitored, controlling the slave shaft to output the target number of pulses and updating the second counter; wherein the process of updating the first counter is to decrease the value in the first counter by one each time the pulse input of the main shaft is monitored, and the process of updating the second counter is to decrease the value in the second counter by one each time the slave shaft outputs a pulse; judging whether the pulse processing for the target parameter is completed based on the current counts of the first counter and the second counter; if not, jumping to the step of determining the target number of pulses required to be output by the slave shaft by using the ratio of the counts between the current first counter and the current second counter.
2. The cam control method according to claim 1, characterized by, the extracting of the target parameter for representing the length of a target segment sub-path from a cam table, comprising: extracting the target parameter for representing the length of a target segment sub-path from a cam table when a cam parameter processing command is received; wherein the length of the target segment sub-path is determined based on the length of the main shaft target segment sub-path and the length of the slave shaft target segment sub-path.
3. The cam control method according to claim 2, characterized by, the updating of the first counter for counting the displacement of a main shaft and the second counter for counting the displacement of a slave shaft based on the target parameter, comprising: assigning the length of the main shaft target segment sub-path to the first counter for counting the displacement of a main shaft, and assigning the length of the slave shaft target segment sub-path to the second counter for counting the displacement of a slave shaft.
4. The cam control method according to claim 1, characterized by, after the judging whether the pulse processing for the target parameter is completed based on the current counts of the first counter and the second counter, further comprising: if the pulse processing for the target parameter is completed, judging whether the target parameter is the last parameter in the cam table in a preset order; if the target parameter is not the last parameter, taking the next parameter of the target parameter as the current target parameter and jumping to the step of extracting the target parameter for representing the length of a target segment sub-path from a cam table, until all the target parameters in the cam table are processed.
5. The cam control method according to claim 1, characterized by, the determining of the target number of pulses required to be output by the slave shaft by using the ratio of the counts between the current first counter and the current second counter, comprising: determine a current pulse period width of the slave shaft by using a count ratio relationship between a value in the first counter and a value in a second counter currently used for counting displacement of the slave shaft, and determine a target number of pulses required to be output by the slave shaft by using the count ratio relationship; correspondingly, the controlling the slave shaft to output the target number of pulses comprises: controlling the slave shaft to output the target number of pulses according to the pulse period width of the current slave shaft.
6. The cam control method according to claim 5, characterized by, the determining the current pulse period width of the slave shaft by using the count ratio relationship between the value in the first counter and the value in the second counter currently used for counting displacement of the slave shaft comprises: obtaining a value as a first ratio by comparing the value in the first counter with the value in the second counter currently used for counting displacement of the slave shaft; determining the pulse period width of the slave shaft by using a period width of a last pulse received by the main shaft and the first ratio.
7. The cam control method according to any one of claims 1 to 6, characterized by, before the extracting the target parameter for representing a length of the target segment sub-path from the cam table, further comprising: setting a third counter for counting a number of pulses of the main shaft which have not been processed, so as to update the third counter when there is a pulse input of the main shaft; correspondingly, the updating the first counter if it is monitored that there is a pulse input of the main shaft comprises: updating the first counter for counting displacement of the main shaft if it is monitored that the value in the third counter is a value representing a number of pulses of the main shaft which have not been processed.
8. A cam control device characterized by comprising: applied to a field programmable logic gate array, comprising: a parameter extraction module, configured to extract a target parameter for representing a length of a target segment sub-path from a cam table, and update a first counter for counting displacement of a main shaft and a second counter for counting displacement of a slave shaft based on the target parameter; a pulse number determination module, configured to determine a target number of pulses required to be output by the slave shaft by using a count ratio relationship between the first counter and the second counter; a pulse output module, configured to update the first counter if it is monitored that there is a pulse input of the main shaft, control the slave shaft to output the target number of pulses, and update the second counter; a pulse processing judgment module, configured to judge whether pulse processing for the target parameter has been completed based on current counts of the first counter and the second counter; a jump execution module, configured to jump to a step of determining the target number of pulses required to be output by the slave shaft by using the count ratio relationship between the first counter and the second counter if the pulse processing for the target parameter has not been completed.
9. An electronic device, comprising: comprising a processor and a memory; wherein the processor implements a cam control method as claimed in any one of claims 1 to 7 when executing a computer program saved in the memory.
10. A computer-readable storage medium, characterized in that, for storing a computer program; wherein the computer program implements a cam control method as claimed in any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
Electronic cam control system of programmable logic controller and electronic cam control method
CN102650862A
Electronic cam controller
JP2011221850A