Help Understanding a Stepper Motor App Note for ATmega

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

I'm trying to figure out the how the timer is configured in the app note  "AVR446: Linear speed control of stepper motor"..

 

From what I've read it looks like it sets up the timer, and at every timer interrupt it 1) updates the period for the next interrupt and 2) Generates a step pulse.

 

For example, the pdf uses an ATmega48 @3.68MHz , and during the motor setup it initializes the timer to:

    OCR1A = 10;

    TCCR1B |= ((0<<CS12)|(1<<CS11)|(0<<CS10));   // Run Timer/Counter 1 with prescaler = 8.

 

Then when the timer expires (Timer/Counter1 Output Compare A Match Interrupt), this period is updated:

   OCR1A = srd.step_delay;

 

 

They don't mention the initial value nor range of values that the timer should be expected to fire at, instead they mention that the user sets the speed in rad/sec (a value of 100 = 1 rad/sec).    In any case, can anyone tell how this works and the timer frequencies I should expect?  

 

Attachment(s): 

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

The document outlines the equations. If you set the speed to 1 rad/s (9.55rpm or 31.8 steps/s given 200 steps/rev motor). Work that in terms of timer counts:

3680000/8/31.8 = 14465 timer ticks. So steps/s is timer frequency in Hz.

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

That makes more sense, I'll try to duplicate and see if it works, thanks!