Summary of the invention
In view of this, may be implemented simultaneously the purpose of the present invention is to provide a kind of motor control algorithms to multiple motors
It is controlled in real time, improves the speed of service and accuracy of motor.
The embodiment of the invention provides a kind of motor control methods, which comprises
Trigger signal is detected every the period 1, and according to the operation shape at the trigger signal more new motor current time
State;
Every the actual position information of second round detection motor, and obtain motor target position information;And
The fortune of next second round motor is updated according to the actual position information and the target position information
Row state;
Wherein, the second round is the integral multiple of the period 1, and the target position information is next described
The location information of second round motor.
Preferably, the trigger signal includes reset signal, detecting liquid level signal, emergent stop signal and error signal;
The operating status according to the trigger signal more new motor current time is, is emergency stop in response to trigger signal
Signal and error signal stop motor operation.
Preferably, it every the actual position information of second round detection motor, and obtains motor target position information and includes:
The actual position information of motor is obtained by the encoder connecting with the motor;And
Target position information is obtained according to the running track of scheduled motor, the running track includes each moment motor
Location.
Preferably, next second round electricity is updated according to the actual position information and the target position information
The operating status of machine includes:
The operation speed of next second round motor is determined according to the actual position information and target position information
Degree;And
Corresponding pulse signal is obtained according to the speed of service of the motor, the pulse signal is for controlling motor fortune
Row.
Preferably, next second round electricity is updated according to the actual position information and the target position information
The operating status of machine includes:
Compare the theoretical position information and the actual position information at current time, the theoretical position information is according to institute
State location information of the motor at current time of running track acquisition;And
It is inconsistent in response to the theoretical position information and the actual position information, issue error signal.
Preferably, next second round motor is obtained according to the actual position information and target position information
The speed of service includes:
Obtain the deviation of the actual position information and target position information;And
The speed of service of next second round motor is calculated according to the deviation.
Preferably, the method also includes:
Receive the control signal of host computer;And
According to the running track of the control signal acquisition motor, and control motor operation.
The technical solution of the embodiment of the present invention is by detecting trigger signal every the period 1, and according to the trigger signal
The more operating status at new motor current time then every the actual position information of second round detection motor, and obtains motor
Target position information updates next second round motor according to the actual position information and the target position information
Operating status.Thus, it is possible to realize while controlled in real time multiple motors, the speed of service of motor and accurate is improved
Degree.
Specific embodiment
Below based on embodiment, present invention is described, but the present invention is not restricted to these embodiments.Below
Based on embodiment, present invention is described, but the present invention is not restricted to these embodiments.Below to of the invention
It is detailed to describe some specific detail sections in datail description.Part without these details for a person skilled in the art
Description the present invention can also be understood completely.In order to avoid obscuring essence of the invention, well known method, process, process, element
There is no narrations in detail with circuit.
In addition, it should be understood by one skilled in the art that provided herein attached drawing be provided to explanation purpose, and
What attached drawing was not necessarily drawn to scale.
Unless the context clearly requires otherwise, "include", "comprise" otherwise throughout the specification and claims etc. are similar
Word should be construed as the meaning for including rather than exclusive or exhaustive meaning;That is, be " including but not limited to " contains
Justice.
In the description of the present invention, it is to be understood that, term " first ", " second " etc. are used for description purposes only, without
It can be interpreted as indication or suggestion relative importance.In addition, in the description of the present invention, unless otherwise indicated, the meaning of " multiple "
It is two or more.
Fig. 1 is the flow chart of motor control method of the embodiment of the present invention.As shown in Figure 1, motor control algorithms include as follows
Step:
Step S100, trigger signal is detected every the period 1, and according to the trigger signal more new motor current time
Operating status.
Preferably, the trigger signal includes reset signal, detecting liquid level signal, emergent stop signal and error signal.
Preferably, the operating status according to the trigger signal more new motor current time is to believe in response to triggering
Number be emergent stop signal and error signal, stop motor operation.
Step S200, every the actual position information of second round detection motor, and motor target position information is obtained.
Preferably, it every the actual position information of second round detection motor, and obtains motor target position information and includes:
The actual position information of motor is obtained by the encoder connecting with the motor;And
Target position information is obtained according to the running track of scheduled motor, the running track includes each moment motor
Location.
Step S300, next second round is updated according to the actual position information and the target position information
The operating status of motor.
Wherein, the second round is the integral multiple of the period 1, and the target position information is next described
The location information of second round motor.
Preferably, next second round electricity is updated according to the actual position information and the target position information
The operating status of machine includes:
The operation speed of next second round motor is determined according to the actual position information and target position information
Degree;And
Corresponding pulse signal is obtained according to the speed of service of the motor, the pulse signal is for controlling motor fortune
Row.
Preferably, next second round electricity is updated according to the actual position information and the target position information
The operating status of machine includes:
Compare the theoretical position information and the actual position information at current time, the theoretical position information is according to institute
State location information of the motor at current time of running track acquisition;And
It is inconsistent in response to the theoretical position information and the actual position information, issue error signal.
Preferably, next second round motor is obtained according to the actual position information and target position information
The speed of service includes:
Obtain the deviation of the actual position information and target position information;And
The speed of service of next second round motor is calculated according to the deviation.
Preferably, the method also includes:
Receive the control signal of host computer;And
According to the running track of the control signal acquisition motor, and control motor operation.
The above method in such a way that round-robin algorithm and motor step curve motion algorithm combine to motor into
Row control.It specifically can refer to Fig. 2 and Fig. 3.
Fig. 2 is the schematic diagram of round-robin algorithm of the embodiment of the present invention.As shown in Fig. 2, every period 1 T1 processing
Trigger signal, the trigger signal include reset signal, detecting liquid level signal, emergent stop signal, error handle signal etc., figure
Middle period 1 T1=t2-t1.Meanwhile an actual position information is read from encoder every second round T2, and combine
Target position information after next second round T2 is once calculated, and according to calculated result, updates motor control pulse letter
Number, second round T2=t11-t1 in figure.
The second round T2 is the integral multiple of the period 1 T1.In an optional implementation, T1 is
1ms, T2 10ms.That is, every 1ms carries out the processing of a trigger signal, thus can most timely to the external triggered time
Response, meanwhile, every 10ms reads an actual position information from encoder.
As a result, by the mechanism of round-robin, real-time control can be carried out to multiple motors, to multiple I/O signals into
Row real-time monitoring improves the stability of system.
Fig. 3 is the schematic diagram of motor step curve motion algorithm of the embodiment of the present invention.As shown in figure 3, the operation rail of motor
Mark is step curve, is in accelerated motion state in t3-t5 period motor, in the t5-t6 period, motor is in uniform motion
State, in the t6-t7 period, motor is in retarded motion state, wherein second round T2=t4-t3.It is with second round T2
Running track can be divided into multiple fritters by unit, and the area of each fritter is exactly the displacement of targets within second round, often
Second round carries out once-through operation, obtains target position information according to running track, the target position information is next the
The location information of two cycles motor.Then the deviation of target position information and the actual position information obtained from encoder is calculated,
The speed of next second round motor is calculated, and is converted into pulse frequency parameter, generates pulse signal.And then more new motor
Operating status.
The present embodiment is realized by way of being combined according to round-robin algorithm and motor step curve motion algorithm
Simultaneously multiple motors are carried out with the motion control of real-time position and speed, motor acceleration and deceleration are more steady, and operation is relatively reliable,
Give full play to motor speed advantage.
In an optional implementation, can by the above method to the motor in full-automatic immunohistochemical staining machine into
Row control.It is specific as follows:
Fig. 4 is the structural schematic diagram of control system of the embodiment of the present invention.As shown in figure 4, full-automatic immunohistochemical staining machine
Control system 1 include core board 11, it is expansion board 12, bus interface 13, detecting liquid level plate 14, multiple optoelectronic switches 15, multiple
Hall switch 16, multiple valves 17, multiple encoders 18 and multiple motors 19.The control system 1 can pass through C bus interface 13
Host computer 2 is connected, the control signal of host computer 2 is received, is run according to control signal control motor 19.
In the present embodiment, core board 11 includes first control unit 111 and the second control unit 112.First control
Unit 111 processed and the second control unit 112 realize the control function to complete machine kinematic system.
In the present embodiment, expansion board 12 includes multiple valve driving units 123, multiple electric-motor drive units 125 and multiple
Interface.The multiple interface includes bus 121, multiple optocouplers 122, multiple high speed photo couplings 124.
In the present embodiment, first control unit 111 or the second control unit 112 pass through optocoupler 122 or high speed photo coupling 124
It is connect with other components in the control system 1.Specifically, optocoupler full name is photo-coupler, photoisolator or photoelectricity coupling
Clutch.It is the device for carrying out transmission telecommunications number using light as medium, usually photophore (infrared light-emitting diode LED) and light-receiving device
(photosensitive semiconductor pipe, photo resistance) is encapsulated in same shell.When input terminal power up signal, photophore emits beam, light
Device receives just to generate photoelectric current after light, flows out from output end, to realize the conversion of " electricity-light-electricity ".With volume
It is small, the service life is long, contactless, strong antijamming capability, insulate between output and input, the advantages that one-way transmission signal, to input, defeated
Electric signal has good buffer action out.High speed photo coupling has can be with fast response compared to common optical coupler.
Specifically, first control unit 111 is connect by bus 121 with the bus interface 13, passes through optocoupler 122 and institute
Detecting liquid level plate 14, multiple optoelectronic switches 15, multiple Hall switch 16 and multiple valves 17 is stated to connect.Second control unit 112 is logical
It crosses high speed photo coupling to connect with multiple encoders 18, be connect by optocoupler with multiple motors.
Preferably, the bus 121 is CAN (Controller Area Network, controller local area network) bus.
CAN is the serial communication protocol of ISO International standardization, is a kind of serial communication for effectively supporting distributed AC servo system or real-time control
Network has the characteristics that structure is simple, real-time is good, high reliablity.In the present embodiment, full-automatic immunohistochemistry can be contaminated
Color machine, CAN interface and host computer and communication equipment form typical distribution type control system, allow a host computer same
When control multiple full-automatic immunohistochemical staining machines and work.
In the present embodiment, first control unit 111 is connect by optocoupler 122 with detecting liquid level plate 14, can detect liquid level
Position.In an optional implementation, detecting liquid level plate 14 has been internally integrated oscillating circuit, transmitting line, has received electricity
Road, rectification circuit, low-pass filter circuit, amplifying circuit, digital filter circuit and driving screened circuit.When probe touches liquid level
When, the AC signal of transition can be received immediately by receiving circuit, and the signal is rectified, filters, converts direct-flow output signal after amplification.
The position of liquid level can relatively accurately be detected.
In the present embodiment, first control unit 111 is connect by optocoupler 122 with optoelectronic switch 15.Optoelectronic switch is light
The abbreviation of electricity close to switch connects circuit by synchronization loop, thus detectable substance using detected material blocking or reflect to light beam
The presence or absence of body.Input current is converted to optical signal injection by optoelectronic switch 15 on transmitter, and receiver is further according to receiving
The power of light or whether there is or not detect to target object.
In the present embodiment, first control unit 111 is connect by optocoupler 122 with Hall switch 16.Hall switch is one
The active magnetoelastic transducer part of kind is made on the basis of Hall effect principle using integration packaging and packaging technology, can be square
Just electric signal magnetic input signal being converted into practical application.
In the present embodiment, expansion board 12 further includes valve driving unit 123, and the first control unit 111 passes through optocoupler
122 connect with the valve driving unit 123, and then connect with valve 17.Specifically, valve 17 is direct current generator.Valve driving unit 123
For generating direct current according to control signal, and then control the operation of direct current generator.
In the present embodiment, the second control unit 112 is connect by high speed photo coupling 124 with encoder 18, passes through the volume
Code device 18 obtains the position of motor 19.Specifically, encoder be signal or data are worked out, be converted to can be used to communicate,
The device of the signal form of transimission and storage.Angular displacement or straight-line displacement can be converted into electric signal by encoder, the former is known as
Code-disc, the latter are known as yardstick.Two class of increment type and absolute type can be divided into according to working principle encoder.Incremental encoder be by
Displacement is converted into periodic electric signal, then this electric signal is transformed into counting pulse, indicates displacement with the number of pulse
Size.The corresponding determining digital code in each position of absolute type encoder, therefore the only starting with measurement of its indicating value
It is related with final position, and be independent of the intermediate process of measurement.
In the present embodiment, expansion board 12 further includes electric-motor drive unit 125, and second control unit 112 passes through light
Coupling 122 is connect with the electric-motor drive unit 125, and then is connected to motor 19.Motor 19 be stepper motor, stepper motor be by
Electric impulse signal is changed into the opened loop control motor of angular displacement or displacement of the lines, is mainly holding in modern digital program control system
Units, application are extremely wide.Angular displacement can be controlled by control pulse number, to reach the mesh of accurate positionin
's;The velocity and acceleration that motor rotation can be controlled by control pulse frequency simultaneously, to achieve the purpose that speed regulation.Its
Working principle is that direct current is become to the multiphase timing control electric current of time sharing power supply, is step with this electric current using electronic circuit
It powers into motor, stepper motor could work normally, and electric-motor drive unit is exactly that the multiphase of time sharing power supply is provided for stepper motor
Sequence controller.Specifically, the second control unit 112 sends pulse signal to the electric-motor drive unit 125, motor driven list
Member 125 generates the angular displacement of motor according to the pulse signal, and then controls the motor 19 and run in a predetermined manner.
Preferably, the first control unit 111 is arm processor, and second control unit 112 is FPGA
(Field-Programmable Gate Array, field programmable gate array).Arm processor have small in size, low-power consumption,
The characteristics such as low cost, high-performance, more peripheral hardwares, multiplex roles and more I/O are responsible for the parsing of CAN signal and the reality of motor control algorithms
It is existing, using the powerful calculating ability of arm processor, real-time control is carried out to the movement of multiple motors respectively, makes motor acceleration and deceleration
It is more steady, give full play to motor speed advantage.FPGA has many advantages, such as that low in energy consumption, performance is strong, resource is more, easy to use, main
It to be used as hardware interface, is responsible for the transmission of motor pulses signal and the acquisition of code device signal.Utilize the powerful interface function of FPGA
Can, the reading interface of the pulse direction control interface of motor, encoder is all concentrated in together, it is convenient and efficient.
The present embodiment by using integrated control system, by original 20 muti-piece circuit board by core board and expansion board come
It realizes, substantially reduces circuit board quantity, reduce number of cables, the material cost of complete machine is reduced, simultaneously as circuit board and cable
The reduction of quantity, and then reduce the workload of scheduling and planning, moreover, only one CAN node of integrated control system, communication network
Network is simple, and failure rate is low, and system operation is more stable.
Specifically, the structure of core board is as shown in Figure 5.Fig. 5 is the structural schematic diagram of core board of the embodiment of the present invention.Such as figure
Shown in 5, core board 11 includes first control unit 111 and the second control unit 112.First control unit 111 is configured as connecing
Control signal is received, and pulse frequency parameter is generated according to the control signal, the control signal includes the control letter of host computer 2
Number and trigger signal.Second control unit 112 is configured as receiving the pulse frequency ginseng that the first control unit 111 is sent
Number generates pulse signal according to the pulse frequency parameter to update the operating status of the multiple motor 19.
In the present embodiment, first control unit 111 include parsing module 1111, running track preprocessing module 1112,
Target position computing module 1113, emergency stop module 1115, detecting liquid level module 1116, resets first bus driver block 1114
Detection module 1117, timer module 1118 and error handling module 1119.
In the present embodiment, parsing module 1111 is configured as the control signal that parsing host computer 2 is sent.Preferably, institute
Stating parsing module 1111 is CAN protocol parsing module.
In the present embodiment, running track preprocessing module 1112 is configured as generating electricity according to the control signal after parsing
The running track of machine 19 and corresponding pulse frequency parameter.
In the present embodiment, target position computing module 113 is configured as obtaining motor according to the running track of motor
Target position information.
In the present embodiment, emergency stop module 1115, detecting liquid level module 1116, reset detection module 1117, timer mould
Block 1118 and error handling module 1119 are configurable to generate trigger signal, and running track preprocessing module 1112 is according to the touching
It signals to generate running track and corresponding pulse frequency parameter.For example, being that emergent stop signal and mistake are believed in response to trigger signal
Number, generate control motor pulse frequency parameter out of service.
In the present embodiment, the first bus driver block 1114 is configured as the pulse frequency parameter being sent to second
Control unit 112.
In the present embodiment, the second control unit 112 includes the second bus driver block 1121, motor control module 1122
With encoder receiving module 1123.
In the present embodiment, the second bus driver block 1121 is configured as receiving the first bus receiving module transmission
Pulse frequency parameter.
Preferably, first bus driver block 1114 and the second bus driver block 1121 are FSMC (Flexible
Static Memory Controller can be changed static storage controller) bus driver block.FSMC is a kind of novel storage
Device expansion technique has unique advantage in terms of external memory expansion, can easily be carried out according to systematic difference needs
The extension of different type large capacity static memory.With a variety of static memory types of support, support storage operation abundant
Method is supported while being extended multiple memorizers and supports the advantages such as more extensive memory model.Pass through the time to FSMC
Parameter setting expands the velocity interval of available memory in system, provides flexible storage chip for user and selects space.
In the present embodiment, motor control module 1122 is configured as generating pulse letter according to the pulse frequency parameter
Number, the pulse signal is for controlling the operation of motor 19.
In the present embodiment, encoder receiving module 1123 is configured as receiving the reality for the motor 19 that encoder 18 is got
Border location information, and the actual position information is sent to first control unit by first bus driver block 1114
111。
Pass through the combination of this round-robin and motor step curve motion algorithm as a result, control system can be right simultaneously
Multiple motors carry out the motion control of real-time position and speed, and motor acceleration and deceleration are more steady, run relatively reliable, abundant hair
Wave motor speed advantage.
The above description is only a preferred embodiment of the present invention, is not intended to restrict the invention, for those skilled in the art
For, the invention can have various changes and changes.All any modifications made within the spirit and principles of the present invention are equal
Replacement, improvement etc., should all be included in the protection scope of the present invention.