A project log for Air Extractor Controller for AC

A solution to extend a mobile AC exhaust duct with a two speed air extractor

vincentmakesvincentmakes 04/29/2021 at 07:430 Comments

The board is functioning properly after uploading the sketch: the relays are properly triggered depending on the conditions. However I had issue with the LEDs consuming too much current vs what the Attiny can deliver to both the coils and the LEDs. I should have added some transistors in between to offload that to the power supply. 

Not a big deal though, after removing the min/max LEDs it still works perfectly. I will just use the sound of the fan and relays clicking as an indicator instead.

Now onto fine tuning the programming part:

edit: the steps below have been now replaced by a simple Vpp measurement. It's more than enough for what we want to achieve here. The sketch named Measurement2.ino has been used to display the ADC Vpp values we need.


What needs to be adjusted is the sampling phase: In order to calculate the RMS value we need to measure the sine wave current at regular intervals. Each measurement is squared and added to the previous sum. The 3 lines below do that:

currentSampleRead = analogRead(currentAnalogInputPin) 
currentSampleSum = currentSampleSum + sq(currentSampleRead) ;                                      
currentSampleCount = currentSampleCount + 1; 

Using the timestamps of the serial output I found that this set of instructions takes about 180uS to be executed. I need a measurement every 1ms, so I will add a 820uS delay in the loop.

 When a certain amount of measurement as been reached, we can calculate the mean and root of it, giving us the TRMS value.

The testing phase is a bit repetitive with the Attiny85 though. I'm using an Arduino as ISP in the middle and the process goes as following:

  1. Upload ArduinoISP sketch to the Arduino Uno
  2. Change the board to Attiny and programmer to Arduino as ISP
  3. Change wiring from Arduino to Attiny
  4. Upload Sketch
  5. Change board to Arduino Uno and programmer back to ArduinoISP
  6. Upload empty Sketch to Arduino
  7. Change wiring to serial TX/RX
  8. Launch Serial Monitor
  9. Debug, adjust Attiny .ino file
  10. Repeat