z ysaito
/
Pro_B2_1ZNR_CrExpB2_MotorCtrl_LPC824MAX
2018.08.06
Diff: common.h
- Revision:
- 1:c3508bfe65b6
- Parent:
- 0:653609b2a5cf
- Child:
- 2:aeff576d5013
--- a/common.h Mon Mar 28 00:08:58 2016 +0000 +++ b/common.h Thu Apr 14 10:25:30 2016 +0000 @@ -14,9 +14,10 @@ #define __DEBUG_L0__ #define __DEBUG_L1__ -#define __DEBUG_L2__ -#define __DEBUG_L3__ +//#define __DEBUG_L2__ +//#define __DEBUG_L3__ //#define __DEBUG_L4__ +#define __DEBUG_DSPMCNT__ // Display motor current percentage value #ifdef __DEBUG_L0__ #define DEBUG_PRINT_L0(...) pc.printf(__VA_ARGS__) @@ -43,7 +44,11 @@ #else #define DEBUG_PRINT_L4(...) #endif - +#ifdef __DEBUG_DSPMCNT__ + #define DEBUG_DSPMCNT(...) pc.printf(__VA_ARGS__) +#else + #define DEBUG_DSPMCNT(...) +#endif /* Motor Controller I2C address definition */ #define I2C_ADDRESS_HANDY 0x20 @@ -92,13 +97,30 @@ FLG_MOTOR_DIR_NONE }; - +/* I2C Command packet to motor controller */ +/* For motor controller */ +enum{ + I2C_CP_PREAMBLE, // Preamble of command packet + I2C_CP_COMMAND, // instruction command + I2C_CP_M1_DIR, // motor1 rotation direction + I2C_CP_M1_SPEED, // motor1 rotation speed + I2C_CP_M1_FWD_CNTTH_U, // motor1 current limit detection threshold upper byte + I2C_CP_M1_FWD_CNTTH_L, // motor1 current limit detection threshold lower byte + I2C_CP_M1_RVS_CNTTH_U, // motor1 current limit detection threshold upper byte + I2C_CP_M1_RVS_CNTTH_L, // motor1 current limit detection threshold lower byte + I2C_CP_M2_DIR, // motor2 rotation direction + I2C_CP_M2_SPEED, // motor2 rotation speed + I2C_CP_M2_FWD_CNTTH_U, // motor2 current limit detection threshold upper byte + I2C_CP_M2_FWD_CNTTH_L, // motor2 current limit detection threshold lower byte + I2C_CP_M2_RVS_CNTTH_U, // motor2 current limit detection threshold upper byte + I2C_CP_M2_RVS_CNTTH_L, // motor2 current limit detection threshold lower byte +}; #define MC_UPPER_LIMIT 95.0f #define MC_LOWER_LIMIT 5.0f #define MC_LOCK_COUNT 5 #define NumberOfPcCommand 11 -#define NumberOfI2CCommand 10 +#define NumberOfI2CCommand 14 #define ROTATE_PER_RESOLUTION 24