Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[51] Stepper Motor interfacing with 8051

Status
Not open for further replies.

Er_pank

Newbie level 4
Joined
Oct 22, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
47
Hi friends
I am having problem in interfacing 8051 uC with stepper motor.
My aim is to rotate the stepper motor by +90 degree when i push a "UP" button once and when I push the "UP" button twice +180 degree and then +270 then 0 degree.
And when I push "DOWN" button rotate by -90 degree and when I push DOWN twice -180 degree and so on.

I am working on a Proteus but I think there is problem in program and I am not able to get proper result.



Can you any one give me proper Program for that :


Thanks in advance :smile:

My WRONG program was :

Code:
void delay(int);
sbit zin= P0^0;
sbit zout= P0^1;
void main()
{ int num=0;
	P0=0;
  P2=0;
	do
{
		
		if(zin==1)
    {
			P2=0x0C; 
		  num++;
		}
	 if(zout==1)
   { 
		 P2=0x03;
		 num--;
	 }
}
while(1);
}

void delay(int k)
{
  int i,j;
  for(i=0;i<k;i++)
  {
    for(j=0;j<100;j++)
    {}
  }
}



And Proteus diagram is :


<a title="stepper_motor_protues.JPG" href="http://obrazki.elektroda.pl/6857363500_1382873179.jpg"><img src="http://obrazki.elektroda.pl/6857363500_1382873179_thumb.jpg" alt="stepper_motor_protues.JPG" /></a>

https://obrazki.elektroda.pl/6857363500_1382873179.jpg
 

Thanks for your reply,
I have read it but unable to write a proper program for the operation.
I m trying it in proteus,

Can you give program for the above mentioned operation ?

can you tell me which stepper motor would be good choice ?
 

hello what is the meaning of num variable i think this is doesn't metter . and also clear the specific bit after set means your peace of code change below like this .
Code:
if(zin==1)
 {
      P2=0x0C; 
      num++;
      zin = 0 ;
}
if(zout==1)
{ 
       P2=0x03;
       num--;
       zout = 0;
}
and also make some change on rotation bit on port2 .
 

i think the problem is because you send 0x0c for every key press .So the same coil get exited every time.You need to give the excitation sequence for your purpose .


also i doubt the button switch connection wiil work properly. if you don't get any output first check the switch connection.If you get a degree rotation when the up key is pressed then leave it.

Regards,
 

Hello!

1. First you might want to understand how a stepper works.
Inyour code, P2 has 2 states only, 0x0C and 0x03. This cannot work.
Looking at the schematic, it looks like it's a unipolar motor. You have
to power the windings in the right sequence, which is unlikely to be 0x03 / 0x0C.


2. If you want to move by 90 degrees, you should have this variable somewhere.
I use 400 steps motors, which means that 90 degrees is 100 steps. I would expect
some definition like this somewhere in the program:

#define STEPS_PER_TURN 400 // Adapt to your motor.

3. Your value 'zin' will never update. It is defined forever at the beginning of the program.
You have to at least read port 0 in your loop. Same for zout.

4. You don't use the delay function.

5. Your num variable is never used.

6. You might want to learn about timers and interrupts. But for a first run, try to
run your motor at constant speed, and then think about the possible evolutions.


Can you any one give me proper Program for that :

What is the point of getting your program done by somebody else. Are you that bored by
technology?

Dora.
 
I am working on real hardware it is not giving desired response how ever it works perfectly in Proteus.
hardware: AT89C51, capacitor 33pF, crystal 12MHz, Bipolar Stepper Motor (4 wire)...
The motor rotates few steps but after few steps it stop rotating...

I have program but same result...

My motor is:
NMB-MAT pm35s-048 FEE6
TB6628D
I am giving 9 volt supply through HW HI Watt battery (vallue of current is not given in battery)...

Is the current is not enough to rotate the rotor ?

My program is:
Code:
#include<reg51.h> //using AT89C51
#include<stdio.h>
void delay(int); // Rotation In sequence without any switch continously
void main()
{
P1=0;
P2=0;
P3=0;
  do
  {
    P2=0x01; //0001
    delay(100);
    P2=0x04; //0100
    delay(100);
    P2=0x02; //0010
    delay(100);
    P2=0x08; //1000
    delay(100);
  }while(1);
}
 
void delay(int k)
{
  int i,j;
  for(i=0;i<k;i++)
  {
    for(j=0;j<1725;j++)
    {}
  }
}



<a title="stepper_motor2.jpg" href="http://obrazki.elektroda.pl/1903070500_1384611337.jpg"><img src="http://obrazki.elektroda.pl/1903070500_1384611337_thumb.jpg" alt="stepper_motor2.jpg" /></a>

https://obrazki.elektroda.pl/1903070500_1384611337.jpg
 

Attachments

  • stepper_motor2.jpg
    stepper_motor2.jpg
    98.1 KB · Views: 104

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top