Comments on: Interfacing Stepper Motor with PIC Microcontroller https://electrosome.com/stepper-motor-pic-microcontroller/ You Inspire.....We Create..... Sun, 14 Jan 2018 15:28:35 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Namratha https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6823 Mon, 17 Jul 2017 06:19:00 +0000 https://electrosome.com/?p=2392#comment-6823 Hi Ligo George …
Please check this code ,
I have interfaced 2 amps (1.8 deg ) Stepper Motor to pic16f877a pic controller. Am unsign L298N Stepper motor driver .

#define A1 RC0 // OUTPUT motor
#define A2 RC1 // OUTPUT
#define B1 RC2 // OUTPUT
#define B2 RC3 // OUTPUT

#define pulse RD0 // INPUT pulse sensor
#define led RD2 // OUTPUT power on
#define DETECT RB3 // OUTPUT MAGNETIC SENSOR

while(1)
{
state = DETECT;
if(pulse && state == 1)
{
led = 1;
for(i=0; i<50; i++)
{
motor_full();
}
}
if(pulse == 0)
{
motor_off();
led = 0;

}
if(state == 0)
{
i++;
motor_full(); // come back to home position
}

}
}

void motor_full()
{

A1 =1; B1= 0; A2 =0; B2= 1;
__delay_ms(1);

A1 =0; B1= 0; A2 =0; B2= 1;
__delay_ms(1);

A1 =0; B1= 0; A2 =1; B2= 1;
__delay_ms(1);

A1 =0; B1= 0; A2 =1; B2= 0;
__delay_ms(1);

A1 =0; B1= 1; A2 =1; B2= 0;
__delay_ms(1);

A1 =0; B1= 1; A2 =0; B2= 0;
__delay_ms(1);

A1 =1; B1= 1; A2 =0; B2=0;
__delay_ms(1);

A1 =1; B1= 0; A2 =0; B2= 0;
__delay_ms(1);

}

void motor_off()
{
PORTCbits.RC0 = 0;
PORTCbits.RC1 = 0;
PORTCbits.RC2 = 0;
PORTCbits.RC3 = 0;
A1 =0; B1= 0; A2 =0; B2= 0;

}

]]>
By: Ligo George https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6478 Sun, 27 Nov 2016 07:35:00 +0000 https://electrosome.com/?p=2392#comment-6478 In reply to Kannan Devadass.

It depends on the minimum stepping angle of your motor. What is minium step ?

]]>
By: Kannan Devadass https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6406 Thu, 06 Oct 2016 07:08:00 +0000 https://electrosome.com/?p=2392#comment-6406 Hi.. Ligo George
I want to rotate my stepper motor for 1.8 degree. For that what process i should follow. If i run this above program its working well and good but the rotation is about 45 degree for every cycle.

]]>
By: Ligo George https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6132 Thu, 02 Jun 2016 13:00:00 +0000 https://electrosome.com/?p=2392#comment-6132 In reply to Rakesh.

Sorry, the above article is not about Atmega. Please use our forums ( https://electrosome.com/forums ) for asking doubts outside the scope of above article.

]]>
By: Rakesh https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6066 Thu, 05 May 2016 06:11:00 +0000 https://electrosome.com/?p=2392#comment-6066 HI…Ligo geroge
. I want to rotate unipolar stepper motor with atmega16a
and i configure it with following code

#include

#include

int main()

{

DDRA = 0xFF; //All pins of PORTB as output

PORTA = 0x00; //Initially all pins as output high

while(1)

{

PORTA = 0x01; //0001

_delay_ms(10);

PORTA = 0x04; //0100

_delay_ms(10);

PORTA = 0x02; //0010

_delay_ms(10);

PORTA = 0x08; //1000

_delay_ms(10);

}

return 0;

}
and common terminal connected to vcc

its not rotating properly

will you suggest me any solution

Thanks in advances

]]>
By: Ligo George https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6021 Fri, 15 Apr 2016 02:48:00 +0000 https://electrosome.com/?p=2392#comment-6021 In reply to Mark Moinjeh.

You can control the speed by adjusting the delay in each step and reading the potentiometer using adc.

]]>
By: Ligo George https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6011 Fri, 15 Apr 2016 02:33:00 +0000 https://electrosome.com/?p=2392#comment-6011 In reply to asmaa.

You can calculate depending on the number of steps on that stepper motor.

]]>
By: Ligo George https://electrosome.com/stepper-motor-pic-microcontroller/#comments/6003 Fri, 15 Apr 2016 02:14:00 +0000 https://electrosome.com/?p=2392#comment-6003 In reply to Don Xavier.

You can use for loop for that.

]]>
By: Mark Moinjeh https://electrosome.com/stepper-motor-pic-microcontroller/#comments/5980 Sat, 09 Apr 2016 17:54:00 +0000 https://electrosome.com/?p=2392#comment-5980 I am Mark, I need a code in MikroC to control the speed of my steeper motor using a potentiometer when the switch is on/ high. Thank you

]]>
By: Mark Moinjeh https://electrosome.com/stepper-motor-pic-microcontroller/#comments/5981 Sat, 09 Apr 2016 17:54:00 +0000 https://electrosome.com/?p=2392#comment-5981 sorry it is stepper motor

]]>