8051/PIC > DT516-180.c 유니폴라 스텝모터구동

TODAY1,528 TOTAL2,701,433
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 8051/PIC | DT-516 강좌 | DT516-180.c 유니폴라 스텝모터구동

페이지 정보

작성자 키트 작성일2017-09-12 10:01 조회1,730회 댓글0건

본문

//-------------------------------------------------------------
// 82G516 E/V BOARD ( DT-516 )
// 2011.09.12
//-------------------------------------------------------------
// XTAL : 22.1184Hz
//-------------------------------------------------------------
// filename: DT516-180.c
// 스텝모터 구동 
//-------------------------------------------------------------
#include <REG_MPC82G516.H>
//
#include "DT516-main.h"
//
U_I count=0;
//
U_C m_tbl_1[4] ={0x01,0x02,0x04,0x08};
U_C m_tbl_2[4] ={0x09,0x03,0x06,0x0C};
U_C m_tbl_12[8]={0x09,0x01,0x03,0x02,0x06,0x04,0x0C,0x08};
//
void ADC_Interrupt(void) interrupt 9{ // ADC_Interrupt:
}
//
void Timer_0_Interrupt(void) interrupt 1{ // 7200Hz주기
    P4=0xFF; // FND OFF
    switch(FND_CNT){
        case 0: P0=Seg_Data[count/1000];     FND_COM1=0; break;
        case 1: P0=Seg_Data[(count/100)%10]; FND_COM2=0; break;
        case 2: P0=Seg_Data[(count/ 10)%10]; FND_COM3=0; break;
        case 3: P0=Seg_Data[count%10];       FND_COM4=0; break;
    }
    if(++FND_CNT>3)FND_CNT=0;
    //
    if(delay_buf){ if(--delay_buf==0)delay_flg=1; }
}
//
void main(){
    int i,step=0;
    TMOD=2; ET0=1; TR0=1; EA=1;
    while(1){
        for(i=0;i<50;i++){ if(++step>3)step=0; P2=m_tbl_1[i]; delay_ms(1); } // CW 90도 // 1상구동
        for(i=0;i<50;i++){ if(--step<0)step=3; P2=m_tbl_1[i]; delay_ms(1); } // CCW 90도 // 1상구동
    }
}
//-------------------------------------------------------------

댓글 0

조회수 1,730

등록된 댓글이 없습니다.

8051/PICHOME > 8051/PIC > DT-516 강좌 목록

게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기