Hi all, [using teensy 3.5 here]
I'm looking for input/advice about the behavior of analogwrite when I have used teensy's analogwriteFrequency() function set to a particularly low frequency.
Particularly, what happens to the signal when I update analogWrite several times a cycle. Am I interrupting timer count at all? Does the timer go to zero? I am running the standard arduino PID library and end up calling analogWrite(pin, output) quite a few times during a given pwm cycle, because my frequency is set so low. For me, it's a 1hz frequency that I want to use.
I assume that if I am at the time point in a cycle of 500/1000ms and my flag is set to 510ms, if I write analogWrite(pin,output) such that the pin should now turn off at 520/1000ms, it just turns off in 20ms, not another 520ms. Similarly, if I am at 500/1000ms and I write analogWrite(pin,output) such that the cycle should end at 490mS instead of 510mS, that the pin state simply changes when I write analogWrite(pin, output), since it is over the point it should trigger. I could imagine if the behavior doesn't follow what I've described, I could have problems by calling analogWrite so frequently within a cycle.
The reason I am using a 1hz frequency is that I selected that as "slow enough" to be useful with a zero-crossing SSR, i.e, the kind that can only turn off 60 times a second. I know I could deal with this in software instead of PWM, but feel it would be more versatile to use pwm since the writeFrequency function lets me change between fast and slow PWM for different projects.
Please let me know if I can clarify the question any better. Thanks for any advice and input!
I'm looking for input/advice about the behavior of analogwrite when I have used teensy's analogwriteFrequency() function set to a particularly low frequency.
Particularly, what happens to the signal when I update analogWrite several times a cycle. Am I interrupting timer count at all? Does the timer go to zero? I am running the standard arduino PID library and end up calling analogWrite(pin, output) quite a few times during a given pwm cycle, because my frequency is set so low. For me, it's a 1hz frequency that I want to use.
I assume that if I am at the time point in a cycle of 500/1000ms and my flag is set to 510ms, if I write analogWrite(pin,output) such that the pin should now turn off at 520/1000ms, it just turns off in 20ms, not another 520ms. Similarly, if I am at 500/1000ms and I write analogWrite(pin,output) such that the cycle should end at 490mS instead of 510mS, that the pin state simply changes when I write analogWrite(pin, output), since it is over the point it should trigger. I could imagine if the behavior doesn't follow what I've described, I could have problems by calling analogWrite so frequently within a cycle.
The reason I am using a 1hz frequency is that I selected that as "slow enough" to be useful with a zero-crossing SSR, i.e, the kind that can only turn off 60 times a second. I know I could deal with this in software instead of PWM, but feel it would be more versatile to use pwm since the writeFrequency function lets me change between fast and slow PWM for different projects.
Please let me know if I can clarify the question any better. Thanks for any advice and input!