Differences

This shows you the differences between two versions of the page.


moacon:motorstat:index [2026/02/20 15:34] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== motorStat ======
  
 +''u32 motorStat (u8 motionID, u8 stChannel )''
 +|motionID : 모션제어 모듈의 ID ( 0 부터 9 까지 )   
 +|stChannel : 채널번호 
 +
 +==== 설명 ====
 +현재, 출력중인 펄스의 개수를 알려주는 함수 입니다. 펄스출력이 모두 끝났다면 0 을
 +반환합니다.
 +MotorMove 함수를 실행시키면, 펄스출력은 모션제어모듈에서 알아서 출력합니다. CPU 가
 +펄스출력이 종료될때까지 기다리지 않습니다. 따라서 언제 펄스출력이 끝났는지 알아보기
 +위해서 motorStat 함수를 사용해야 합니다. 
 +
 +==== 사용예 ====
 +<code c>
 +//
 +// 스탭모터를 회전시키면서 회전상태를 CLCD 상에 회전수 (STAT)와 위치(POS)를 표시합니다. 
 +//
 +#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);
 + }
 +
 +</code>
 +
 +
 +[[moacon:index#-m-|라이브러리 목록으로 가기]]