2017年度の製作を開始します。
Dependencies: Control_Yokutan_CANver1 ADXL345_I2C mbed MPU6050
Fork of Souda_Yokutan_ver528TF by
Diff: main.cpp
- Branch:
- XBus???
- Revision:
- 25:e8bfb629e1b1
- Parent:
- 24:d416722b4aad
- Parent:
- 23:d551db88df65
- Child:
- 26:f14579683f98
diff -r d416722b4aad -r e8bfb629e1b1 main.cpp --- a/main.cpp Wed Feb 15 13:27:52 2017 +0000 +++ b/main.cpp Wed Feb 15 13:29:20 2017 +0000 @@ -8,18 +8,18 @@ #define TO_SEND_DATAS_NUM 7 #define INIT_SERVO_PERIOD_MS 20 #define WAIT_LOOP_TIME 0.02 -#define CONTROL_VALUES_NUM 2 +#define CONTROL_VALUES_NUM sizeof(float) + 1 #define TO_SEND_CAN_ID 100 #define ADXL_MEAN_NUM 10 #define SEND_DATAS_LOOP_TIME 0.1 #define RECEIVE_DATAS_LOOP_TIME 0.05 -#define ERURON_MOVE_DEG_INI_R 10 // もともと10 +#define ERURON_MOVE_DEG_INI_R 30 // もともと10 #define DRUG_MOVE_DEG_INI_R 76 #define ERURON_TRIM_INI_R 97 //元々94 #define DRUG_TRIM_INI_R 33 -#define ERURON_MOVE_DEG_INI_L -8 //もともと-7 +#define ERURON_MOVE_DEG_INI_L -30 //もともと-7 #define DRUG_MOVE_DEG_INI_L -80 #define ERURON_TRIM_INI_L 113 //元々95 #define DRUG_TRIM_INI_L 110 @@ -55,12 +55,13 @@ Ticker receiveDatasTicker; char toSendDatas[TO_SEND_DATAS_NUM]; -char controlValues[CONTROL_VALUES_NUM];//0:eruruon,1:drug - +char controlValues[CONTROL_VALUES_NUM];//0~3:eruruon,4:drug +char floatvalues[sizeof(float)]; float eruronTrim; float drugTrim; float eruronMoveDeg; float drugMoveDeg; +float eruronfloat; unsigned short ina_val; double V,C; bool SERVO_FLAG; @@ -192,7 +193,9 @@ if(can.read(recmsg)){ for(int i = 0; i < CONTROL_VALUES_NUM; i++){ controlValues[i] = recmsg.data[i]; + if(i<CONTROL_VALUES_NUM-1) floatvalues[i] = controlValues[i]; } + eruronfloat = *(const float *)floatvalues; led1 = !led1; //WriteServo(); } @@ -221,8 +224,9 @@ // } // else{ // led3 = 0; - eruronServo.pulsewidth(calcPulse(eruronTrim+eruronMoveDeg*(controlValues[0]-1))); - drugServo.pulsewidth(calcPulse(drugTrim+drugMoveDeg*controlValues[1])); +// eruronServo.pulsewidth(calcPulse( eruronTrim + eruronMoveDeg * (controlValues[0]-1) )); + drugServo.pulsewidth(calcPulse( drugTrim + drugMoveDeg * controlValues[4])); + eruronServo.pulsewidth(calcPulse( eruronTrim + eruronMoveDeg * (eruronfloat-1) )); //} } @@ -238,7 +242,7 @@ } //pc.printf("eruronTrim:%f drugTrim:%f\n\r",eruronTrim,drugTrim); pc.printf("eruronTrim:%f drugTrim:%f ",eruronTrim,drugTrim); - pc.printf("eMD:%f dMD:%f\n\r",eruronMoveDeg,drugMoveDeg); + pc.printf("eMD:%f dMD:%f ef:%f\n\r",eruronMoveDeg,drugMoveDeg,eruronfloat); } void checkMaxDeg(){ @@ -255,7 +259,7 @@ } // pc.printf("eMD:%f dMD:%f\n\r",eruronMoveDeg,drugMoveDeg); pc.printf("eruronTrim:%f drugTrim:%f ",eruronTrim,drugTrim); - pc.printf("eMD:%f dMD:%f\n\r",eruronMoveDeg,drugMoveDeg); + pc.printf("eMD:%f dMD:%f ef:%f\n\r",eruronMoveDeg,drugMoveDeg,eruronfloat); wait_us(10); } @@ -275,7 +279,7 @@ } // pc.printf("eT:%f\n\r",eruronTrim); pc.printf("eruronTrim:%f drugTrim:%f ",eruronTrim,drugTrim); - pc.printf("eMD:%f dMD:%f\n\r",eruronMoveDeg,drugMoveDeg); + pc.printf("eMD:%f dMD:%f ef:%f\n\r",eruronMoveDeg,drugMoveDeg,eruronfloat); led4 = 0; debugLED = 0;