1. Technical Field
Embodiments of the present disclosure generally relate to step motors, and more particularly, to a system and a method for driving a step motor.
2. Description of Related Art
A step motor rotates by a predetermined angle, namely a step angle, on application of one pulse to the step motor. Step motors have been widely used as a core driving source in many fields, such as, factory automation, and precision measurement industry.
In the precision measurement industry, the step motor may be mounted inside an image measurement machine for controlling and adjusting zoom of a lens module of the image measurement machine via rotation to a predetermined position. What is needed, therefore, is a system and method for driving rotation of the step motor, which can control and adjust zoom of the lens module effectively and accurately.
A system for driving a step motor is provided. The system includes a first data packet receiving module, a MCU determining module, a converting module, and at least one processor. The first data packet receiving module is configured for receiving a first data packet from a computer, wherein the first data packet comprises a header data and a main data, wherein the header data defines an identification of the main data, and wherein the main data defines a numerical zoom value corresponding to a selected magnification level of the lens module. The MCU determining module is configured for determining the identification of the main data in the first data packet according to the header data. The converting module is configured for converting the selected magnification level of the lens module into drive signals to drive rotation of the step motor, upon the condition that the identification of the main data is the numerical zoom value corresponding to the selected magnification level of the lens module The at least one processor is configured for executing the first data packet receiving module, the MCU determining module, and the converting module.
Other advantages and novel features of the present invention will become more apparent from the following detailed description of preferred embodiment when taken in conjunction with the accompanying drawings.
The computer 1 is configured for receiving zoom commands of a lens module 5 of the image measuring machine 6. It may be understood that, the zoom command is command that controls the lens module 5 to zoom/magnify on a selected area of an object. In one embodiment, the zoom command may include a numerical zoom value corresponding to a selected magnification level of the lens module 5, wherein the numerical zoom value may be, for example, 1, 4, or 9. The lens module 5 is installed in the image measurement machine 6, and be connected with the step motor 3. Zoom of the lens module 5 can be controlled and adjusted via the rotation of the step motor 3. The computer 1 is further configured for packing the numerical zoom value into a first data packet, and sending the first data packet to the MCU 2.
The MCU 2 is arranged and configured for receiving the first data packet from the computer 1, processing the first data packet, and generating drive signals that drive rotation of the step motor 3 according to the numerical zoom value.
The receiving module 10 is configured for receiving a zoom command of the lens module 5. As mentioned above, the zoom command may include a numerical zoom value corresponding to a selected magnification level of the lens module 5.
The first data packet sending module 11 is configured for packing the numerical zoom value to generate a first data packet, and sending the first data packet to the MCU 2. The first data packet may include a header data and a main data. The header data defines an identification of the main data, and may be represented as a predetermined character, such as an “M.” The main data is the numerical zoom value. For example, if the first data packet is “M9,” the header data “M” defines that the main data of the first data packet is identified as a selected magnification level, and the main data “9” is the numerical zoom value.
The first data packet receiving module 20 is configured for receiving the first data packet from the computer 1.
The MCU determining module 21 is configured for determining the identification of the main data in the first data packet according to the header data of the first data packet. As mentioned above, if the header data of the first data packet is the character “M,” the MCU determining module 21 determines that the main data in the first data packet is identified as the selected magnification level. The MCU determining module 21 is further configured for determining if the main data in the first data packet is valid when the main data is identified as the selected magnification level. For example, if the selected magnification level is preset as 1-9, the main data in the first data packet is valid if more than 0, and less than or equal to 9.
The converting module 22 is configured for converting the selected magnification level into drive signals so as to drive the step motor 3 to rotate to a predetermined position. It will be understood that if the step motor 3 rotates to the predetermined position, the zoom of the lens module 5 can be adjusted accurately. The drive signals may include a pulse signal and a direction signal. It may be understood that the pulse signal is a pulse number that can drive the step motor 3 rotate to the predetermined position. The direction signal is a direction that the step motor 3 rotate to. The direction may be upwards or downwards. In one embodiment, a relationship between magnification level of the lens module 5 and pulse number to drive the step motor 3 to rotate may be stored in a table in the MCU 2. For example, the table may comprise data that 1× magnification level corresponds to a 2,000 pulse number, 4× magnification level corresponds to a 10,000 pulse number, 9× magnification level corresponds to a 18,000 pulse number, and so on. The converting module 22 may generate the direction signal by comparing a current magnification level of the lens module 5 with the selected magnification level. The direction may be upwards if the selected magnification level is more than the current magnification level. Otherwise, the direction may be downwards if the selected magnification level is less than the current magnification level. Finally, the converting module 22 generates the pulse signal by subtracting a pulse number corresponding to the current magnification level from a pulse number corresponding to the selected magnification level.
The second data packet sending module 23 is configured for packing a rotation result of the step motor 3 to generate a second data packet, and sending the second data packet to the computer 1. The rotation result of the step motor 3 comprises information defining whether the step motor 3 has rotated to the predetermined position or not rotated to the predetermined position. In one embodiment, the second data packet may include a header data, a main data, and a footer data. The header data and the main data of the second data packet have substantially the same function as the header data and the main data of the first data packet respectively. The footer data defines the rotation result of the step motor 3, and may be represented as a predetermined character, such as a “K” or an “N.” In one embodiment, if the footer data of the second data packet is the “K,” the step motor 3 has rotated to the predetermined position. Otherwise, if the footer data of the second data packet is the “N,” the step motor 3 has not rotated to the predetermined position.
The second data packet receiving module 12 is configured for receiving the second data packet from the MCU 2.
The computer determining module 13 is configured for determining if the step motor 3 has rotated to the predetermined position according to the second data packet. To do so, the computer determining module 13 determines if the main data in the second data packet is identified as the selected magnification level according to the header data of the second data packet. Then, the computer determining module 13 determines if the step motor has rotated to the predetermined position according to the footer data of the second data packet.
The feedback module 14 is configured for outputting error information if the step motor 3 has not rotated to the predetermined position. The outputted error information may be outputted to a display of the computer 1 and/or stored in an error log in a storage data system of the computer 1.
In block S10, the receiving module 10 of the computer 1 receives a zoom command of the lens module 5. As mentioned above, the zoom command includes a numerical zoom value corresponding to a selected magnification level of the lens module 5, wherein the numerical zoom value may be, for example, 1, 4, or 9.
In block S11, the first data packet sending module 11 packs the numerical zoom value to generate a first data packet, and sends the first data packet to the MCU 2. As mentioned above, the first data packet may include a header data and a main data. The header data defines identification (type) of the main data, and may be represented as a predetermined character, such as an “M.” The main data is the numerical zoom value corresponding to the selected magnification level of the lens module 5.
In block S12, the first data packet receiving module 20 of the MCU 2 receives the first data packet from the computer 1.
In block S13, the MCU determining module 21 determines if the main data in the first data packet has been identified as the selected magnification level according to the header data of the first data packet. As mentioned above, if the header data of the first data packet is “M,” the main data in the first data packet has been identified as the selected magnification level, and the flow moves to block S14. Otherwise, if the header data of the first data packet is not “M,” the main data in the first data packet has not been identified as the selected magnification level, then, the flow moves to block S12.
In block S14, the MCU determining module 21 further determines if the main data in the first data packet is valid. As mentioned above, if the numerical zoom value is more than 0, and less than or equal to 9, the main data in the first data packet is valid, and the flow moves to block S15. Otherwise, the main data in the first data packet is invalid, and the flow moves to block S12.
In block S15, the converting module 22 of the MCU 2 converts the selected magnification level into drive signals (detailed description is given in
In block S16, the second data packet sending module 23 packs the rotation result of the step motor 3 to generate a second data packet, and sends the second data packet to the computer 1. As mentioned above, the second data packet may include a header data, a main data, and a footer data. The header data and the main data of the second data packet have substantially the same function as the header data and the main data of the first data packet respectively. The footer data defines the rotation result of the step motor 3, and may be represented as a predetermined character, such as a “K” or an “N.” If the footer data of the second data packet is the “K,” the step motor 3 has rotated to the predetermined position.
In block S17, the second data packet receiving module 12 receives the second data packet from the MCU 2.
In block S18, the computer determining module 13 determines if the step motor 3 has rotated to the predetermined position according to the second data packet. As mentioned above, the computer determining module 13 firstly determines if the main data in the second data packet is identified as the selected magnification level according to the header data of the second data packet. Then, the computer determining module 13 determines if the step motor 3 has rotated to the predetermined position according to the footer data of the second data packet. If the footer data of the second data packet is “K,” the step motor 3 has rotated to the predetermined position and the flow ends. Otherwise, if the footer data of the second data packet is “N,” the step motor 3 has not rotated to the predetermined position, then the flow moves to block S19.
In block S19, the feedback module 14 of the computer 1 outputs error information if the step motor 3 has not rotated to the predetermined position.
In block S150, the converting module 22 converts the selected magnification level of the lens module 5 into pulse number according to the table in the MCU 2.
In block S151, the converting module 22 determines if the pulse number converted above equal pulse number corresponding to a current magnification level of the lens module 5. The flow ends if the pulses converted above equals the pulse corresponding to the current magnification level. The flow moves to block 152 if the pulse number converted above do not equal the pulse number corresponding to the current magnification level.
In block S152, the converting module 22 generates the direction signal by comparing the current magnification level with the selected magnification level, and further generates the pulse signal by subtracting the pulse number corresponding to the current magnification level from the pulse number converted above.
In block S153, the converting module 22 drives rotation of the step motor 3 according to the pulse signal and the direction signal, and generates the rotation result of the step motor 3.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
200710203287.8 | Dec 2007 | CN | national |