aaaaa

Dependencies:   mbed Servo

Committer:
t_yamamoto
Date:
Sat Feb 24 07:32:11 2018 +0000
Revision:
8:cb53beff4bb2
Parent:
7:f4252ddc480d
Child:
9:6901b1dfa688
Sensor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 8:cb53beff4bb2 1 //2018/02/24のやつ
t_yamamoto 5:a802ab60df1b 2
t_yamamoto 0:562021ed1ba9 3 #include "Process.h"
t_yamamoto 0:562021ed1ba9 4
t_yamamoto 0:562021ed1ba9 5 #include "mbed.h"
t_yamamoto 0:562021ed1ba9 6 #include "../../Communication/XBee/XBee.h"
t_yamamoto 0:562021ed1ba9 7 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:562021ed1ba9 8 #include "../../Output/Motor/Motor.h"
t_yamamoto 8:cb53beff4bb2 9 #include "../../Output/Servo/Servo.h"
t_yamamoto 8:cb53beff4bb2 10
t_yamamoto 0:562021ed1ba9 11 //_____________________
t_yamamoto 0:562021ed1ba9 12 /*---------------- HOW TO WRITE ----------------/
t_yamamoto 0:562021ed1ba9 13
t_yamamoto 0:562021ed1ba9 14 ・motor の割り当てを決める
t_yamamoto 0:562021ed1ba9 15 #define TIRE_L 1
t_yamamoto 0:562021ed1ba9 16
t_yamamoto 0:562021ed1ba9 17 ・リミットスイッチの割り当てを決める
t_yamamoto 0:562021ed1ba9 18 #define ARM_L 1
t_yamamoto 0:562021ed1ba9 19
t_yamamoto 0:562021ed1ba9 20 ・他にも自由に定義してもいいです (pwmとか)
t_yamamoto 0:562021ed1ba9 21
t_yamamoto 0:562021ed1ba9 22 /---------------- HOW TO WRITE ----------------*/
t_yamamoto 0:562021ed1ba9 23 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 24
t_yamamoto 0:562021ed1ba9 25
t_yamamoto 0:562021ed1ba9 26
t_yamamoto 0:562021ed1ba9 27
t_yamamoto 0:562021ed1ba9 28
t_yamamoto 0:562021ed1ba9 29 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
t_yamamoto 0:562021ed1ba9 30 //_____________________
t_yamamoto 0:562021ed1ba9 31
t_yamamoto 8:cb53beff4bb2 32 //#define USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 33 #ifdef USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 34 Serial pc(SERIAL_TX, SERIAL_RX);
t_yamamoto 0:562021ed1ba9 35 #endif
t_yamamoto 0:562021ed1ba9 36 XBEE::ControllerData *controller;
t_yamamoto 0:562021ed1ba9 37 MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:562021ed1ba9 38
t_yamamoto 0:562021ed1ba9 39 using namespace SWITCH;
t_yamamoto 0:562021ed1ba9 40
t_yamamoto 8:cb53beff4bb2 41 void SystemProcess(void) {
t_yamamoto 0:562021ed1ba9 42 while(true) {
t_yamamoto 0:562021ed1ba9 43 controller = XBEE::Controller::GetData();
t_yamamoto 0:562021ed1ba9 44 //____________________________
t_yamamoto 0:562021ed1ba9 45 /*------------------------ HOW TO WRITE ------------------------/
t_yamamoto 0:562021ed1ba9 46
t_yamamoto 0:562021ed1ba9 47 ここにメインのプログラムを書く
t_yamamoto 0:562021ed1ba9 48
t_yamamoto 0:562021ed1ba9 49 ・コントローラから受け取ったデータをもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 50 (コントローラのデータは controller-> で取る)
t_yamamoto 0:562021ed1ba9 51
t_yamamoto 0:562021ed1ba9 52 if(controller->Button.RIGHT) {
t_yamamoto 0:562021ed1ba9 53 motor[TIRE_L].dir = FOR;
t_yamamoto 0:562021ed1ba9 54 motor[TIRE_R].dir = BACK;
t_yamamoto 7:f4252ddc480d 55 motor[TIRE_L].pwm = 12.3;
t_yamamoto 7:f4252ddc480d 56 motor[TIRE_R].pwm = 12.3;
t_yamamoto 0:562021ed1ba9 57 }
t_yamamoto 0:562021ed1ba9 58
t_yamamoto 6:c294736ba99d 59 motor[0].dirは FOR (正転)
t_yamamoto 0:562021ed1ba9 60 BACK (逆転)
t_yamamoto 0:562021ed1ba9 61 BRAKE (ブレーキ)
t_yamamoto 0:562021ed1ba9 62 FREE (フリー)
t_yamamoto 0:562021ed1ba9 63
t_yamamoto 0:562021ed1ba9 64 motor[0].pwmは 0.0(%) ~ 100.0(%)
t_yamamoto 0:562021ed1ba9 65
t_yamamoto 0:562021ed1ba9 66 controllerは XBee.hの構造体の中身
t_yamamoto 0:562021ed1ba9 67
t_yamamoto 0:562021ed1ba9 68 (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください)
t_yamamoto 0:562021ed1ba9 69
t_yamamoto 0:562021ed1ba9 70 ・リミットスイッチの値をもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 71
t_yamamoto 0:562021ed1ba9 72 if(Switch::CheckPushed(ARM_L))
t_yamamoto 0:562021ed1ba9 73 {
t_yamamoto 0:562021ed1ba9 74 if(controller->Button.L)
t_yamamoto 0:562021ed1ba9 75 {
t_yamamoto 6:c294736ba99d 76 motor[ARM].dir = FOR;
t_yamamoto 0:562021ed1ba9 77 motor[ARM].pwm = 80.0;
t_yamamoto 0:562021ed1ba9 78 }
t_yamamoto 0:562021ed1ba9 79 if(motor[ARM].dir == BACK)
t_yamamoto 0:562021ed1ba9 80 {
t_yamamoto 0:562021ed1ba9 81 motor[ARM].dir = BRAKE;
t_yamamoto 0:562021ed1ba9 82 }
t_yamamoto 0:562021ed1ba9 83 }
t_yamamoto 0:562021ed1ba9 84
t_yamamoto 0:562021ed1ba9 85 →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false)
t_yamamoto 0:562021ed1ba9 86
t_yamamoto 0:562021ed1ba9 87 ・他にもやりたいことがあったら自由にどうぞ
t_yamamoto 0:562021ed1ba9 88
t_yamamoto 0:562021ed1ba9 89 ps.わからないことがあったら聞いてください
t_yamamoto 0:562021ed1ba9 90
t_yamamoto 0:562021ed1ba9 91 /------------------------ HOW TO WRITE ------------------------*/
t_yamamoto 0:562021ed1ba9 92 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 93
t_yamamoto 0:562021ed1ba9 94
t_yamamoto 0:562021ed1ba9 95
t_yamamoto 0:562021ed1ba9 96
t_yamamoto 0:562021ed1ba9 97
t_yamamoto 0:562021ed1ba9 98
t_yamamoto 0:562021ed1ba9 99
t_yamamoto 0:562021ed1ba9 100
t_yamamoto 0:562021ed1ba9 101 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
t_yamamoto 0:562021ed1ba9 102 //____________________________
t_yamamoto 0:562021ed1ba9 103
t_yamamoto 0:562021ed1ba9 104 MOTOR::Motor::Update(motor);
t_yamamoto 0:562021ed1ba9 105 }
t_yamamoto 0:562021ed1ba9 106 }
t_yamamoto 0:562021ed1ba9 107