MDC2018のデータ量を削減したプログラムのマスタ側(メインマイコン)のプログラム

Dependents:  

モータドライバコントローラ2018(MDC)

モータドライバコントローラ(MDC2018)は、2018年に開発されたモータドライバを制御するためのドライバ回路です。

基本データ

分類名称など
CPUSTM32F303K8T6
主用途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:
2018-10-16
Revision:
7:6d3ea87a81c7
Parent:
4:2ed7cf5feb7c
Child:
9:a3a2fb1a3ba7

File content as of revision 7:6d3ea87a81c7:

#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 I2C i2c;

class motor{
    public:
        motor(int addr);
        int move(int spd = 1000);
        void reset_enc();
//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 data_reset[2];
        char md_data[2];
        void result();
        int val;
};

#endif