This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define INH_U 6 | |
#define INH_V 7 | |
#define INH_W 8 | |
#define INL_U 9 | |
#define INL_V 10 | |
#define INL_W 11 | |
#define ENABLE 13 | |
#define delay_time 1 | |
#define duty_high 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include "DSHOT.h" | |
#include "ESCCMD.h" | |
#define ESCPID_USB_UART_SPEED 115200 //シリアル通信の速度 | |
#define ESCPID_NB_ESC 1 //ESCの数 | |
const float LOGGING_CYCLE = 0.01; //ログ周期[s] | |
IntervalTimer Timer; //10msの割り込み |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(115200); // Terminal | |
Serial1.begin(100000, SERIAL_8E2); // S-BUS | |
} | |
void loop() { | |
static int state = 0; //受信状態を格納する変数 | |
static int cnt = 0; //カウント変数 | |
static byte buff[25]; //受信データ用バッファ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PWM出力に関しての詳細はhttps://www.pjrc.com/teensy/td_pulse.html | |
//エンコーダに関しての詳細はhttps://www.pjrc.com/teensy/td_libs_Encoder.html | |
//タイマー割込みに関しての詳細はhttps://www.pjrc.com/teensy/td_timing_IntervalTimer.html | |
//Teensyの標準ヘッダファイル | |
#include <Encoder.h> | |
//定数の宣言 | |
#define GEAR (32*33*35*38) / (15*14*13*10)//モータのギア比 | |
#define PULSE 12.0 //エンコーダのパルス数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PWM出力に関しての詳細はhttps://www.pjrc.com/teensy/td_pulse.html | |
//エンコーダに関しての詳細はhttps://www.pjrc.com/teensy/td_libs_Encoder.html | |
//タイマー割込みに関しての詳細はhttps://www.pjrc.com/teensy/td_timing_IntervalTimer.html | |
//Teensyの標準ヘッダファイル | |
#include <Encoder.h> | |
//定数の宣言 | |
#define GEAR (32*33*35*38) / (15*14*13*10)//モータのギア比 | |
#define PULSE 12.0 //エンコーダのパルス数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
clc; | |
%% シミュレーション用のモデル作成 | |
dt=0.001; %シミュレーション周期[s] | |
Tc=0.001; %マイコン制御周期[s] | |
FinishTime=1.2; %シミュレーションの終了時間[s] | |
% 359.2 | |
% ------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
clc; | |
%エクセルファイルから入出力データの取り込み | |
FR.u = xlsread('DCmotor_FR_500Hz.xlsx',1,'B1:B15714'); | |
FR.y = xlsread('DCmotor_FR_500Hz.xlsx',1,'D1:D15714'); | |
FRdata = iddata(FR.y,FR.u,0.002); %IDDATA オブジェクトの作成 | |
FRdata.InputName = '電圧 [V]'; %入力データの名前 | |
FRdata.OutputName = '角速度 [rad/s]';%出力データの名前 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PWM出力に関しての詳細はhttps://www.pjrc.com/teensy/td_pulse.html | |
//エンコーダに関しての詳細はhttps://www.pjrc.com/teensy/td_libs_Encoder.html | |
//タイマー割込みに関しての詳細はhttps://www.pjrc.com/teensy/td_timing_IntervalTimer.html | |
//Teensyの標準ヘッダファイル | |
#include <Encoder.h> | |
//定数の宣言 | |
#define GEAR (32*33*35*38) / (15*14*13*10)//モータのギア比 | |
#define PULSE 12.0 //エンコーダのパルス数 |