Electronic circuits & projects forum - Need help with electronic circuits & projects?  Forum Index Electronic circuits & projects forum - Need help with electronic circuits & projects?
Electronics circuits, projects, schematics discussion forum for Electronic hobbyists, engineers and students to share and discuss problems, ideas, views and general information related to Electronics on the Internet!
 
 FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
[Electronic circuits and hobby Home page]


wat shud b the sequence for steppermotor frm PIC16F876A?

 
Post new topic   Reply to topic    Electronic circuits & projects forum - Need help with electronic circuits & projects? Forum Index -> Electronic Parts forum
View previous topic :: View next topic  
Author Message
rautabhishek



Joined: 18 May 2010
Posts: 1

PostPosted: Tue May 18, 2010 1:08 pm    Post subject: wat shud b the sequence for steppermotor frm PIC16F876A? Reply with quote

I am using Fraen 6405-1512 stepper motor controlled by PIC16F876A (ULN2003A as driver along with transistors to form a H-bridge) to drive a pointer of a speedometer. I need to know about the sequence (if possible in C language) which should be given to the motor windings in order to have a smooth rotation. Till now, I have achieved the motion but it's not smooth nor have I got control over it's direction of rotation. The code I wrote is given below.

the link for circuit diagram of PIC-motor interface is:
http://farm5.static.flickr.com/4064/4616205852_e22feddf86_b.jpg

the link for datasheet and other details of motor is:
http://www.fraenamd.com/steppermotor.htm

If further details are required please let me know.

code:
#include<pic.h>

int msec;

#define wait 10

interrupt void isr()
{
if (TMR2IF)
{
TMR2IF=0;
msec++;
}
}

void init_timer()
{
PIE1=0x02;
PIR1=0x00;
T2CON=0x06;
PR2=0xFA; //count to generate 1ms delay, freq of crystal is 16Mhz
INTCON=0xC0;
}

void delay( unsigned int n)
{
msec =0;
init_timer();
while (msec!=n);
msec++;
T2CON= 0x00;
}


void main()

{ TRISB = 0x00;

while(1)

{
PORTB = 0x22; // A2 B2
delay(wait); /* generates a delay of
as many millisecs as the
count in 'wait' variable */

PORTB = 0x20; // A2
delay(wait);

PORTB = 0x24; // A2 A1
delay(wait);

PORTB = 0x04; // A1
delay(wait);

PORTB = 0x14; // A1 B2
delay(wait);

PORTB = 0x10; // B2
delay(wait);

PORTB = 0x12; // B2 B1
delay(wait);

PORTB = 0x02; // B1
delay(wait);


}

}

please help me out asap.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Electronic circuits & projects forum - Need help with electronic circuits & projects? Forum Index -> Electronic Parts forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group