View Single Post
Old 10-11-2012, 03:16 AM   #1
trienst
Nhập môn đệ tử
 
Tham gia ngày: Oct 2012
Bài gửi: 8
:
cấp cứu động cơ bước

em đang thực hiện mô phỏng động cơ bước, chỉ đơn giản là dùng bảng dịch trạng thái động cơ bước điều khiển nửa bước
code:
#include <stdio.h>
#include <stdlib.h>
#include <p18f452.h>
#include<delays.h>
#pragma config WDT = OFF, OSC = HS
void main()
{
TRISC=0x00;
PORTC=0x00;
TRISD=0xff;
while(1)
{
if(PORTDbits.RD0==0){
PORTC=0x10;
Delay10TCYx(2);
PORTC=0x50;
Delay10TCYx(2);
PORTC=0x40;
Delay10TCYx(2);
PORTC=0x60;
Delay10TCYx(2);
PORTC=0x20;
Delay10TCYx(2);
PORTC=0xa0;
Delay10TCYx(2);
PORTC=0x80;
Delay10TCYx(2);
PORTC=0x90;
Delay10TCYx(2);
}
//cambio di rotazione
if(PORTDbits.RD1==0){
PORTC=0x90;
Delay10TCYx(2);
PORTC=0x80;
Delay10TCYx(2);
PORTC=0xa0;
Delay10TCYx(2);
PORTC=0x20;
Delay10TCYx(2);
PORTC=0x60;
Delay10TCYx(2);
PORTC=0x40;
Delay10TCYx(2);
PORTC=0x50;
Delay10TCYx(2);
PORTC=0x10;
Delay10TCYx(2);
}
}
}
nhưng động cơ ko chạy, trễ khi nhấn nút rất nhiều, mong mọi người giúp đỡ
Hình Kèm Theo
File Type: jpg stepper.JPG (229.3 KB, 3 lần tải)
trienst vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn