![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ライブラリ化を行った後
Dependencies: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_Practice1 by
Diff: main.cpp
- Revision:
- 50:e4e1f38d1bd5
- Parent:
- 49:b041c815c063
- Child:
- 51:70d45b959d6b
diff -r b041c815c063 -r e4e1f38d1bd5 main.cpp --- a/main.cpp Wed Sep 13 01:25:07 2017 +0000 +++ b/main.cpp Wed Sep 13 02:17:38 2017 +0000 @@ -13,6 +13,7 @@ #include "cyclic.h" #include "cyclic_IO.h" #include "cylinder.h" +#include "varEvent.h" #define pc_baud 460800 #define sbdbt_tx p13 @@ -54,8 +55,6 @@ #define pin_cylinder_reload p15 #define pin_sbdbt_pairing p12 #define pin_sbdbt_indicator p11 -//#define pin_servo_reload p29 // -//#define pin_interrupt_reload p30 // DigitalOut led1(LED1); DigitalOut led2(LED2); @@ -83,13 +82,9 @@ Encoder enc_cylinder(encoder_A,encoder_B); Cyclic cyclic_servo; Cyclic_IO cylinder_reload(pin_cylinder_reload); - -//追加 PwmOut servo(pin_servo); -Timeout timer_servo; DigitalOut sbdbt_indigator(pin_sbdbt_indicator); -//Servo servo_reload(pin_servo_reload); -//DigitalIn interrupt_reload(pin_interrupt_reload); +varEvent event; void setup(); void output(); @@ -132,9 +127,9 @@ led2 = interrupt_sholderleft_min; led3 = interrupt_sholderright_max; led4 = interrupt_sholderright_min; - //pc.printf("Pulses is: %lo\tdeg :%f\r\n",enc_cylinder.pulse(),enc_cylinder.deg()); - //pc.printf("rise state : %d\r\n",cyclic_servo.getState()); - pc.printf("Sbdbtstate : %d\r\n",sbdbt.get_pairingState()); + + event.input(sbdbt.left); + pc.printf("riseState %d : fallState %d\r\n",event.getRiseState(),event.getFallState()); } } @@ -158,8 +153,6 @@ v4.setup(acceleration,output_period); enc_cylinder.setup(100); enc_cylinder.set_parameter(enc_Kp,enc_Ki,enc_Kd); - - //追加 servo.period(0.020); } @@ -212,7 +205,6 @@ } } -//追記(動作未確認) void cylinder_cal() { cylinder.cyclic(sbdbt.shikaku); //cylinder ON/OFF @@ -224,24 +216,9 @@ cylinder_origin_flag=1; } } - enc_cylinder.cal((float)cylinder_pos[cylinder_pos_num],output_period); //コントローラで数値設定 + enc_cylinder.cal((float)cylinder_pos[cylinder_pos_num],output_period); //set cylinder_tergetPos //pc.printf("terget\t%f\tnow_deg\t%f\tnow_pulse\t%d\tpwm\t%f\r\n",cylinder_pos[cylinder_pos_num],enc_cylinder.deg(),enc_cylinder.pulse(),enc_cylinder.duty()); - -//リロード機構完成後 - /* - if(cylinder.getInState() == 1){ - if(interrupt_cylinder_min)servo_reload = 1.0; - }else{ - servo_reload = 0.0; - reload_magazine_flag = 1; - } - - if(reload_magazine_flag == 1){ - rs422.put(n6_id, 0.8, 0.0); - if(interrupt_reload == 1)reload_magazine_flag = 0; - } - */ } void servo_max()