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を参照してください。
mdc.h
- Committer:
- DaichiArai
- Date:
- 2019-06-27
- Revision:
- 10:1bbe0d41813e
- Parent:
- 9:a3a2fb1a3ba7
File content as of revision 10:1bbe0d41813e:
#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 #define DPI 6.2832 #include "mbed.h" class motor{ public: motor(I2C &i2c, int addr); int move(float pwm = 1000); void reset(); //enc------------------------------------------------------------------- int count; float angle(); float angle_data; float position_data; //----------------------------------------------------------------------------- char data[2]; private: char data_reset[2]; char md_data[2]; void result(); int write_pwm; int val; int address; float encoder_spd; float position_angle; I2C mdc_i2c; }; #endif