====== motorSetup ====== ''void motorSetup (u8 motionID, u8 stCh, u32 freqBase, u32 freqTop, u32 stepAccel)'' |motionID : 모션제어 모듈의 ID ( 0 부터 9 까지 ) | |stCh : 채널번호 (0 또는 1 만 사용가능) | |freqBase: 시작 주파수 (최소 280 부터 사용가능) | |freqTop: 최대 주파수 (최대 50,000 까지 사용가능) | |freqAccel :가감속 주파수 | ==== 설명 ==== 모터의 움직임에 대한 기본 설정치 (시작주파수, 최대주파수, 가감속 주파수)를 셋팅하는 함수입니다. 이 함수는 셋팅만 바꿀뿐 아무 동작도 하지 않는 함수입니다. {{ :moacon:motorsetup:motorsetup.png?nolink |}} ==== 사용예 ==== #include "moacon500.h" void statprint(u32 i) { u32 j; clcdPrint(0,0,"STAT:%09d ",i); delay(20); j = getMotorPos(0,0); clcdPrint(0,1,"POS: %09d ",j); delay(20); } void cmain(void) { int i=0; clcdI2cInit(0); clcdPower(1); // lcd 의 Power 를 On delay(100); clcdCls(); clcdCsr(0); delay(2000); // 드라이버가 초기화될때까지 잠시 대기 (2 초) setMotorPos(0,0,0); // 현재위치를 0 으로 셋팅 while(1) { motorSetup(0,0,500,50000,50000); // 모터초기정보 셋팅 (50KHz 출력) motorMove(0,0,1640000); // 1640000 위치로 이동 while (i=motorStat(0,0)) { statprint(i); // 이동하는 동안 정보를 lcd 상에 표시 } delay(500); // 이동이 종료됨 i=motorStat(0,0); statprint(i); delay(3000); motorMove(0,0,0); // 원래위치로 다시 이동 while (i=motorStat(0,0)) { statprint(i); } delay(500); i=motorStat(0,0); statprint(i); delay(3000); } } [[moacon:index#-m-|라이브러리 목록으로 가기]]