DC motor control program using TA7291P type H bridge driver and rotary encoder with A, B phase.
Fork of DCmotor2 by
Revision 22:4fd506b1c68d, committed 2016-06-10
- Comitter:
- kosakaLab
- Date:
- Fri Jun 10 04:29:13 2016 +0000
- Parent:
- 19:6c81fc207d83
- Commit message:
- nothing is changed
Changed in this revision
| controller.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/controller.cpp Wed Jul 02 04:25:28 2014 +0000
+++ b/controller.cpp Fri Jun 10 04:29:13 2016 +0000
@@ -4,7 +4,7 @@
#include "controller.h" // controller.cpp: モータ制御器(位置制御、電流制御)
#include "Hbridge.h" // Hbridge.cpp: モータ駆動用ドライバのフルブリッジ(Hブリッジ)をPWM駆動する。
-Serial pc(USBTX, USBRX); // PCのモニタ上のtera termに文字を表示する宣言
+//Serial pc(USBTX, USBRX); // PCのモニタ上のtera termに文字を表示する宣言
motor_parameters p; // モータの定数、信号など
current_loop_parameters il; // 電流制御マイナーループの定数、変数
@@ -285,7 +285,7 @@
}
void display2PC(){ // PCのモニタ上のtera termに諸量を表示 display to tera term on PC
- pc.printf("%8.1f[s]\t%8.2f[V]\t%8.2f [Hz]\t%8.2f\t%8.2f\r\n",
+ printf("%8.1f[s]\t%8.2f[V]\t%8.2f [Hz]\t%8.2f\t%8.2f\r\n",
_time, il.v_ref, vl.w_lpf/(2*PI), vl.w_ref/(2*PI), debug[0]);
// pc.printf("%8.1f[s]\t%8.5f[V]\t%4d [deg]\t%8.2f\r\n", _time, _u, (int)(_th/(2*PI)*360.0), _r);//debug[0]*3.3/R_SHUNT); // print to tera term
}
--- a/main.cpp Wed Jul 02 04:25:28 2014 +0000
+++ b/main.cpp Fri Jun 10 04:29:13 2016 +0000
@@ -17,7 +17,7 @@
#include "Hbridge.h" // Hブリッジ用
-Serial pc2(USBTX, USBRX); // PCのモニタ上のtera termに文字を表示する宣言
+//Serial pc2(USBTX, USBRX); // PCのモニタ上のtera termに文字を表示する宣言
LocalFileSystem local("mbedUSBdrive"); // PCのmbed USB ディスク上にデータをセーブする宣言
Ticker TickerTimerTS0; // タイマー割込みを宣言。1ms以下もOK。RTOSよりも優先度が高い
unsigned char fTimerTS2ON=0, fTimerTS3ON=0, fTimerTS4ON=0; // timerTS2, TS3, TS4のスタート・ストップ指定フラグ
@@ -85,7 +85,7 @@
init_parameters(); // モータの機器定数等の設定, 制御器の初期化
// シミュレーション開始
- pc2.printf("Simulation start!!\r\n"); // PCのモニタ上のtera termに文字を表示
+ printf("Simulation start!!\r\n"); // PCのモニタ上のtera termに文字を表示
#ifndef OLD
// PWMとすべてのタイマーをスタートする
start_pwm(); // PWMスタート
@@ -141,5 +141,5 @@
fclose( fp ); // PC上のmbed USB ディスクをリリース
Thread::wait(100); // セーブ完了まで待つ
- pc2.printf("Control completed!!\r\n\r\n"); // 制御実験終了をPCモニタ上に表示
+ printf("Control completed!!\r\n\r\n"); // 制御実験終了をPCモニタ上に表示
}
