MDC2018のデータ量を削減したプログラムのマスタ側(メインマイコン)のプログラム
モータドライバコントローラ2018(MDC)
モータドライバコントローラ(MDC2018)は、2018年に開発されたモータドライバを制御するためのドライバ回路です。
基本データ
分類 | 名称など |
CPU | STM32F303K8T6 |
主用途 | 3ピン型MDの駆動とABZ相出力型インクリメンタルエンコーダの読み取り |
製作年 | 2018年 |
通信方式 | I²C(Slave)・UART |
使用方法
- ST-LINK V2にmdc_simpleのソースコードを書き込むか、main.cppを参考にしてオリジナルのファームウェアを作成して、書き込みます。
- I²Cコネクタ経由でメインマイコンから制御します。
- 5V駆動インクリメンタルエンコーダとモータドライバ(2018年)制御端子を接続します。
詳しくは、readme.txtを参照してください。
Diff: mdc.h
- Revision:
- 3:acec9ffd0ac0
- Child:
- 4:2ed7cf5feb7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdc.h Wed Oct 03 17:18:11 2018 +0000 @@ -0,0 +1,48 @@ +#ifndef mdc_h +#define mdc_h + +#define MOTOR_FREE 0x00 +#define MOTOR_FORWARD 0x01 +#define MOTOR_BACK 0x02 +#define MOTOR_STOP 0x03 + +#define SPD_MINUS 0 +#define SPD_H 1 +#define SPD_M 2 +#define SPD_L 3 +#define COUNT_MINUS 4 +#define COUNT_SPIN 5 +#define ANGLE_MINUS 6 +#define ANGLE_H 7 +#define ANGLE_M 8 +#define ANGLE_L 9 +#define NUM 4 + +#include "mbed.h" + +extern Serial pc; +extern I2C i2c; + +class motor{ + public: + motor(int addr); + int move(int spd = 1000); +//enc------------------------------------------------------------------- + char data[10]; + float spd; + int count; + float angle; + void read(); + + float spd_e(); + int count_e(); + float angle_e(); +//----------------------------------------------------------------------------- + int address; + private: + char md_data[2]; + void result(); + int val; +}; + +#endif \ No newline at end of file