Summary of the invention
The invention provides a kind of closed loop control method for stepping motor, be intended to the mode that the common close-loop control mode of solution compares opened loop control stepping motor, cost often needs to increase several times, and can not determine the movement angle of motor due to other motor, the control effects of realizing ideal if want, control algolithm is the problem such as very complicated often.
The object of the present invention is to provide a kind of closed loop control method for stepping motor, the method comprises:
Position detecting element and the position signalling of trigger equipment to stepping motor is utilized to feed back;
Anti-tampering process filtering process is carried out to the positional information that each road collects;
The current count value of step motor position information and the count value of benchmark are compared, the error amount drawn and actual count value is carried out arithmetical operation, and revises actual count value.
Another object of the present invention is to provide a kind of closed-loop control system for stepping motor, this closed-loop control system comprises:
For carrying out the position detecting module of position feedback,
Export with described position detecting module and be connected, the positional information for collecting each road carries out the hardware filtering module of anti-tampering process;
Export with described hardware filtering module and be connected, for carrying out motor counting and correction, the algoritic module that count value can be returned when needing to preserve motor current state;
Export with described algoritic module and be connected, running synchronous pulse signal and the count signal of counting direction signal for providing for algoritic module with motor, carrying out motor counting to make algoritic module according to count signal; When motor status preserved by needs, the main control module of the information returned by algoritic module can be received.
The present invention realizes by analog encoder the method improving control precision, and one week of continuous rotation installs multiple position detecting device, and installation quantity is more, and counting error compensates will be more timely, and count value is more accurate, and control precision and positioning precision also can be higher; The seizure of position detection signal is adopted and carries out along detecting the mode of interrupting, ensure that the promptness of seizure, accuracy; By the filtering process of software, twice, hardware, make the signal that captures more accurate, avoid the signal caused due to voltage fluctuation, load variations etc. and gather by mistake; Utilize the count signal that main control module provides, independently carry out motor and run step number record, only when needs, count information is returned, share the task of main control module, more complicated functional module can be increased in main control module, or select the more cheap master controller that can meet the demands, reduce system power dissipation, extend working time.Because the current type of drive research to stepping motor is comparatively ripe, the control precision of itself can reach very high requirement, for the control precision compensated caused by structural factor or environmental factor declines, only need adopt method of the present invention, to compare the closed-loop control system of other encoders or servomotor, cost of the present invention is low, stability is high, service life of equipment is longer, system building is simple and convenient, without the need to complicated algorithm, operability is high, control is more simple and easy.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, and be not used in restriction invention.
Fig. 1 shows the realization flow of the closed loop control method for stepping motor that the embodiment of the present invention provides.
For a closed loop control method for stepping motor, the method comprises:
In step S101, position detecting element and the position signalling of trigger equipment to stepping motor is utilized to feed back;
In step s 102, the positional information collected each road carries out anti-tampering process filtering process;
In step s 103, the current count value of step motor position information and the count value of benchmark are compared, the error amount drawn and actual count value are carried out arithmetical operation, and revises actual count value.
In embodiments of the present invention, the implementation method utilizing position detecting element and the positional information of trigger equipment to stepping motor to feed back is:
By at least one independently position detecting element be installed on circumferentially fixing, stepping motor rotating shaft is installed a trigger equipment, make trigger equipment with rotating shaft continuous rotation, when trigger equipment arrival can cause detecting element to occur the position of state variation, utilize the detection port of single-chip microcomputer the position signalling of stepping motor can be detected.
In embodiments of the present invention, the computational methods of the count value residing for position detecting element are: choosing the position detecting element present position be installed on uniformly on circumference is counting original position C
1=n
0, utilize stepping motor step angle θ
1, reduction box speed reducing ratio η
1and drive system compares η
2, obtain stepping motor and often turn and move a step, the actual angle value θ turned over of load rotating shaft,
θ=θ
1/(η
1×η
2);
Count value C residing for other position detecting elements
ncan determine,
C
n=C
n-1+(360/θ)/N。
In embodiments of the present invention, the implementation method that the positional information collected each road carries out anti-tampering process filtering process is:
Adopt C-R-C π type filter circuit, by the interference sections filtering in the position signalling of stepping motor.
In embodiments of the present invention, the current count value of step motor position information and the count value of benchmark is compared, the error amount drawn and actual count value are carried out arithmetical operation, and the implementation method revising actual count value is:
Take to interrupt detecting to the response of each road position signalling;
The each road position signalling interrupting detecting is carried out the anti-tampering process of secondary;
After utilizing process, the data of the active position information of feedback carry out the correction of motor counting error calculating.
In embodiments of the present invention, this closed loop control method also comprises further:
When receiving the instruction needing to preserve the current running status of motor, count value can be carried out output by communication and preserving.
Fig. 2 shows the structure of the closed-loop control system for stepping motor that the embodiment of the present invention provides.For convenience of explanation, illustrate only part related to the present invention.
For a closed-loop control system for stepping motor, this closed-loop control system comprises:
For carrying out the position detecting module 21 of position feedback,
Export with described position detecting module and be connected, the positional information for collecting each road carries out the hardware filtering module 22 of anti-tampering process;
Export with described hardware filtering module and be connected, for carrying out motor counting and correction, the algoritic module 23 that count value can be returned when needing to preserve motor current state;
Exporting with described algoritic module and be connected, running synchronous count signal for providing for algoritic module with motor, carry out motor counting to make algoritic module according to count signal; When motor status preserved by needs, the main control module 24 of the information returned by algoritic module can be received.
As a preferred version of the embodiment of the present invention, described algoritic module 23 also comprises:
Export with described hardware filtering module and be connected, for responding the interruption detection module 231 of each road position feed back signal;
Export with described interruption detection module and be connected, for the event of interrupting detecting being carried out the software filtering module 232 of the anti-tampering process of secondary;
Export with described software filtering module and be connected, for the data after software filtering resume module being carried out the correction module 233 of motor counting error calculating;
Exporting with described correction module and be connected, for carrying out motor counting according to the motor count signal received, and utilizing error amount correction motor count value; When the running status that system needs preservation motor current, count value can be carried out the counting module 234 returned by communication.
In embodiments of the present invention, the position detecting element 1...N used in position detecting module 21 adopts optocoupler and catch (or Hall element and magnet), to ensure during installation catch can accessible vertically through each optocoupler part, if the standard meter numerical value of detecting element present position, each position is C
1.。。C
nif the installation of position detecting element can be very accurate, be then installed on uniformly on circumference by element as far as possible, such system only need define a position detecting element present position for counting original position C
1=n
0(generally for and prevent counting from overflowing, counting initial value n
0usually be set to slightly larger than circumference counting total value 1/2 nonzero integer), utilize motor step elongation θ
1, reduction box speed reducing ratio η
1and drive system compares η
2, obtain motor and often turn and move a step, the actual angle value θ turned over of load rotating shaft,
θ=θ
1/(η
1×η
2);
Count value C so residing for other position detecting elements
ncan determine,
C
n=C
n-1+(360/θ)/N;
Just the count value after each position corrects can be set like this without the need to carrying out the self-inspection of motor counting.
If the installation accuracy of element can not ensure, then system needs circumferentially circle after powering on certainly, using the count value at each position detecting element gained as the count value after correction.
Hardware filtering module 22 adopts C-R-C π type filter circuit, by the interference sections filtering in signal, ensures that interruptive port detects the accuracy along signal, and the interference edge of reducing due to misoperation or fluctuation generation is gathered by mistake, has influence on control precision.
The realization flow that interruption detection module 231 carries out interrupting detecting is: be set to along detecting, and the level after edge produces keeps producing interrupt response afterwards sometime, utilizes the resource of single-chip microcomputer to improve along accuracy of detection.Interrupt when a certain position detecting element produces, after then entering interruption subroutine, arrange filtering inspection and start, filtering check mark checkstart carries out state change in position, the reference count value of motor count value count initialization position detecting element position for this reason, namely
count=C
n;
And current base count value and current count value are asked for difference, be stored in error variance error.
Fig. 3 shows and carries out the realization flow that software filtering module 232 carries out software filtering, if detect that in primitive recursive function a certain position detecting element creates filtering check mark position checkstart state and changes, whether the level that then circulation T time detects interruptive port continues to keep the level value along after generation, judges that whether the interruption produced is effective with this.After each filtering is verified, to be all filtering test ending by filtering check mark position change state.
Fig. 4 shows the realization flow that correction module 233 carries out correcting: if along the level value retention time long enough after producing, then assert that current is correct along gathering, then motor count value keeps current value; If the level value retention time after producing is very short, then it is wrong for assert that current edge gathers, then motor count value will deduct error numerical value, comes, guarantee the accuracy counted by correcting corrigendum by mistake.
In counting module 234, often receive the counting direction from main control module 24 and counting pulse signal, just carry out the amendment of count value count, after receiving the count value read requests from main control module 24, current count value count is returned to main control module 24 by communication port, carries out other function application.
In main control module 24, after motor receives action command, rotate according to a certain frequency, often turn and move a step, namely a level skip signal is sent to the counting module 234 in algoritic module 23, the triggering signal counted is carried out as counting module 234, simultaneously using the level of some IO ports as counting direction signal, when needs store motor current location information time, pass through communication port, send request signal to counting module 234, and received the count information returned by counting module 234 by communication port, carry out other function application.
The beneficial effect of the embodiment of the present invention is:
1, adopt, in stroke, multiple position detecting element is installed, compensate in time, revise counting error, improve control precision;
2, adopt the seizure carrying out position signalling along the interrupt mode detected, through twice filtering process of hardware, software, make the triggering of capture events more timely, accurate, avoid and signal during misoperation is gathered;
3, adopt independently single-chip microcomputer to carry out motor and run the record of step number, by the share tasks of main control module, slot milling and time carry out the process of other functions, improve chip utilization ratio, reduce system power dissipation, extend the service time of chip;
4, to compare the closed-loop control system of other encoders or servomotor, cost of the present invention is low, stability is high, service life of equipment is longer, system building is simple and convenient, without the need to complicated algorithm, operability is high, it is more simple and easy to control.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.