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.
Revision 18:c61ba21bbc67, committed 2022-01-29
- Comitter:
- gennnisi
- Date:
- Sat Jan 29 15:43:32 2022 +0000
- Parent:
- 17:9ee4c69d2d8b
- Child:
- 19:fbb3b5331641
- Commit message:
- a
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 27 07:29:51 2022 +0000
+++ b/main.cpp Sat Jan 29 15:43:32 2022 +0000
@@ -4,22 +4,20 @@
#include "scrp_slave.hpp"
#include "Motor.hpp"
-Motor motor_revolver(PB_4,PB_5);//リボルバーモーター
-Motor motor_shoot(PB_1,PA_11);//発射機構モーター
-PwmOut servo(PB_8);//ロック解除用サーボ
+Motor motor_revolver(PA_8,PA_7);//リボルバーモーター
+Motor motor_shoot(PB_6,PA_11);//発射機構モーター
+PwmOut servo(PA_1);//ロック解除用サーボ
-//ScrpSlave slave(PA_9,PA_10,PA_12,SERIAL_TX,SERIAL_RX,0x0803f800);//l432kc
-ScrpSlave slave(PC_12,PD_2,PH_1,SERIAL_TX,SERIAL_RX,0x0807f800);
+ScrpSlave slave(PA_9,PA_10,PA_12,SERIAL_TX,SERIAL_RX,3);//id=3
-//RotaryInc v(PA_14,PA_15,1,1024,4);//リボルバーロリコン
-RotaryInc v(PA_14,PA_15,1,1024,2);
+RotaryInc v(PA_0,PA_4,1,1024,2);//リボルバーロリコン
-DigitalIn limit_1(PA_9);//リミットスイッチ1
-DigitalIn limit_2(PA_8);//リミットスイッチ2
+DigitalIn limit_1(PB_0);//リミットスイッチ1
+DigitalIn limit_2(PB_1);//リミットスイッチ2
int shoot_phase = 0;//発射フェーズ 0:待機 1:装填動作 2:リボルバー回転、モーター復帰(同時) 3:発射
-bool turn_able = 0;//回転可否 0:待機 1:回転
-bool back_able = 0;//復帰可否
+bool turn_able = 0;//回転可否
+bool back_able = 0;//復帰可否
double revolver_pwm = -0.03;//リボルバー回転速度
double load_pwm = -0.3;//装填モーター速度
@@ -33,7 +31,7 @@
bool interrupt(int rx_data,int &tx_data){
if(shoot_phase == 0){//フェーズ0以外は、発射できないように
- shoot_phase = rx_data;//1を受け取って装填動作開始
+ shoot_phase = 1;
}
return true;
}
@@ -46,7 +44,7 @@
turn_able = 0;
printf("no turn\n");
}
- if(count != 1){
+ if(count > 1){
if(roricon < 341 * (count - 1)){
if(turn_able == 1){
roricon = v.get();
@@ -72,7 +70,7 @@
printf("finished backing\n");
}
//ループ抜け出し
- if(turn_able == 0 && turn_able == 0){
+ if(turn_able == 0 && back_able == 0){
break;
}
wait(0.1);