Microcontroller › 8051 › In what form signal is given to AT89c51 mc’s input
- This topic has 8 replies, 2 voices, and was last updated 9 years, 6 months ago by nitish kumar singh.
-
AuthorPosts
-
April 3, 2015 at 12:09 pm #3601nitish kumar singhParticipant
I had feed following program into AT89C51 mc . And for testing i am just connecting +ve terminal into P1^0 but nothing was happening to stepper motor.
#include<reg51.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0;
sbit sense2=P1^1;
void main ()
{
int i;
P1=0xf0;
while (1)
{
if (sense1==1 && sense2!=1)
{
for (i=0;i<=2;i++)
{
P2=0x66;
MSDelay (350);
P2=0xCC;
MSDelay (350);
P2=0x99;
MSDelay (350);
P2=0x33;
MSDelay (350);
}
}
sense1=0;
if (sense2==1 && sense1!=1)
{
for (i=0; i<=2;i++)
{
P2=0x66;
MSDelay (350);
P2=0x33;
MSDelay (350);
P2=0x99;
MSDelay (350);
P2=0xCC;
MSDelay (350);
}
}
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y;
for(x=0; x<1275;x++)
for(y=0;y<value;y++);
}April 3, 2015 at 6:57 pm #12747Ashutosh BhattParticipantit should not be
if (sense2==1 && sense1!=1)
but
if ((sense2=='1') && (sense1!='1'))
also these two pins must be configured as input by
P1 = 0x03;
April 4, 2015 at 11:11 am #12759nitish kumar singhParticipantin both If condition, it is required to correct it or only in one case.
if ((sense2=='1') && (sense1!='1'))
if ((sense1=='1') && (sense2!='1'))
After making correction the led on ULN 2003 blink randomly but stepper motor yet not rotating.
April 4, 2015 at 11:15 am #12760nitish kumar singhParticipantThe above program is correct to rotate in clock wise and anticlockwise.I wantt to rotate only two step in each direction according to condtion not to rotate continously.
April 5, 2015 at 10:14 am #12765nitish kumar singhParticipantplease reply sir
April 6, 2015 at 11:54 am #12768Ashutosh BhattParticipantwhich type of motor u have
unipolar or bipolar?
for unipolar u can use ULN2003A chip
but for bipolar u have to use L293D chip
the pulse sequence you are giving is for bipolar motor
for unipolar motor it will be 0x01,0x02,0x04,0x08…..
April 6, 2015 at 3:52 pm #12772nitish kumar singhParticipantsir
i had purchased a stepper motor in which uln2003A was provided along with it.so it may be unipolar motor.
April 7, 2015 at 4:04 am #12774nitish kumar singhParticipantfollowing program is correct for rotating the stepper motor half revolution in clock wise and anti-clock wise.?
My aim is to use this stepper motor to close and open the Railway crossing gate..
#include<reg51.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0;
sbit sense2=P1^1;
void main ()
{
int i;
P1=0x03;
{
if ((sense1=='1')&& (sense2!='1'))
{
for (i=0;i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x02;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x08;
MSDelay (10);
}
}
sense1=0;
if ((sense2=='1') && (sense1!='1'))
{
for (i=0; i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x08;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x02;
MSDelay (10);
}
}
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y;
for(x=0; x<1275;x++)
for(y=0;y<value;y++);
}April 8, 2015 at 7:09 am #12775nitish kumar singhParticipantreply sir?
If you have such program that is used to control the Gate then please sent it to my mail id [email protected]
-
AuthorPosts
- You must be logged in to reply to this topic.