Motor controller for a sewing machine
FIELD OF THE INVENTION AND RELATED ART STATEMENT 
     1. Field of the Invention 
     The present invention relates to a motor controller of a sewing machine for starting or stopping a motor of the sewing machine in response to a starting or stopping signal from a foot switch or a manual switch, and especially a motor controller of a sewing machine which has a function of stopping the needle at a predetermined position. 
     2. Description of the Related Art 
     Needle moving speed, which is controlled by a conventional motor controller of a sewing machine, is shown in FIG. 1 with respect to time, and it is described as follows with reference to FIG. 1. 
     Generally, a magnetic clutch type motor is used as a motor of a sewing machine, the motor having cluth-and-brake coils, linings of respective clutches and a magnetic circuit thereof. The needle positioning method for stopping the needle at a predetermined position is practiced with such a motor as follows. At first, when a stop signal is issued during normal maximum speed operation &#34;N max&#34;, the needle speed (sewing speed) is quickly decreased by a brake signal &#34;Br&#34; and shifted to slow speed operation &#34;Nlow&#34; at point &#34;α&#34;. Next, at point &#34;β&#34;, where a predetermined needle position signal &#34;Nd&#34; is issued, the brake coil is maximally excited, and the needle (sewing machine) stops at point &#34;γ&#34;, which is the position where the needle is to be stopped. Furthermore, after a time period T 1 , which is longer by a certain margin than a time required to stop the sewing machine from the point of time &#34;β&#34;, the needle is stopped at the predetermined position. 
     In the above-mentioned conventional needle positioning method, the needle stopping control after the point &#34;β&#34;, where the needle position signal &#34;Nd&#34; is issued, is an open control, and the brake coil is maximally excited unconditionally for a fixed time period. Accordingly, in such a method the needle is not positioned precisely. That is, error in the needle stop position is caused by (1) change of the needle speed at point &#34;β&#34;, (2) change of inertia or load of the sewing machine, (3) change of brake power corresponding to the potential change of the electric power source, (4) change of coefficient of friction on a surface of the brake lining caused by friction heating and the like. Due to such errors the conventional motor controller of a sewing machine is inaccurate, and because improvement in the precision of stopping position is limited, a discrepancy in the stopping position after cutting thread occurs, or in a worse case, the breaking in two of the needle occurs due to interference of the needle and the thread wiper. 
     OBJECT AND SUMMARY OF THE INVENTION 
     The object of the present invention is to provide an improved motor controller for a sewing machine by which a needle of the sewing machine may be precisely stopped at a predetermined position. 
     A motor controller of such a sewing machine in accordance with the present invention comprises: 
     pulse generating means for generating plural pulse signals for each rotation of a motor shaft, 
     speed measuring means for measuring rotational speed of the motor shaft and for generating a signal representative of a measured rotational speed of the motor shaft, 
     needle position detecting means for detecting the position of a needle and for generating a needle position signal, 
     motion command means for commanding the start or stop of rotation of the motor shaft, 
     speed setting means for setting rotation speed of the motor shaft and for generating a signal of a lower set speed when a stop signal is generated by the motion command means, 
     speed control means for controlling rotation speed of the motor shaft, 
     needle position confirming means for confirming the position of the needle and for generating a position control command signal when the signal repesentative of a measured rotational speed reaches the lower set speed and the needle position signal is detected, 
     counter means for counting the number of pulse signals by receiving the position control command signal and for generating a first speed set signal which is reduced to zero when the counted number of pulse signals reaches a predetermined value, 
     converter means for converting an output of the counter means into a second speed set signal, and 
     switching means for disabling the first speed set signal from the speed setting means and for enabling the second speed set signal from the converter means, with reference to the position control command signal. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a timing chart showing the operation of the conventional motor controller of a sewing machine. 
     FIG. 2 is a block diagram showing an embodiment of a motor controller of a sewing machine in accordance with the present invention. 
     FIG. 3 is a circuit diagram showing an embodiment of a counter circuit in accordance with the present invention. 
     FIG. 4 is a flow chart showing the manner of speed control of a motor controller of sewing machine in accordance with the present invention. 
     FIG. 5 is a timing chart showing an operation of the motor controller of a sewing machine in accordance with the present invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     A preferred embodiment for a motor controller of sewing machine in accordance with the present invention is described as follows with reference to FIG. 2, FIG. 3, FIG. 4 and FIG. 5. 
     FIG. 2 is a block diagram showing an embodiment of a motor controller for a sewing machine in accordance with the present invention. In FIG. 2, a motion command circuit 1 issues a start or stop signal &#34;St&#34; to a motor in response to the switching on/off of a switch or the pushing down or release of a pedal of a foot switch. A needle position detecting device 2 constituted by a Hall device is used to detect the rotation of a rotating magnet or to detect the reflecting light from a rotating mirror using a photo-sensor, and needle position detecting device 2 issues a needle position signal &#34;Nd&#34; at the top position or the bottom position of the needle movement. A needle position confirming circuit 3 constituted by a logic circuit is responsive to start or stop signal &#34;St&#34; and needle position signal &#34;Nd&#34; and outputs an output signal &#34;Bs&#34;. A speed setting device 4 responsive to start or stop signal &#34;St&#34; issues a speed signal &#34;Ps&#34; which corresponds to the position of the pedal stepped on or a value set by a volume controller. 
     The present embodiment also includes a counter circuit 5 and an absolute value circuit 6 which are respectively constituted by logic circuits. The output &#34;Ca&#34; of absolute value circuit 6 is received by a converter circuit 7 constituted by a multiplying circuit. A data selector 8, monostable multivibrators 9 and 10 and an AND gate 11 are arranged as shown and respectively constituted by discrete ICs (integrated circuits). a speed control circuit 12 responsive to a set speed signal &#34;Ns&#34; outputted by data selector 8 is constituted by a digital circuit or an analogue circuit. A driver 13 for driving a motor 15 is combined directly or with a belt inbetween with a sewing machine 14, and the driver 13 is constituted by power transistors and an electric power source circuit for driving them. 
     The present embodiment further includes a rotary encoder 16 for detecting the position of a rotating multiple magnet using a magnetic sensor such as a magnetic resistance device or for detecting the position of a rotating disc with slits by using a transmitting type photo-sensor. Rotary encoder 16 also issues two pulse signals &#34;A&#34; and &#34;B&#34;, whose phases are respectively shifted electrically by 90 degrees, by using two of the above-mentioned sensors. A four-pulse circuit 17 responsive to pulse signals &#34;A&#34; and &#34;B&#34; is constituted by a discrete IC so as to generate pulse signals &#34;Pe&#34; at front and rear edges of the pulse signals &#34;A&#34; and &#34;B&#34;. A speed calculating circuit 18 then issues a real speed signal &#34;Nf&#34; which shows the real speed of the motor using a built-in timer and an operating circuit with reference to the pulse signal &#34;Pe&#34; of the four-pulse circuit 17. A rotation direction discriminating circuit 19 constituted by a logic circuit is also responsive to pulse signals &#34;A&#34; and &#34;B&#34; and has a function of detecting the rotation direction of the motor by detecting the order of phase delay between the pulse signals &#34;A&#34; and &#34;B&#34; and of generating a rotation direction indicating signal &#34;Rd&#34;. 
     Operation of the above-mentioned motor controller for a sewing machine will be described in the following: 
     At first, when the output signal &#34;St&#34; of the motion command circuit 1 represents the starting command, the speed setting device 4 issues the speed signal &#34;Ps&#34; responding to the position of the pedal, the needle position confirming circuit 3 changes its output &#34;Bs&#34; to &#34;L&#34; level from &#34;H&#34; level, and the data selector 8 is switched to select the speed &#34;Ps&#34; and to issue a set speed &#34;Ns&#34;. The speed control circuit 12 controls the motor 15 via driver 13 so as to minimize the deviation between the set speed &#34;Ns&#34; and the real speed &#34;Nf&#34;. Accordingly, the motor 15 rotates in a speed corresponding to the set speed &#34;Ns&#34;. 
     Next, stopping operation of the sewing machine from the above-mentioned normal operation corresponding to the position of the pedal is described below. At first, when the output signal &#34;St&#34; representing the stopping command of the motion command circuit 1 is issued, the speed setting device 4 issues the signal &#34;Ps&#34; of a slow speed for positioning, and the speed control circuit 12 quickly brakes the motor 15 because the deviation between the set speed &#34;Ns&#34; corresponding to the lower speed and the real speed &#34;Nf&#34; becomes large. Next, the needle position confirming circuit 3 changes its output signal &#34;Bs&#34; from &#34;L&#34; level to &#34;H&#34; level when the real speed signal &#34;Nf&#34; reaches the slow speed corresponding to the speed signal &#34;Ps&#34; and the front edge of the needle position signal &#34;Nd&#34; is detected. Thereafter, the operations of the motor controller of the sewing machine shifts to the needle position detecting mode. 
     Hereupon, FIG. 3 shows a concrete constitution of the counter circuit 5. In FIG. 3, the counter circuit 5 is constituted by resistor R 0  to R 7 , switches S 0  to S 7  and an up/down counter 20 which can preset 8 bit data. 
     As mentioned above, when the signal &#34;Bs&#34; changes from &#34;L&#34; level to &#34;H&#34; level, the monostable multivibrator 9 issues pulse signal &#34;Pm&#34;, and the counter 20 presets the data which is set by the switches S 0  to S 7  and starts to count the orderly fourfold pulse signals &#34;Pe&#34;. At this time, the rotation direction discriminating signal &#34;Rd&#34; shows the positive rotation. Accordingly, at first, the counter 20 counts down. The absolute value circuit 6 then calculates the absolute value from a counted value &#34;Cn&#34; of the counter 20 and a column borrowing signal &#34;Bo&#34;, which shows that the count down result is negative, and outputs the absolute value data &#34;Ca&#34;. The converter circuit 7 then converts the absolute value data &#34;Ca&#34; into a value of a set speed &#34;Ms&#34; by multiplying &#34;Ca&#34; by a predetermined value and issuing the value. On the other hand, the shifting of the signal &#34;Bs&#34; to &#34;H&#34; level is caused by changing the data selector 8 for selecting the value of set speed &#34;Ms&#34;, and the speed control circuit 12 thus controls the speed of the motor 15 in response to the value of set speed &#34;Ms&#34;. 
     Hereupon, the speed control circuit 12 can be constituted by a microcomputer, and FIG. 4 shows a flow chart of a speed control method in such a case. 
     When a borrowing signal &#34;Bo&#34; is issued, it shows that the number of predetermined pulses has been already counted and the needle has passed through the target stopping position. The motor needs to rotate at the set speed &#34;Ns&#34; in the reverse direction, but the deviation of speed &#34;ε&#34; is calculated in two ways depending on the real indication of the rotation direction &#34;Rd&#34; and the real speed &#34;Nf&#34; as shown in FIG. 4, and the motor is controlled to differ the rotation direction in respective cases. When the borrowing signal &#34;Bo&#34; is not issued, the motor needs to rotate in the positive direction, but it is controlled to rotate in two different directions depending on two different ways of calculating the speed deviation &#34;ε&#34;. The speed deviation &#34;ε&#34; which is so calculated is multiplied by a magnification factor &#34;K&#34; and transferred to the driver 13 as a current command value &#34;Im&#34; together with the command of the rotation direction, and the driver 13 drives the motor 15. On the other hand, the monostable multivibrator 10 and the AND gate 11 enables the speed control circuit 12 during a predetermined time period after shifting of the signal &#34;Bs&#34; to &#34;H&#34; level, and thereafter they stop power supply to the motor 15. 
     As mentioned above, the needle position control is practiced by starting the counting pulse &#34;Pe&#34; of the four-pulse circuit 17 after generation of the needle position signal &#34;Nd&#34;, then gradually decreasing the set speed and setting the set speed to zero when the number of pulses set by the switches S 0  to S 7  has been counted. The rotation direction of the motor is then reversed when the counted pulse is above the predetermined value, and the motor is stopped when the predetermined number of pulses has been counted over. 
     FIG. 5 is a timing chart showing the above-mentioned motion. The lower speed of the motor (namely equal to the needle speed) is set at point &#34;a&#34;. After the speed of the sewing machine (needle) is quickly decreased, it reaches the lower speed &#34;N low&#34; at point &#34;b&#34;. The front edge of the needle position signal is detected at point &#34;C&#34;, and the pulse number corresponding to the aimed stop position set by the switches is preset into the counter. Thereafter, the set speed is gradually decreased by subtracting the fourfold multiplied pulse signal &#34;Pe&#34;, and when the remaining pulse number reaches to zero, the set speed becomes zero and the motor stops. Hereupon, though a phenomenon of reversing of the rotation direction due to inertia of the control system or delay of current flow to coil of the motor are generally observed at the stopping (shown between the points d and e or f and g), such reversing phenomenon is detected by the rotation direction discriminating circuit 19. Therefore, the speed control is completely practiced by the above-mentioned method shown in FIG. 4 so that the vibration is damped and the motor (or the needle) finally stops. 
     As mentioned above, in the motor control apparatus of the present invention, the pulse signals generated by the rotation of the motor are counted after detection of the needle position signal, and feedback control is used to stop the motor at the position set by the plural switches in the needle positioning process. Accordingly, a motor controller for a sewing machine with very accurate positioning and control of the needle at stopping is obtainable.