kanni1303
Full Member level 3
- Joined
- Jun 29, 2012
- Messages
- 164
- Helped
- 12
- Reputation
- 24
- Reaction score
- 11
- Trophy points
- 1,298
- Location
- Chennai, Tamil Nadu, India
- Activity points
- 2,708
Hi...
I am in need to run my stepper motor fast... but i don't know how to run it fast... everyone says increase the PPS but i don't know how to increase it...
here is my code... and i am using the PM42L-048 Bipolar stepper motor
pls make me understand
I am in need to run my stepper motor fast... but i don't know how to run it fast... everyone says increase the PPS but i don't know how to increase it...
here is my code... and i am using the PM42L-048 Bipolar stepper motor
Code:
#include<htc.h>
int _XTAL_FREQ=12000000;
int i;
void forl();
void revl();
void form();
void revm();
void forr();
void revr();
void DelayMs(unsigned char delay)
{
unsigned int j;
for(i=0;i<=delay;i++)
{
for(j=0;j<=1000;j++);
}
}
void port_initialize()
{
TRISB=0X00;
PORTB=0x00;
TRISC=0xFF;
TRISD=0X00;
PORTD=0x00;
#define a RC0
#define b RC1
#define l1 RB0
#define l2 RB1
#define l3 RB2
#define l4 RB3
}
void main()
{
port_initialize();
while(1)
{
if(a>0x00)
{
forl();
}
if(b>0x00)
{
revl();
}
}
}
/*
void forl()
{
PORTB=0x08;
DelayMs(150);
PORTB=0x02;
DelayMs(150);
PORTB=0x04;
DelayMs(150);
PORTB=0x01;
DelayMs(150);
}
void revl()
{
PORTB=0x04;
DelayMs(150);
PORTB=0x02;
DelayMs(150);
PORTB=0x08;
DelayMs(150);
PORTB=0x01;
DelayMs(150);
}
*/
void forl()
{
l1=1;
l2=0;
l3=0;
l4=0;
DelayMs(150);
l1=0;
l2=0;
l3=1;
l4=0;
DelayMs(150);
l1=0;
l2=1;
l3=0;
l4=0;
DelayMs(150);
l1=0;
l2=0;
l3=0;
l4=1;
DelayMs(150);
}
void revl()
{
l1=0;
l2=1;
l3=0;
l4=0;
DelayMs(150);
l1=0;
l2=0;
l3=1;
l4=0;
DelayMs(150);
l1=1;
l2=0;
l3=0;
l4=0;
DelayMs(150);
l1=0;
l2=0;
l3=0;
l4=1;
DelayMs(150);
}