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.

Stepper motor interfacing 8051

Status
Not open for further replies.

bhadmanathan

Junior Member level 1
Joined
May 7, 2016
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
187
Hi

i am using 8051 uc and 1.8 degree motor which is 4 wired hybrid bi polar stepper motor.
Done a coding to control a stepper motor and it is working fine in the frequency of 10-50 Hz.

Code:
void T0_ISR (void) interrupt 1  //Timer0 interrupt
{
TL0=0x65;      // comes to ISR 1ms once
TH0=0xFC;
count1++;
if(count1>=10)
{
xx++;
count1=0;
}  
     
if(xx==1) P3=0x60;
else if(xx==2) P3=0xa0;
else if(xx==3) P3=0x90;
else if(xx==4) {P3=0x50;xx=0;}

}

In Port3 i need to connect two stepper motors .
one is connected in P3.0 to P3.3.
Another is connected in P3.4 to P3.7.

Coding wise i need to give pulses without disturbing the other motor's pulse.

I modified the code like,

if(xx==1) {P3 &= 0x0f;P3 |= 0x60;}
else if(xx==2) {P3 &= 0x0f;P3 |= 0xa0;}
else if(xx==3) {P3 &= 0x0f;P3 |= 0x90;}
else if(xx==4) {P3 &= 0x0f;P3 |= 0x50;xx=0;}

Like wise one more above 4 lines for another 4 pins.

But pulse is not coming correctly.
Above every lines of code is in ISR.

Other alternative i used is single bit access, but that is also not helping.

Now i completed the task by using separate ports, But i want to know "why bit clear and bit set was not working ?"


Thanks
 

Hi,

show schematic.
show scope picture of the outputs.

Did you test if the ISR runs at all?
ISR initialisation.
Interrupt mask register setup
Interrupts enabled?

Port setup?

Maybe you need to READ a different register than you WRITE (Depends on microcntroller type. I´m not experienced with 8051)

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top