View Single Post
Old 02-13-13, 11:36 PM   #35
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default Video of CO2 Controller for HRV!

More progress to report...

Trying to send analog voltage from Telair to Teensy PWM pin.

Scaled the 1024 step analog read to 256 step PWM write.

Code:
int CO2_Read = 38;                  // initialize pin 38 for input of analog voltage
int PWM_feed = 14;                  // initialize Teensy pin 14 for PWM

 
void setup()   {                    // BEGIN SETUP
  pinMode(PWM_feed, OUTPUT);        // Make Brightness (AKA: pin 14) an output pin
  int CO2_Read = 0;                 // variable set to zero
  int PWM_feed = 0;                 // variable set to zero               
  Serial.begin(38400);
}                                   // END SETUP

int CO2_volt = 0;

void loop()               
{                                   // BEGIN LOOP
  CO2_volt = analogRead(CO2_Read);  // read the Teensy input pin 38
  PWM_feed = (CO2_volt/4);        // PWM out takes the value of CO2 volt divided
  Serial.print("PWM_feed is = ");   // print val to serial monitor
  Serial.println(PWM_feed);
  delay(1000);			    // delay 1 second before repeating loop
}                                   // END LOOP
Which yielded this result:


Then I was really interested in using setup to actually power a fan, to get some idea if this was actually feasible.

I knew that the output from the Teensy pins was pretty puny, but trying to attach ANYTHING more than an LED led to disappointment.

So I learned about various Power MOSFET transistors, as the solution. I discovered that the choices of MOSFETS that can directly interface with Teensy is fairly limited, because most MOSFETs need at least a 10v pulse to turn on the transistor, but the Teensy only has 5 volts.

I did find out that these will work:
  • RFP30N06LE
  • IRL540
  • IRLZ44N
  • ST95N2LH5
  • IRF520
... but nobody in this city has one. So I ordered 10 of the RFP30N06LE from Sparkfun... (wait a week)

I also found out that you can build a single transistor amplifier to kick the 5 volt output up to 10 volt(+) levels, which I did until the real thing arrives.

I also discovered that the single transistor amp inverts the signal, so I wrote a line of code that inverted the pulse, and I'm in business.

Code:
int CO2_Read = 38;                  // initialize pin 38 for analog voltage in
int PWM_pin = 14;                   // initialize pin 14 for PWM

 
void setup()   {                    // BEGIN SETUP
  pinMode(PWM_pin, OUTPUT);         // Make PWM_pin (AKA: pin 14) an output pin
  int CO2_Read = 0;                 // variable set to zero
  int PWM_pin = 0;                  // variable set to zero               
  //Serial.begin(38400);
}                                   // END SETUP

int CO2_volt = 0;
int PWM_feed = 0;
int DutyCycle = 0;
int PWM_invert = 0;

void loop()               
{                                   // BEGIN LOOP
  CO2_volt = analogRead(CO2_Read);  // read the Teensy input pin 38
  PWM_feed = CO2_volt/4;            // Scale CO2_volts (1024) to PWM (256)
  PWM_invert = 256 - PWM_feed;  // Invert PWM_feed
  //analogWrite(PWM_pin, PWM_feed);
  analogWrite(PWM_pin, PWM_invert);
  Serial.print("PWM_feed is = ");   // print val to serial monitor
  Serial.print(PWM_feed);
  //DutyCycle = PWM_feed/256;
  DutyCycle = CO2_volt/10 ;
  Serial.print(" and duty cycle = ");
  Serial.print(DutyCycle);
  Serial.println("%");

  delay(1000);			    // delay 1 second before repeating loop
}                                   // END LOOP
See fan spin!



Many thanks to the very helpful dorks at DorkbotPDX, you guys helped me a bunch!

Best,

-AC_Hacker
Attached Images
 
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...

Last edited by AC_Hacker; 02-16-13 at 11:36 AM..
AC_Hacker is offline   Reply With Quote