I want to control a stepper motor at its maximum RPM of 5,000. Can this be done using the pwm? 5000 RPMs requires 1000000 pulses on my motor. I don't believe the pwm can handle this frequency. If I'm wrong please correct me and let me know how to do that. Is there another way to output 1000000 pulses and be able to control the frequency (the pulse rate)?
This can give you a 1MHz output at pin 12.
I expect you'd need to accelerate from zero to the maximum to keep the motor in sync.
What stepper motor are you using that has 12000 steps/rev?
/*
* Timer1
* set prescaler /1 (ticks at 16MHz)
* set WGM15
* set OC1A to 15
* set OC1B to 7
*
* 5000RPM = 83.33333 revs/sec
* 1MHz: 1E+06 steps/sec
*
* 1E+06 steps x 1 sec
* sec 83.3333 rev
*
* 12000 steps/rev?
*
*/
const uint8_t pinStep = 12;
void setup( void )
{
pinMode( pinStep, OUTPUT );
TCCR1A = _BV(COM1B1) | _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10);
OCR1A = 15;
OCR1B = 7;
}//setup
void loop( void )
{
}//loop
I'm using a 85BYGH450C-012. Which requires 200 steps per Revolution. It has a maximum rpm 5000. NEMA 34
kenmcgrath662:
I'm using a 85BYGH450C-012. Which requires 200 steps per Revolution. It has a maximum rpm 5000. NEMA 34
You initially asked for 1000000: What is the significance of this number?
The 85BYGH450C-012 has a step-size of 1.8-deg/step so 360-degrees is indeed 200 steps: 200 x 83.333 revolutions/sec (5000rpm) is a step frequency of 16.67kHz.
Please excuse my ignorance I'm new to the Arduino. I calculated 1 megahertz based upon 5000 revolutions per minute at 200 pluses per Revolution. I recently retired and found the Arduino fascinating. This is all new to me so please once again excuse my ignorance.
kenmcgrath662:
Please excuse my ignorance I'm new to the Arduino. I calculated 1 megahertz based upon 5000 revolutions per minute at 200 pluses per Revolution. I recently retired and found the Arduino fascinating. This is all new to me so please once again excuse my ignorance.
No worries. Just looking for clarification.
At 200ppr and 5000 rpm, you are looking for 1,000,000 pulses per minute which is 16.67kHz.
This can give you that at pin 12:
/*
* Timer1
* set prescaler /1 (ticks at 16MHz)
* set WGM15
* set OC1A to 959
* set OC1B to 480
*
* 5000RPM = 83.33333 revs/sec
* 16.67kHz
* at 62.5nS/tick
* period == 960 ticks
*
*/
const uint8_t pinStep = 12;
void setup( void )
{
pinMode( pinStep, OUTPUT );
TCCR1A = _BV(COM1B1) | _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10);
OCR1A = 959;
OCR1B = 480;
}//setup
void loop( void )
{
}//loop
I think you'd still need to accelerate the motor from a stop before reaching full stepping speed.
I would like thank you for all your help. As a beginner into the world of Arduino it's people like you who helped out the Newbie. once again thank you.
I checked online for the datasheet where you got this information from and Was unable to find it. I purchase a book by Jeremy Bloom, "Exploring Arduino" and that made no mention on how to configure timers. If you would be nice enough to point me in the right direction so I can download the datasheet you were referring to.
kenmcgrath662:
I checked online for the datasheet where you got this information from and Was unable to find it. I purchase a book by Jeremy Bloom, "Exploring Arduino" and that made no mention on how to configure timers. If you would be nice enough to point me in the right direction so I can download the datasheet you were referring to.
You can find the datasheet for the processor here:
See sect 17 "16-bit Timer/Counter (Timer/Counter 1, 3, 4, and 5)"
Thank you for the link. You got a badass Blackfinn.
A cool name, black fin
I'm with you brother I'm just trying to learn and understand Arduino
I want to send a special thank you to Blackfinn. For pointing me in the right direction.