Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
System/Process/Process.cpp
- Committer:
- t_yamamoto
- Date:
- 2018-01-27
- Revision:
- 7:f4252ddc480d
- Parent:
- 6:c294736ba99d
- Child:
- 8:cb53beff4bb2
File content as of revision 7:f4252ddc480d:
//2018/01/26のやつ
#include "Process.h"
#include "mbed.h"
#include "../../Communication/XBee/XBee.h"
#include "../../Input/Switch/Switch.h"
#include "../../Output/Motor/Motor.h"
//_____________________
/*---------------- HOW TO WRITE ----------------/
・motor の割り当てを決める
#define TIRE_L 1
・リミットスイッチの割り当てを決める
#define ARM_L 1
・他にも自由に定義してもいいです (pwmとか)
/---------------- HOW TO WRITE ----------------*/
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
//_____________________
// #define USE_USB_SERIAL
#ifdef USE_USB_SERIAL
Serial pc(SERIAL_TX, SERIAL_RX);
#endif
XBEE::ControllerData *controller;
MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
using namespace SWITCH;
void SystemProcess(void) {
while(true) {
controller = XBEE::Controller::GetData();
//____________________________
/*------------------------ HOW TO WRITE ------------------------/
ここにメインのプログラムを書く
・コントローラから受け取ったデータをもとに動作のプログラムを書く
(コントローラのデータは controller-> で取る)
if(controller->Button.RIGHT) {
motor[TIRE_L].dir = FOR;
motor[TIRE_R].dir = BACK;
motor[TIRE_L].pwm = 12.3;
motor[TIRE_R].pwm = 12.3;
}
motor[0].dirは FOR (正転)
BACK (逆転)
BRAKE (ブレーキ)
FREE (フリー)
motor[0].pwmは 0.0(%) ~ 100.0(%)
controllerは XBee.hの構造体の中身
(AnalogL・Rを使いたかったら、頑張って考える or 聞いてください)
・リミットスイッチの値をもとに動作のプログラムを書く
if(Switch::CheckPushed(ARM_L))
{
if(controller->Button.L)
{
motor[ARM].dir = FOR;
motor[ARM].pwm = 80.0;
}
if(motor[ARM].dir == BACK)
{
motor[ARM].dir = BRAKE;
}
}
→関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false)
・他にもやりたいことがあったら自由にどうぞ
ps.わからないことがあったら聞いてください
/------------------------ HOW TO WRITE ------------------------*/
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
//____________________________
MOTOR::Motor::Update(motor);
}
}