2018.07.26

Dependencies:   QEI mbed

Committer:
sayzyas
Date:
Thu Jul 26 00:21:10 2018 +0000
Revision:
0:b022386f217f
2018.07.26

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sayzyas 0:b022386f217f 1 /*
sayzyas 0:b022386f217f 2 * mbed LPC824-Max header
sayzyas 0:b022386f217f 3 *
sayzyas 0:b022386f217f 4 */
sayzyas 0:b022386f217f 5
sayzyas 0:b022386f217f 6 // If you use moving type winch , then should comment out followings !!
sayzyas 0:b022386f217f 7 // #define FFWinchPhaseSetting // Valid if Fix falling winch system is using.
sayzyas 0:b022386f217f 8
sayzyas 0:b022386f217f 9 #define __DEBUG__
sayzyas 0:b022386f217f 10 #ifdef __DEBUG__
sayzyas 0:b022386f217f 11 #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 12 #else
sayzyas 0:b022386f217f 13 #define DEBUG_PRINT(...) ;
sayzyas 0:b022386f217f 14 //#define DEBUG_PRINT(...) 1 ? (void)0 : pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 15 #endif
sayzyas 0:b022386f217f 16 /* Information */
sayzyas 0:b022386f217f 17 #define LatestUpDate "2016.09.27"
sayzyas 0:b022386f217f 18 #define ProgramRevision "Rev 2.30"
sayzyas 0:b022386f217f 19 #define Author "Y.Saito(zinsor)"
sayzyas 0:b022386f217f 20 #define Company "Revast Co.,Ltd"
sayzyas 0:b022386f217f 21
sayzyas 0:b022386f217f 22
sayzyas 0:b022386f217f 23 /* Debug macro */
sayzyas 0:b022386f217f 24 #define __DEBUG_L0__
sayzyas 0:b022386f217f 25 #define __DEBUG_L1__
sayzyas 0:b022386f217f 26 #define __DEBUG_L2__
sayzyas 0:b022386f217f 27 #define __DEBUG_L3__
sayzyas 0:b022386f217f 28 #define __DEBUG_L4__
sayzyas 0:b022386f217f 29
sayzyas 0:b022386f217f 30 #ifdef __DEBUG_L0__
sayzyas 0:b022386f217f 31 #define DEBUG_PRINT_L0(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 32 #else
sayzyas 0:b022386f217f 33 #define DEBUG_PRINT_L0(...)
sayzyas 0:b022386f217f 34 #endif
sayzyas 0:b022386f217f 35 #ifdef __DEBUG_L1__
sayzyas 0:b022386f217f 36 #define DEBUG_PRINT_L1(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 37 #else
sayzyas 0:b022386f217f 38 #define DEBUG_PRINT_L1(...)
sayzyas 0:b022386f217f 39 #endif
sayzyas 0:b022386f217f 40 #ifdef __DEBUG_L2__
sayzyas 0:b022386f217f 41 #define DEBUG_PRINT_L2(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 42 #else
sayzyas 0:b022386f217f 43 #define DEBUG_PRINT_L2(...)
sayzyas 0:b022386f217f 44 #endif
sayzyas 0:b022386f217f 45 #ifdef __DEBUG_L3__
sayzyas 0:b022386f217f 46 #define DEBUG_PRINT_L3(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 47 #else
sayzyas 0:b022386f217f 48 #define DEBUG_PRINT_L3(...)
sayzyas 0:b022386f217f 49 #endif
sayzyas 0:b022386f217f 50 #ifdef __DEBUG_L4__
sayzyas 0:b022386f217f 51 #define DEBUG_PRINT_L4(...) pc.printf(__VA_ARGS__)
sayzyas 0:b022386f217f 52 #else
sayzyas 0:b022386f217f 53 #define DEBUG_PRINT_L4(...)
sayzyas 0:b022386f217f 54 #endif
sayzyas 0:b022386f217f 55
sayzyas 0:b022386f217f 56 #define NumberOfI2CCommand 14
sayzyas 0:b022386f217f 57
sayzyas 0:b022386f217f 58 /* For resolver reader controller */
sayzyas 0:b022386f217f 59 enum{
sayzyas 0:b022386f217f 60 I2C_CP_PREAMBLE_R, // Preamble of command packet
sayzyas 0:b022386f217f 61 I2C_CP_COMMAND_R, // instruction command
sayzyas 0:b022386f217f 62 I2C_CP_WDRAM_DIA_UPPER, // motor1 rotation direction
sayzyas 0:b022386f217f 63 I2C_CP_WDRAM_DIA_LOWER, // motor1 rotation speed
sayzyas 0:b022386f217f 64 I2C_CP_CCABLE_DIA_UPPER, // motor1 current limit detection threshold upper byte
sayzyas 0:b022386f217f 65 I2C_CP_CCABLE_DIA_LOWER, // motor1 current limit detection threshold lower byte
sayzyas 0:b022386f217f 66 I2C_CP_RESOLVER_RESO, // motor1 current limit detection threshold upper byte
sayzyas 0:b022386f217f 67 I2C_CP_PRESET_CPOS_UPPER, // reserved
sayzyas 0:b022386f217f 68 I2C_CP_PRESET_CPOS_LOWER, // reserved
sayzyas 0:b022386f217f 69 I2C_CP_RES3, // reserved
sayzyas 0:b022386f217f 70 I2C_CP_RES4, // reserved
sayzyas 0:b022386f217f 71 I2C_CP_RES5, // reserved
sayzyas 0:b022386f217f 72 I2C_CP_RES6, // reserved
sayzyas 0:b022386f217f 73 I2C_CP_RES7, // reserved
sayzyas 0:b022386f217f 74 };
sayzyas 0:b022386f217f 75
sayzyas 0:b022386f217f 76 #define ROTATE_PER_RESOLUTION 24
sayzyas 0:b022386f217f 77 #define REAL_THREAD_DIAMETER 63 // 60+3
sayzyas 0:b022386f217f 78 //#define ROTATION_DISTANCE 197.82f // (60+3)*3.14
sayzyas 0:b022386f217f 79 #define ROTATION_PULSE_PER_1ROUND 16384 // 2^12(bit) * 4
sayzyas 0:b022386f217f 80 #define PAI 3.14159265359
sayzyas 0:b022386f217f 81
sayzyas 0:b022386f217f 82 /* ***************** */
sayzyas 0:b022386f217f 83 /* Target definition */
sayzyas 0:b022386f217f 84 /* ***************** */
sayzyas 0:b022386f217f 85 #define I2C_ADDRESS_RESOLVER 0x02
sayzyas 0:b022386f217f 86 #define Target_IIC_ADDR 0x02 // For Resolver count controller
sayzyas 0:b022386f217f 87
sayzyas 0:b022386f217f 88
sayzyas 0:b022386f217f 89 /* Command Packet */
sayzyas 0:b022386f217f 90 #define CLEAR_RESOLVER_POSITION 'X'
sayzyas 0:b022386f217f 91 #define HELLO_PACKET 'A'
sayzyas 0:b022386f217f 92
sayzyas 0:b022386f217f 93 #define LED_ON 0
sayzyas 0:b022386f217f 94 #define LED_OFF 1