Hi there,
I’m working on a project to run a BLDC motor using an Arduino UNO R3 with an H-Bridge interface and a published sketch.
As I understand it the Arduino can produce a range of specific frequencies from it PWM pins (see attached) and I was interested to understand how the code sets the frequency. The output from pins 9,10 and 11 on the Arduino feed to pin 3 on each of three IR2104 drivers. I am led to believe that each of these Arduino output pins supplies a 31,372.55 Hz signal.
The relevant code from the sketch is shown below:
// Timer1 module setting: set clock source to clkI/O / 1 (no prescaling)
TCCR1A = 0;
TCCR1B = 0x01;
// Timer2 module setting: set clock source to clkI/O / 1 (no prescaling)
TCCR2A = 0;
TCCR2B = 0x01; //0x01; uhura:0x05; 0x03:976Hz
// Analog comparator setting
I don’t know enough about the syntax to be able to understand how this code sets this frequency.
Thanks
Jules