Stepper Motor.rar

  • Alnahry
    了解作者
  • C/C++
    开发工具
  • 48KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-01-07 00:28
    上传日期
Stepper Motor Interfacing with AVR ATmega32
Stepper Motor.rar
内容介绍
/* * ATmega32 Stepper Motor Control * http://www.electronicwings.com * */ #define F_CPU 8000000UL /* Define CPU Frequency e.g. here its 8MHz */ #include <avr/io.h rel='nofollow' onclick='return false;'> /* Include AVR std. library file */ #include <util/delay.h> /* Include delay header file */ int main(void) { int period; DDRD = 0x0F; /* Make PORTD lower pins as output */ period = 100; /* Set period in between two steps of Stepper Motor */ while (1) { for(int i=0;i<12;i++) /* Rotate Stepper Motor clockwise with Half step sequence; Half step angle 3.75 */ { PORTD = 0x09; _delay_ms(period); PORTD = 0x08; _delay_ms(period); PORTD = 0x0C; _delay_ms(period); PORTD = 0x04; _delay_ms(period); PORTD = 0x06; _delay_ms(period); PORTD = 0x02; _delay_ms(period); PORTD = 0x03; _delay_ms(period); PORTD = 0x01; _delay_ms(period); } PORTD = 0x09; /* last one step to acquire initial position */ _delay_ms(period); _delay_ms(1000); for(int i=0;i<12;i++) /* Rotate Stepper Motor Anticlockwise with Full step sequence; Full step angle 7.5 */ { PORTD = 0x09; _delay_ms(period); PORTD = 0x03; _delay_ms(period); PORTD = 0x06; _delay_ms(period); PORTD = 0x0C; _delay_ms(period); } PORTD = 0x09; _delay_ms(period); _delay_ms(1000); } }
评论
    相关推荐