I'm having trouble with a code I'm writing which needs to generate PWM signals in order to run cooling fans for an HVAC system. I've used PWM.h library and it works with a simple script (call variables and run with pwmWrite) to generate the signals, see OScope photo 1, here is the code that works fine and reflects Oscope photo 1:
#include <PWM.h>
int evap1 = 9;
int evap2 = 10;
int confan = 3;
void setup()
{
// put your setup code here, to run once:
InitTimersSafe();
Timer1_SetFrequency(100);
Timer2_SetFrequency(35);
pinMode(evap1, OUTPUT);
pinMode(evap2, OUTPUT);
pinMode(confan, OUTPUT);
pinMode(pin4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
analogWrite (evap1, 1800);
analogWrite (evap2, 6000);
analogWrite (confan, 100);
}
Now, if I want to get a 4th signal from pin 11, which is on the same timer as pin 3 (and therefore should have same frequency and resolution) both pin 11 and pin 3 no longer have pwm and go to straight on/off (see OscopePhoto2);
The full code that generates OscopePhoto2 is here:
#include <PWM.h>
int evap1 = 9;
int evap2 = 10;
int confan = 3;
int pin4 = 11;
void setup()
{
// put your setup code here, to run once:
InitTimersSafe();
Timer1_SetFrequency(100);
Timer2_SetFrequency(35);
pinMode(evap1, OUTPUT);
pinMode(evap2, OUTPUT);
pinMode(confan, OUTPUT);
pinMode(pin4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
analogWrite (evap1, 1800);
analogWrite (evap2, 6000);
analogWrite (confan, 100);
analogWrite (pin4, 100);
}
So, does anyone have experience with generating multiple pwm signals and having it work?
The code-snippet I've included in this posting is a subroutine of a larger program. The program works to do everything other than generate the pwm signals properly.
Any help, guidance, direction, other ideas for methods to write pwm signals? I really appreciate any/all input!

