controlling stepper motor using atmega 16 with l298 driver

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

could anyone please tell me about how to control steppers using the l298 connected to atmega 16?

i use programmers notepad for programming in c.

please show me a sample code if possible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The general idea is you have 4 outputs from the avr to the 4 inputs of the h-bridge. The stepper has 2 coils A and B. A coil has 2 wires... these go to one side of the h bridge. If one pin is hi, the other low, juice flows thru the coil one way, reverse the outputs juice flows the other way. So you have 4 combinations of outputs to step the motor... 00, 01, 11, 10 where the first char is A coil, second char is the B coil. 0 means the two outputs to that coil are hi lo, and 1 means lo hi. So its a table lookup with those 4 output patterns in a table, and you increment the table index 01230123 to go cw, 32103210 to go ccw. Clear as mud?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have done some homework after reading ur reply.
now i understand it better.thank you

i am not able to understand which voltage rating stepper to use with L298.(i am supplying 12v to the L298).
i tried to figure out from the data sheet,didn't get anything.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which datasheet? The L298 or the stepper?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

l298 data sheet

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The output from the 298 will go from 0V to 12V when it changes. If this voltage is applied to the coil of the stepper motor, it will dissipate some power. You could probably run a 5V stepper on 12V for a while before it got too hot, and you could probably run a 24V stepper on 12V if you didnt need maximum torque, and, like Goldilocks and the Porridge, if you run a 12V stepper on 12V, everything will be just right. I can't help but think that this should have been abundantly obvious, but maybe there is some cultural difference I can't see.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have chosen bi-polar stepper(4 leads) with 4.5ohms resistance btw the pair of wires.
the max output current of l298 is around 2.5A.
so it would make a drop of around 10V.

i have planned to go around with 12 v stepper.
thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
with ref to data sheet of L298. looks like one cannot run the stepper with only L298, we need L297 too rite?

could you please tell me any other driver which might be able to use for a 12v stepper

thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

L297 isn't an absolute requirement, but its functionality has to be provided one way or another.

L297 does two distinct things. First, it translates DIR/STEP signals into four L298 bridge inputs. This is trivial to do with any AVR.
Second, and much more important, it provides PWM-like current control, which allows you to run (almost) any motor from any voltage without overheating. The majority of motors are current-rated, not voltage-rated, and the higher voltage you set, the better dynamic performance you get.
This thing is not easily done with AVRs because you need two analog comparators, while most of AVRs have only one. One option here is to use an external dual comparator (e.g. LM393) with its outputs connected to AVR interrupt lines, another option is to use a specialized AVR (like AT90PWM3).

If your current requirements are no more than 0.75A, a good option is L6219.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i m using bipolar full step(2 phase on)stepper motor driver containing L298 and L297..i m not getting the idea of controlling of its circuit through atmega16..kindly provide me with the code..help..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can kindly provide you with the algorithm.... I think there might be several dozen stepper motor programs in the 'projects' section here.

unsigned char stpdat[4]={0x05,0x06,0x0a,0x09};
unsigned char ndx;

void stpfwd(void){
  ndx++;
  if(ndx >= 3){
    ndx=0;
  }
  PORTB = stpdat[ndx];
}
void stprev(void){
  ndx--;
  if(ndx == 0xff){
    ndx=3;
  }
  PORTB = stpdat[ndx];
}

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

plz help me what shuld i do when i use only L298.??what will be code if i need to control the angles of my stepper..because i need to control the movement of my robotic arm..help..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

help..

Help yourself, to begin with.

1. Tell us what ype of stepper motor this is (unipolar or bipolar?)
2. Show schematic on how the AVR, the 298 and the motor is connected.
3. Goole stuff like "AVR L298 stepper code".
4. Read findings from 3.
5. Read Wikipedia articles etc on stepper motors in general, and your type in particluar.
5. Finally, post a qustion here that makes people interested in actually helping you. Pweople here are not paid to answer you - it is up to you to formulate your question so that people get's interested. Making a post with nothing but "spoonfeed me" makes no-one interested.

I often repeat: The quality of the answers you get is highly correlated with the quality of the question you ask.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As a Real Last Resort, cutnpaste that snippet from my message and call the stpfwd function every 10ms and see if the motor moves?

Imagecraft compiler user