Good evening!
I'm in the process of creating a controller for a diesel-fired heater. It uses a metering pump to inject a known amount of fuel into the burner. I need to inject fairly low duty cycle pulses into the metering pump at fairly slow rates for this to work properly. (from about 1 Hz to a maximum of 6 Hz, at a duty cycle of 10% to 20%)
I tried the code below on an Arduino Uno using an LED and 1k resistor connected to Pin 9. Works perfectly! I get a 1 Hz pulse train for 5 seconds, then 2 Hz, then 4 Hz, then 5 Hz.
However, when I try it on a Teensy 3.2, adjusting the code to reflect that Teensy 3.2 has PWM on pin 3 (or pin 4), it doesn't work. Instead of getting 1 Hz pulses increasing to 5 Hz, I get a much faster pulse train (10 Hz maybe?) that doesn't change in frequency.
I suspect that perhaps due to the higher clock frequency on the Teensy 3.2 vice the Uno, TimerOne cannot go as slow as I need it to go?
Any help / advice is greatly appreciated!
Thanks much and 73,
Ben, KD5BYB
I'm in the process of creating a controller for a diesel-fired heater. It uses a metering pump to inject a known amount of fuel into the burner. I need to inject fairly low duty cycle pulses into the metering pump at fairly slow rates for this to work properly. (from about 1 Hz to a maximum of 6 Hz, at a duty cycle of 10% to 20%)
I tried the code below on an Arduino Uno using an LED and 1k resistor connected to Pin 9. Works perfectly! I get a 1 Hz pulse train for 5 seconds, then 2 Hz, then 4 Hz, then 5 Hz.
However, when I try it on a Teensy 3.2, adjusting the code to reflect that Teensy 3.2 has PWM on pin 3 (or pin 4), it doesn't work. Instead of getting 1 Hz pulses increasing to 5 Hz, I get a much faster pulse train (10 Hz maybe?) that doesn't change in frequency.
I suspect that perhaps due to the higher clock frequency on the Teensy 3.2 vice the Uno, TimerOne cannot go as slow as I need it to go?
Any help / advice is greatly appreciated!
Code:
#include <TimerOne.h>
void setup(void)
{
pinMode(9, OUTPUT);
Timer1.initialize(10000000); // 1 Hertz
Timer1.pwm(9, 100);
Serial.begin(115200);
}
void loop(void)
{
Serial.println(millis());
delay(5000);
Serial.println(millis());
Timer1.setPeriod(500000); // 2 Hertz
delay(5000);
Serial.println(millis());
Timer1.setPeriod(250000); // 4 Hertz
delay(5000);
Serial.println(millis());
Timer1.setPeriod(200000); // 5 Hertz
}
Thanks much and 73,
Ben, KD5BYB