【0001】
【発明の属する技術分野】
本発明は、ステッピングモータの駆動パルスレートの計算法に関わるもので、コンピュータ上で、ホストが、任意のパラメータを入力することにより、駆動パルスを計算し、任意の時間で、任意の角度だけ回転させることを可能にしたステッピングモータ制御装置に関する。
【0002】
【従来の技術】
ステッピングモータは、パルス信号が入力される毎にモータの巻線に流す電流を切り換えることで一定角度ずつ回転するモータで、位置制御・速度制御に適したモータである。また、ステッピングモータコントローラLSIを採用し、コマンドと、データの入出力を、おこなうためのレジスタを供えているので、ホストから、定速駆動や台形駆動などの制御を容易におこなうことができるようになっている。しかし、元来、位置決め機能を、重視して、設計されたものであるから、ふつうの、モーターのように、容易に高速運転を行うことはできない。メカニズムと電流の変化の相互関係で、トルクが、大幅に変動したり、共振を、おこして、脱調したりする場合がある。一般的には、これらの現象を防止するために、図3に示すような加減速制御(台形駆動)が必要となる。従来の技術では、これらの加減速制御を、ホストから与える簡単なパラメータによって、デジタル的に、処理しようとしている。すなわち、起動時パルスレート、高速時パルスレート、加減速パルス数、動作パルス数などのデータを、コマンドとともに、書き込むことで、加減速制御をおこなっていた。
【0003】
【発明が解決しようとする課題】
ステッピングモータを、ホストが制御する場合、パルス数を、パラメータとするのは、実際の動きとの関係が不明瞭で分かりにくいとゆう問題があった。
【0004】
また、ステッピングモータに与える高速パルスレートの値が、ある一定のしきい値をこえると、パルス間隔の乱れによって変調をきたし、一般的計算式で得られる回転速度と、実際の回転速度の間に、ずれが、生じてくるという問題があった。
【0005】
また、汎用ライブラリを、利用する方法もあるが、これらのライブラリでは、脱調やトラブルをおそれ、大幅にパルスレートに制限を設けているため、細かい動き(制御)を、実現することが不可能であった。
【0006】
【課題を解決するため為の手段】
本発明は上述の課題を解決するため、第1に、ホスト側からは、ステッピングモータの目標回転角度と目標回転時間(動き始めてから、停止するまでの時間)をパラメータとして入力するだけで、コンピュータ上で自動的にパルス数を算出し、ステッピングモータのレジスタに書き込む手段を設けた。第2に、ステッピングモータの回転速度のずれを補正する手段を設けることで、より精密なステッピングモータの自動制御を可能にしたものである。
【0007】
【発明の実施の形態】
以下、図面に基づいて本発明によるステッピングモータ制御装置の実施例を詳細こ説明する。第図1は本発明によるステッピングモータ制御装置の一実施例の要部ブロック図で、ステッピングモータ3を駆動するドライバ回路2と電源4,ステッピングモータ3の駆動パルス列を作るステッピングモータコントローラ1とホストコンピュータ5のCPU6とメモリ7と、キーボード8から構成されている。ステッピングモータコントローラ1には、タイマ9、カウンタ10、マイクロプロセッサ11が、あり、これらによって、モータコントロール信号を、出力している。コマンド、および、パラメータが、あたえられると、それに従って内部で制御データを作成し、この制御データを用いて高速のパルス列を出力するようになっている。また、ドライバ回路とのインターフェイス用のI/Oポート12がある。
【0008】
つぎに、図2のフロー図にもとずいて詳しく説明する。
【0009】
まず、S1で、本発明のシステムを起動させ、ホストコンピュータ5のプログラムを起動する。S2では、ステッピングモータの初期設定をおこなう。初期設定では、I/0ポート12の、アドレス設定と、基準クロックの設定を行う。次に、S3ではデータファイルの読み込みをおこなう。データファイルとは、ホストが、あらかじめ、キーボード8から実行時間(相対的)、目標回転角度と、回転方向、目標回転時間を、パラメータとして書き込んで作成したものである。本プログラム起動時に、このデータファイルを一気に読み込み、メモリ7に、記録しておく。つぎに、このデータを、CPU6で、時間ごとにひとつひとつ実行していく手法をとることにより、ホストが思い描いたとうりに、ステッピングモータが自動的にうごくように処理している。
【0010】
S4では、N番目のデータ(初期値1)を、総データ数(Nmax)だけ順次に実行していく。Nが、Nmaxをこえたら、S5においてプログラムを終了する。N≦Nmaxの場合は、S6で、プログラム内部の相対的な時間Tr(ホストコンピュータ5の内部クロックをつかって、プログラム起動時に、Tr=0にし、その後は、Tr=プログラムの実行時間になる)と、データの実行開始指定時間Tnとを比較し、Tn≧Trの場合はS7の処理をおこなう。S7では、ステッピングモータを、実行時間(相対的)、目標回転角度と、回転方向、目標回転時間の4つのパラメータにもとずいて稼動する。一般的に、ステッピングモータのスピードを決定するためのにパルスレートという数字をつかっている。パルスレートは、モータを1ステップ動かすために要する基本クロックの数で、パルスレートとモータの速度との関係は以下の式であらわされる。
【0011】
Speed=1000000/((Rate+1)*Tclock+7.5)(PPS) …(数1)
Speed:モータ速度(パルス/秒)
Tclock:基本クロック周期(μsec)
Rate:パルスレート
ステッピングモータを動かすためには、まず、初期値の設定をおこない、次に、この値にもとずいて、加減速動作をおこなうための、命令を発する必要がある。初期値の設定では、ステッピングモータコントローラ1に、初期設定コマンドと初期値データを書き込む処理をおこなっている。初期値データは、モータの加減速動作の条件を決めるためのもので、起動時パルスレートRL、高速時パルスレートRH、加減速パルス数の3個である。起動時パルスレート及び高速時パルスレートは、それぞれ1バイトの値で与え、このとき、対応する起動時および高速時速度(PPS)は、以下の式から、求められる。
SL=1000000/((RL+1)×Tclock+7.5)
SH=1000000/(RH+1×Tclock+7.5) …(数2)
Tclock:基本クロック周期(μsec)、(コントローラの内部クロックは25kHz)
パルスレートには、制限があり、以下の条件を満足しない場合は、ステッピングモータコントローラ1よりエラーが返される。
255≧RL≧RH>0 …(数3)
本発明のシステムにおいては、データファイルのなかの、目標回転角鹿degree(°)と、目標回転時間mtime(msecから上記の起動時パルスレートRL、高速時パルスレートRH、加減速パルス数を算出することを特徴とする。以下にこの過程を、いくつかの式をもちいながら説明する。
【0012】
まず、ステッピングモータには、モータの種類ごとに、固有の基本ステップ角がきめられている。基本ステップ角DPPは、1ステップで、移動できる角度(°)である。
【0013】
よって、目標回転角度degreeから、動かしたいステップ数movstepは以下の式から算出する。
movstep=degree/DPP …(数4)
また、起動時パルスレートRLを、最低速度の255に設定すると、
RL=255
高速時パルスレートRHは、数1から
RH=(1000000/SH−7.5)/clock−1 …(数5)
となる。
【0014】
ここで、加速および減速に要する時間をktime(msec)とすると、高速時速度SHは以下の式で求められる。
SH=((movstep×1000−RL×ktime/(mtime−ktime) …(数6)
よって、数5と、数6から、RHが、算出される。
【0015】
また、加減速パルス数movrateは、数6と以下の式から算出する。
SL=(100000)/((255+1)×Tclock+7.5) …(数7)
movrate=SL+(SH+SL)/2 …(数8)
つぎに、加減速動作をおこなうための、コマンドと、動かす回転方向、動作パルス数を、設定する。回転方向は、時計回り(+)と、反時計回り(−)を設定する。動作パルス数pulsは、3バイトで設定し、動かしたいステップ数−1の数字をあたえる。
puls=movstep−1 …(数9)
モーターが止まると、次の位置まで、移動させるために、s8で、Nを、インクリメントして、s4にもどる。このように、データファイルの、実行時間(相対的)、目標回転角度と、回転方向、目標回転時間にしたがって、次々に、ステッピングモータを、うごかすのだが、実際には、ステッピングモータコントローラ1の能力に限界があるため、RHとSHの関係は、図4に示すように、RHがしきい値Rminより小さい場合(RH<Rmin)やRHがしきい値Rmaxより大きい場合(RH>Rmax)には、数2の式に当てはまらず、目標高速時速度と、実高速時速度の間に、偏差が生じる。また、この、偏差の大きさは、モーターの機種や、外部条件などによって、多少異なるため、正確な補正のための数式をもとめることが困難である。そこで、本発明では、1≦RH<Rminの範囲内で、実回転時間を測定する実験をおこなった。図5は実験結果を示したもので、目標回転時間がTのとき、RH=Rminになる回転角度Dminをもとめる。Dminは以下の式からもとめられる。
Rmin=(1000000/SH−7.5)/Tclock−1
SH=((Dmin/DPP×1000−255×ktime)/(T−ktime) …(数10)
次に、RH=1、2、3、…Rmin−2Rmin−1のときの、回転角度を、同様にもとめ、この値をD1、D2、D3、…Dmin−2,Dmin−1とし、これらの角度を目標回転時間Tで動かした時の、実回転時間TR1、TR2…TRmin−2TRmin−1を測定したものである。
【0016】
この測定結果にもとずき、目標回転角度D1を、目標回転時間Tで、動かすためには、あらかじめ、T−TR1の偏差をTに付加した回転時間TT1で稼動させる。
TT1=T+(T−TR1) …(数11)
同様に、RHがRmax<RH≦255の範囲においても実測をおこなう。その結果を、図6にしめす。図6は、目標回転時間がTのとき、RH=Rmaxになる回転角度Dmaxを、数10式から求め、次に、RH=Rmax,Rmax+1….255のときの、回転角度を、同様にもとめ、この値をDmax,Dmax+1、…D255とし、これらの角度を目標回転時間Tで動かした時の、実回転時間TRmax、TRmax+1…TR255を測定したものである。この測定結果にもとずき、目標回転角度D255を、目標回転時間Tで、動かすためには、あらかじめTR5−Tの偏差をTから差し引いた回転時間TT255で稼動させる。
TT255=T−(TR255−T) …(数12)
さらに、目標回転時間を、小さい値から、大きい値に、適当な間隔でふやしていき、
Tn,Tn+m,Tn+2m,…
これらの目標回転時間に対する、RH=1、2、3、…Rmin−2Rmin−1とRH=Rmax,Rmax+1….255のときの、実回転速度も、同様に算出することにより、図4における、偏差値全体を明確にしていく。
【0017】
数11と、数12を、まとめ、RH=iとすると、
1≦RH<Rminの場合は、
TTi=T+(T−TRi)
Rmax<RH≦255の場合は、
TTi=T−(TRi−T)
なので、
TTi=T+T−TRi …(数13)
となり、同一の式となる。
【0018】
【発明の効果】
以上に説明したように、本発明によるステッピングモータ制御装置によれば、ホストが、ステッピングモータを動かす場合、いちいち、パルス数を算出するための、難しい計算を行う必要がなく、データファイルにパルス数よりも、直感的な情報である目標回転時間と目標回転角度を、あらかじめ、実行する相対的時間とともに、書き込んでおくだけで、コンピューターから、自動的にステッピングモータを稼動することが可能になった。
【0019】
また、高速時パルスレートが、小さい場合や、大きい場合でも、みかけ上(ソフトウエア処理により)、性能をアップさせることで、これまでは実現できなかった、より精密なステッピングモータの自動制御を行うことが可能になった。
【図面の簡単な説明】
【図1】本発明装置の構成を示すブロック図。
【図2】本発明の実施例の処理手順を示すフローチャート。
【図3】ステッピングモータの台形駆動の概念図。
【図4】RHと高速時速度の関係を表した図。
【図5】1≦RH<Rmminの時の目標回転時間と実回転時間の関係を表した図。
【図6】Rmax<RH≦255の時の目標回転時間と実回転時間の関係を表した図。[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a method of calculating a drive pulse rate of a stepping motor, in which a host calculates a drive pulse by inputting an arbitrary parameter on a computer, and rotates by an arbitrary angle at an arbitrary time. The present invention relates to a stepping motor control device capable of performing the control.
[0002]
[Prior art]
The stepping motor is a motor that rotates at a constant angle by switching a current flowing through a winding of the motor every time a pulse signal is input, and is a motor suitable for position control and speed control. In addition, since a stepping motor controller LSI is used and registers for inputting and outputting commands and data are provided, the host can easily perform control such as constant speed driving and trapezoidal driving. Has become. However, since the positioning function was originally designed with emphasis on the positioning function, high-speed operation cannot be easily performed like a motor. Due to the interrelationship between the mechanism and the change in current, the torque may fluctuate significantly, or resonance may occur, causing a step out. Generally, acceleration / deceleration control (trapezoidal drive) as shown in FIG. 3 is required to prevent these phenomena. In the prior art, the acceleration / deceleration control is digitally processed by using simple parameters provided by a host. That is, acceleration / deceleration control is performed by writing data such as a pulse rate at startup, a pulse rate at high speed, the number of acceleration / deceleration pulses, and the number of operation pulses together with a command.
[0003]
[Problems to be solved by the invention]
When the host controls the stepping motor, using the number of pulses as a parameter has a problem that the relationship with the actual motion is unclear and difficult to understand.
[0004]
Also, if the value of the high-speed pulse rate given to the stepping motor exceeds a certain threshold, modulation occurs due to disturbance of the pulse interval, and the rotation speed obtained by a general calculation formula and the actual rotation speed are calculated. However, there has been a problem that deviation occurs.
[0005]
There is also a method of using general-purpose libraries. However, these libraries have a risk of step-out or trouble, and the pulse rate is greatly limited, so that it is impossible to realize fine movement (control). Met.
[0006]
[Means for solving the problem]
In order to solve the above-described problems, the present invention firstly requires that a host input a target rotation angle and a target rotation time of a stepping motor (time from the start of movement to a stop) as parameters. A means for automatically calculating the number of pulses above and writing the number into the register of the stepping motor is provided. Secondly, by providing a means for correcting the deviation of the rotation speed of the stepping motor, more precise automatic control of the stepping motor is enabled.
[0007]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, an embodiment of a stepping motor control device according to the present invention will be described in detail with reference to the drawings. FIG. 1 is a block diagram of a main part of an embodiment of a stepping motor control device according to the present invention. A driver circuit 2 for driving a stepping motor 3, a power source 4, a stepping motor controller 1 for generating a driving pulse train for the stepping motor 3, and a host computer 5 comprises a CPU 6, a memory 7, and a keyboard 8. The stepping motor controller 1 includes a timer 9, a counter 10, and a microprocessor 11, which output a motor control signal. When a command and a parameter are given, control data is internally generated according to the command and the parameter, and a high-speed pulse train is output using the control data. There is also an I / O port 12 for interfacing with the driver circuit.
[0008]
Next, a detailed description will be given based on the flowchart of FIG.
[0009]
First, in S1, the system of the present invention is started, and the program of the host computer 5 is started. In S2, an initial setting of the stepping motor is performed. In the initial setting, the address setting of the I / O port 12 and the setting of the reference clock are performed. Next, in S3, a data file is read. The data file is created by the host writing the execution time (relative), the target rotation angle, the rotation direction, and the target rotation time as parameters from the keyboard 8 in advance. When the program is started, the data file is read at a stretch and recorded in the memory 7. Next, this data is executed by the CPU 6 one by one at every time, so that the stepping motor automatically moves as the host envisions.
[0010]
In S4, the N-th data (initial value 1) is sequentially executed by the total number of data (Nmax). If N exceeds Nmax, the program ends in S5. If N ≦ Nmax, the relative time Tr in the program is set in S6 (Tr = 0 when the program is started by using the internal clock of the host computer 5, and then Tr = program execution time). Is compared with the data execution start specified time Tn. If Tn ≧ Tr, the process of S7 is performed. In S7, the stepping motor is operated based on four parameters of the execution time (relative), the target rotation angle, the rotation direction, and the target rotation time. Generally, a pulse rate is used to determine the speed of a stepping motor. The pulse rate is the number of basic clocks required to move the motor by one step, and the relationship between the pulse rate and the speed of the motor is expressed by the following equation.
[0011]
Speed = 1,000,000 / ((Rate + 1) * Tclock + 7.5) (PPS) (Equation 1)
Speed: Motor speed (pulse / second)
Tclock: Basic clock cycle (μsec)
Rate: In order to operate the pulse rate stepping motor, it is necessary to first set an initial value and then issue a command for performing an acceleration / deceleration operation based on this value. In the setting of the initial value, a process of writing an initial setting command and initial value data to the stepping motor controller 1 is performed. The initial value data is used to determine the conditions of the acceleration / deceleration operation of the motor, and includes three values: a pulse rate RL at startup, a pulse rate RH at high speed, and the number of acceleration / deceleration pulses. The start-up pulse rate and the high-speed pulse rate are each given as a 1-byte value, and the corresponding start-up and high-speed speeds (PPS) are obtained from the following equations.
SL = 1,000,000 / ((RL + 1) × Tclock + 7.5)
SH = 1,000,000 / (RH + 1 × Tclock + 7.5) (Equation 2)
Tclock: basic clock cycle (μsec) (the internal clock of the controller is 25 kHz)
The pulse rate is limited, and if the following conditions are not satisfied, an error is returned from the stepping motor controller 1.
255 ≧ RL ≧ RH> 0 (Equation 3)
In the system of the present invention, the above-described start-up pulse rate RL, high-speed pulse rate RH, and acceleration / deceleration pulse number are calculated from the target rotation angle degree (°) and the target rotation time mtime (msec) in the data file. In the following, this process will be described using some equations.
[0012]
First, the stepping motor has a unique basic step angle for each type of motor. The basic step angle DPP is an angle (°) that can be moved in one step.
[0013]
Therefore, from the target rotation angle degree, the number of steps movstep to be moved is calculated from the following equation.
movstep = degree / DPP (Equation 4)
Also, if the starting pulse rate RL is set to the minimum speed of 255,
RL = 255
The high-speed pulse rate RH is calculated from Equation 1 as follows: RH = (1,000,000 / SH-7.5) / clock-1 (Equation 5)
It becomes.
[0014]
Here, assuming that the time required for acceleration and deceleration is ktime (msec), the high speed speed SH is obtained by the following equation.
SH = ((movstep × 1000−RL × ktime) / (mtime−ktime) (Equation 6)
Therefore, RH is calculated from Equations 5 and 6.
[0015]
The acceleration / deceleration pulse number moverate is calculated from Equation 6 and the following equation.
SL = (100000) / ((255 + 1) × Tclock + 7.5) (Expression 7)
moverate = SL + (SH + SL) / 2 (Equation 8)
Next, a command for performing the acceleration / deceleration operation, a rotating direction to be moved, and the number of operation pulses are set. The rotation direction is set to clockwise (+) and counterclockwise (-). The number of operation pulses “pulss” is set in 3 bytes, and a number corresponding to the number of steps to be moved−1 is given.
pulse = movstep-1 (Equation 9)
When the motor stops, N is incremented at s8 to return to the next position, and the process returns to s4. As described above, the stepping motor moves one after another according to the execution time (relative), the target rotation angle, the rotation direction, and the target rotation time of the data file. , There is a limit to the relationship between RH and SH, as shown in FIG. 4, when RH is smaller than threshold Rmin (RH <Rmin) or when RH is larger than threshold Rmax (RH> Rmax). Does not apply to equation (2), and a deviation occurs between the target high speed and the actual high speed. Further, the magnitude of the deviation is slightly different depending on the model of the motor, external conditions, and the like, and it is difficult to find a mathematical formula for accurate correction. Therefore, in the present invention, an experiment was performed to measure the actual rotation time within the range of 1 ≦ RH <Rmin. FIG. 5 shows an experimental result. When the target rotation time is T, the rotation angle Dmin at which RH = Rmin is obtained. Dmin is obtained from the following equation.
Rmin = (1,000,000 / SH-7.5) / Tclock-1
SH = ((Dmin / DPP × 1000-255 × ktime) / (T-ktime) (Equation 10)
Next, the rotation angles when RH = 1, 2, 3,..., Rmin-2Rmin-1 are similarly determined, and the values are D1, D2, D3,. The actual rotation times TR1, TR2,..., TRmin-2 and TRmin-1 when the angle is moved at the target rotation time T are measured.
[0016]
Based on this measurement result, in order to move the target rotation angle D1 with the target rotation time T, the target rotation angle D1 is operated in advance with the rotation time TT1 in which the deviation of T-TR1 is added to T.
TT1 = T + (T−TR1) (Equation 11)
Similarly, actual measurement is performed even when RH is in the range of Rmax <RH ≦ 255. The result is shown in FIG. FIG. 6 shows that when the target rotation time is T, the rotation angle Dmax at which RH = Rmax is obtained from Expression 10, and then, RH = Rmax, Rmax + 1,. The rotation angles at the time of 255 are similarly calculated, and the values are Dmax, Dmax + 1,..., D255, and the actual rotation times TRmax, TRmax + 1,. It is. Based on this measurement result, in order to move the target rotation angle D255 with the target rotation time T, the target rotation angle D255 is operated with the rotation time TT255 obtained by subtracting the deviation of TR5-T from T in advance.
TT255 = T- (TR255-T) (Equation 12)
Furthermore, the target rotation time is increased from a small value to a large value at appropriate intervals,
Tn, Tn + m, Tn + 2m, ...
For these target rotation times, RH = 1, 2, 3,..., Rmin−2Rmin−1 and RH = Rmax, Rmax + 1. The actual rotation speed at the time of 255 is also calculated in the same manner to clarify the entire deviation value in FIG.
[0017]
Equation 11 and Equation 12 are put together and RH = i.
When 1 ≦ RH <Rmin,
TTi = T + (T-TRi)
When Rmax <RH ≦ 255,
TTi = T- (TRi-T)
So,
TTi = T + T-TRi (Equation 13)
And the same expression is obtained.
[0018]
【The invention's effect】
As described above, according to the stepping motor control device of the present invention, when the host operates the stepping motor, it is not necessary to perform a difficult calculation for calculating the number of pulses each time, and the number of pulses is stored in the data file. Rather than writing in advance the target rotation time and target rotation angle, which are intuitive information, along with the relative time to be executed, the stepping motor can be automatically operated from the computer. .
[0019]
In addition, even if the high-speed pulse rate is small or large, apparently (by software processing), by improving the performance, automatic control of a more precise stepping motor, which has not been realized until now, is performed. It became possible.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration of a device of the present invention.
FIG. 2 is a flowchart showing a processing procedure according to the embodiment of the present invention.
FIG. 3 is a conceptual diagram of trapezoidal driving of a stepping motor.
FIG. 4 is a diagram showing a relationship between RH and speed at high speed.
FIG. 5 is a diagram showing a relationship between a target rotation time and an actual rotation time when 1 ≦ RH <Rmmin.
FIG. 6 is a diagram illustrating a relationship between a target rotation time and an actual rotation time when Rmax <RH ≦ 255.