kvtal
Member level 3
https://vkelektroniks.blogspot.in/2012/06/8051-stepper-motor-interface.html
Here u get the informatin about interfacing stepper motor with 8051
Here u get the informatin about interfacing stepper motor with 8051
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 #include <reg52.h> #define LCD P2 void delay_ms(unsigned int i) { unsigned int j; while(i-->0) { for(j=0;j<500;j++) { ; } } } void cmd_lcd(unsigned char c) { unsigned char temp; temp=c>>4; LCD=temp<<4|0x02; //logical or with 0x02 since rs(rs=0) & en(en=1) are LCD=0; //connected to p2.0 & p2.1 respectively //transmit low byte LCD=c<<4|0x02; LCD=0; delay_ms(2); //delay 2 milliseconds } void init_lcd(void) { delay_ms(10); //delay 10 milliseconds cmd_lcd(0x28); //4 bit initialize, 5x7 character font, 16x2 display cmd_lcd(0x0c); //lcd on, cursor on cmd_lcd(0x06); //right shift cursor automatically after each character is displayed cmd_lcd(0x01); //clear lcd } void write_lcd(unsigned char c) { unsigned char temp; temp=c>>4; LCD=temp<<4|0x03; //logical or with 0x03 since rs(rs=1) & en(en=1) are LCD=0; LCD=c<<4|0x03; LCD=0; delay_ms(2); } void display_lcd(unsigned char *s) { while(*s) write_lcd(*s++); } void integer_lcd(int n) { unsigned char c[6]; unsigned int i=0; if(n<0) { write_lcd('-'); n=-n; } if(n==0) write_lcd('0'); while(n>0) { c[i++]=(n%10)+48; n/=10; } while(i-->=1) write_lcd(c[i]); }
#include <at89x52.h>
#define stepper P1
void main
{
while(1)
{
stepper=0x01;
delay(10);
stepper=0x02;
delay(10);
stepper=0x04;
delay(10);
stepper=0x08;
delay(10);
}
}
save this file as lcd.h
Excellent. I've never thought before to make header file by my own.
#ifndef _ADDER_H_
#define _ADDER_H_
uint32 add(uint32 x, uint32 y);
#endif
#include "adder.h"
uint32 add(uint32 x, uint32 y) {
uint32 result = x+y;
return resukt;
}
#ifndef _LCD_H_
#define _LCD_H_
void delay_ms(unsigned int i);
void cmd_lcd(unsigned char c);
void init_lcd(void);
void write_lcd(unsigned char c);
void display_lcd(unsigned char *s);
void integer_lcd(int n);
#endif
Your LCD.h file should look like this:
Code:#ifndef _LCD_H_ #define _LCD_H_ void delay_ms(unsigned int i); void cmd_lcd(unsigned char c); void init_lcd(void); void write_lcd(unsigned char c); void display_lcd(unsigned char *s); void integer_lcd(int n); #endif