PDA

View Full Version : Step Motor Control



Blasfemy
- 19th May 2008, 18:32
Hey, i'm new here but i would like some help on a program for a step motor.
I'm using a timer to operate at 300Hz and the same timer to operate as a delay of 1800.
So, first i turn on the first bit during some time and then my interrupt routine just calls the 2 timer after the first is finished. But i think i have some error on my interrupt routine and function so i will just copy it and you could comment it:

void init_timer1(){
OPTION_REG=00000011; //0xDF;
//t0cs = 0;
//psa = 0;
//ps2=0; ps1=0; ps0=1;
TMR0=0x0F;//47 Este timer começará no valor apropriado de modo a fazer o overflow no tempo certo
Flag=1;
}

void init_timer2(){
OPTION_REG=00000011; //0xDF;
//t0cs = 0;
//psa = 0;
//ps2=0; ps1=0; ps0=1;
TMR0=0x0F;//221 Este timer começará no valor apropriado de modo a fazer o overflow no tempo certo
Flag=0;
}


void interrupt Timers(void)
{
if (TOIF==1 && Flag==1)
{
TOIF=0;
Flag=0;
init_timer2()

else

if (TOIF==1 && Flag==0)
{
TOIF=0;
Flag=1;
init_timer2()
}

void Halfstep(){
while(1){
init_timer0();
PortA = 0x08;//1 0 0 0////

skimask
- 19th May 2008, 18:45
I would've thought that this URL:

www.PICBASIC.co.uk

should've been a big enough hint...
Guess not...
forum.microchip.com

aredhel
- 28th March 2012, 18:22
Hello, I know it's a bit late, but did you use any Input Capture for your control? If so, please let us know. If you remember eventually...