다음의 예와 같이 define을 1번과 같이 할 경우에는 이상이 없지만.
2번과 같이 할 경우에는 모터의 동작이 이상하게 동작합니다.
둘다 컴파일 에러는 없지만, 1번에서만 다음과 같은 warning은 발생합니다.
"warning: integer operation result is out of range"
//==============================================
// 1번
#define MOTOR_INTERPOLATOR 64
#define MOTOR_POLES 12
#define MOTOR_STANDARD_LINECOUNTS 9000
#define MOTOR_POLE_PAIRS (MOTOR_POLES * 0.5)
#define MOTOR_RESOLUTION (MOTOR_STANDARD_LINECOUNTS * MOTOR_INTERPOLATOR)
#define MOTOR_HALF_OF_RESOLUTION (MOTOR_RESOLUTION * 0.5)
#define MOTOR_QPOSINIT (MOTOR_RESOLUTION * 2)
#define MOTOR_QPOSMAX (MOTOR_QPOSINIT * 2)
//================================================
// 2번
#define MOTOR_INTERPOLATOR 64
#define MOTOR_POLES 12
#define MOTOR_STANDARD_LINECOUNTS 9000
#define MOTOR_POLE_PAIRS 6
#define MOTOR_RESOLUTION 576000
#define MOTOR_HALF_OF_RESOLUTION 288000
#define MOTOR_QPOSINIT 1152000
#define MOTOR_QPOSMAX 2304000
위의 1번과 2번은 똑같다라고 생각되는데 다른 점이 있나요?
참고적으로 작업환경은 다음과 같습니다.
OS: Windows XP (sp3)
컴파일러: CCStudio <-- TI에서 만든 DSP 칩을 통합 컴파일러 환경
사용 MCU: TMS320F28335
모터 : 서보 모터
--------------------------------
즐거운 하루 되세요...
아~자~~!
|