mariocaptain
Member
Hi all,
I am trying to use a Teensy 3.1 running at 72Mhz to generate some quality PWM output at to precisely control 2 large brushed motors.
I am using the below code, following this article.
This code is supposed to generate a 50% duty cycle PWM signal at 35156.25 Hz on pin 21.
However, the kind of PWM output I am getting is not as good as I wanted, and not good enough for the application. There are a few observations as follows (please also see attached photos):
1. The max voltage is 3.61V, not 3.3V. How come? I need this to be an exact value to feed the motor driver
2. Pulse width, frequency and duty cycle keep jittering between 2 values. For instance, pulse width keeps jumping between 14.0uS and 16.0uS, while duty cycle + keeps jumping between 50% and 53.3%, which is not good for the motor.
So are there any other ways to generate better PWM output? Anything can be improved in my setting?
Thanks in advance.
Dave
I am trying to use a Teensy 3.1 running at 72Mhz to generate some quality PWM output at to precisely control 2 large brushed motors.
I am using the below code, following this article.
Code:
void setup(void)
{
analogWriteFrequency(21, 35156.25); //resolution will be 10 bit: 0 - 1023. See also: https://www.pjrc.com/teensy/td_pulse.html
analogWriteResolution(10); //10 bit: 0 - 1023
analogWrite(21, 511.5);
}
void loop(void)
{
}
This code is supposed to generate a 50% duty cycle PWM signal at 35156.25 Hz on pin 21.
However, the kind of PWM output I am getting is not as good as I wanted, and not good enough for the application. There are a few observations as follows (please also see attached photos):
1. The max voltage is 3.61V, not 3.3V. How come? I need this to be an exact value to feed the motor driver
2. Pulse width, frequency and duty cycle keep jittering between 2 values. For instance, pulse width keeps jumping between 14.0uS and 16.0uS, while duty cycle + keeps jumping between 50% and 53.3%, which is not good for the motor.
So are there any other ways to generate better PWM output? Anything can be improved in my setting?
Thanks in advance.
Dave
Last edited: