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.

[PIC] L297 Stepper Drive direction malfunctioning

Status
Not open for further replies.

gne_577

Junior Member level 3
Joined
Jun 23, 2013
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,514
hello
am using l297-l298 stepper drive to rotate the bipolar stepper motor along with PIC18f85j11 micro-controller. It gives problem that whenever i set up a direction for rotation, it gives malfunctioning as in result. sometime the motor rotated in clockwise or in anticlockwise.
but in some cases if i continuously rotate the motor, it will rotated in same direction on other hand as i rotated in the steps it will start giving this error.

The programming code is written below:

//20mhz external oscillator used

void DelayMS(unsigned int itime) // Function by Passing Parameter
{
unsigned int i, j;
for(i=0;i<itime;i++)
for(j=0;j<5;j++);
}

void main()
{
STITCH_CLK_DIR=STITCH_FR_DIR=STITCH_EN_DIR=0; //make these pins are output
DelayMS(250) ;

STITCH_FR=1; // make the motor direction in reverse
DelayMS(100) ;
STITCH_EN=0; // make the l297 enable pin on
DelayMS(100) ;
while(i<250) //250 clocks given to stepper motor
{
STITCH_CLK=0; // clock pin on
DelayMS(2);

STITCH_CLK=1; // clock pin off
DelayMS(1);

i++;
DelayMS(1);
}
STITCH_EN=1; // make the l297 enable pin on
DelayMS(250) ;

while(1);
}
 

Hi,

Code:
STITCH_CLK=0; // clock pin on
DelayMS(2);

STITCH_CLK=1; // clock pin off
DelayMS(1);

means you output the clocks with about 330Hz. Without speed ramp up and speed ramp down.
Try with more delay time --> lower speed.

But for a reliable stepper control you need the speed ramp functions.

Klaus
 

what value should i set for the clock and what is the role of speed ramp functions...??
 

Hi,

It depends on your hardware, the motor and the mechanical load on the motor.....
therefore i can´t give you a value. Test different values. If you found a solution, then speed it down by at least 25% to get reliable function.

Ramp:
You are trying to speed up the motor form zero to 100% within no time. And you try to slow it down from 100% to zero within no time. This is like driving your car against a solid wall. ;-)

You need a defined acceleration to smoothly speed up from zero speed to 100% speed. And back.

There is a lot of literature around on how to control a stepper motor. Here in the forum, in microcontroller forum or anywhere (google).
Read it carefully.

Klaus
 

Okkk okk

1 thing i have to ask is that any way to check L298..???

Beacause all hardware structure is okay working fine. but the only problem is that motor just changed its direction from clockwise to anti-clockwise what ever its control..

So far I'll drive motor without load..

Thanks :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top