0

I'm trying to control my ~230 V fan from the Arduino.

Can anyone say the best possible ways to design a fan regulator that can be controlled by the Arduino using a low cost design.

  • Use TRIAC Circut. In this you can control the current flow to the FAN – Vaibhav Apr 19 at 11:47
  • How many relays needed to make 5 level regulator? I think it is not effective design. – Sivamani V Apr 19 at 11:51
  • Do you want a variable speed controller or single-speed? And is this a 3 phase motor? – Duncan C Apr 19 at 12:02
  • Single phase motor and variable speed controller for my home automation. – Sivamani V Apr 19 at 12:05
  • 1
    I use Kemo module to regulate a heater. They can regulate an inductive load too. For MCU control they have a digital pot module M150 controlled by PWM. kemo-electronic.de/en/Light-Sound/Effects/Modules/… – Juraj Apr 19 at 12:59
4

To control AC power for inductive load (motor) a Triac is used. The concept is called phase cutting. It works for a resistive load (heater) too.

This module is designed for phase cutting. It contains a zero crossing detector and a Triac. The control is done in MCU. The zero crossing detector is wired to an interrupt pin. The control signal for the Triac is wired to an output pin. In external interrupt function you set a timer interrupt to send a pulse to the Triac after some microseconds. Longer off time results in less power for the motor.

enter image description here

At 50 Hz AC, one pulse is 10 milliseconds. To cut a part of AC wave out, activate the Triac gate for 20 microseconds after 0 to 10 milliseconds. Triac turns self off the AC line at next zero crossing.

Robotdyn has a library for the module.

EDIT:

I bought the Robotdyn AC dimmer module to use it in my AC heater regulation project and I tested it with a incandescent light bulb and a fan. (video on youtube)

The library by Robotdyn works, but it is designed to control many dimmers and uses a timer interrupt every 12 microseconds (yes, micros). The library sets the interrupts over MCU registers.

I wrote an adrduino fade-in/out sketch using TimerOne library to demonstrate phase cutting with this module.

#include <TimerOne.h>

const byte INTERRUPT_PIN = 2;
const byte TRIAC_PIN = 4;
const byte TRIAC_PULSE_MICROS = 30;

const int FADE_MAX = 9800;
const int FADE_MIN = 2000;

volatile bool triacOn;
volatile int period = FADE_MIN; // microseconds cut out from AC pulse

int fadeAmount = 10;

void zeroCrossing() {
  triacOn = false; // triac tuns off self at zero crossing
  Timer1.setPeriod(period); // to call triacPulse() after off period
}

void triacPulse() {
  if (triacOn) { // stop pulse
    digitalWrite(TRIAC_PIN, LOW);
    Timer1.stop();
  } else { // start pulse
    digitalWrite(TRIAC_PIN, HIGH);
    triacOn = true;
    Timer1.setPeriod(TRIAC_PULSE_MICROS);
  }
}

void setup() {
  pinMode(TRIAC_PIN, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), zeroCrossing, RISING);
  Timer1.initialize();
  Timer1.attachInterrupt(triacPulse);
}

void loop() {
  period = period + fadeAmount;
  if (period <= FADE_MIN || period >= FADE_MAX) {
    fadeAmount = -fadeAmount;
  }
  delay(25);
}

EDIT 2 version with triac activated by 'pwm' pin

const byte TRIAC_PIN = 9;
const byte ZC_EI_PIN = 2;

unsigned long topMicroseconds = 9700; // 10000 micros is between zero crossings
int prescaler = 8;
byte prescalerBits = _BV(CS11); // /8

void zeroCrossing() {
  TCNT1 = 0; // reset the timer counter
}

void setup() {
  Serial.begin(115200);
  Serial.println("START");

  attachInterrupt(digitalPinToInterrupt(ZC_EI_PIN), zeroCrossing, RISING);

  pinMode(TRIAC_PIN, OUTPUT);
  uint32_t topPeriod = ((F_CPU / 1000000)* topMicroseconds) / prescaler ;
  ICR1 = topPeriod;
  OCR1A = topPeriod + 1;
  TCCR1A = _BV(WGM11) | _BV(COM1A0) | _BV(COM1A1);
  TCCR1B = _BV(WGM13) | _BV(WGM12) | prescalerBits;
}

void loop() {
  if (Serial.available()) {
    unsigned long microseconds = Serial.parseInt();
    Serial.find("\n");
    uint32_t period = ((F_CPU / 1000000)* microseconds) / prescaler ;
    OCR1A = period;
  }
}

on SAMD it is possible to setup this to start the timer on external interrupt over event, without an interrupt function. then the CPU of the MCU is not involved in phase cutting after the initial configuration of the peripherals

EDIT 3:

The TriacDimmer library version 1.1.0 for AVR Arduinos available in Library Manager works good with this dimmer. Fun fact: It uses timer1's input capture on pin 8 instead of external interrupt on pin 2 or 3.

  • the modules and component I linked in comments use this method. they work as 'pwm to phase cutting adapters' – Juraj Apr 21 at 8:50
  • The animated graphic is of rectified AC, does it really get down to a zero crossing to do a shut-off? – Dave X Jun 7 at 18:11
  • @DaveX, not to exact zero crossing but in the scale the animation is right – Juraj Jun 7 at 18:20
  • The waveform in the animation isn't right for AC--there's a sharp 'V' at length/2, it looks rectified, so instead of 50Hz 230Vrms AC, it's showing 100Hz (10ms) pulsed DC. The robotdyn module uses a triac that won't rectify like that diagram. It should have the second half of the top diagram flipped around it's X axis and twice the height. – Dave X Jun 14 at 16:49
  • @DaveX, the negative part is mirrored up. I didn't find a better one. I linked the animation from Wikipedia page about phase cutting. now I see SE copied the animation – Juraj Jun 14 at 17:23
1

Its not exactly what you are looking for but it will help Arduino-controlled-light-dimmer-The-circuit.

Here is the sample project in which TRIAC is used with arduino for controlling the flow of current to the light. In your case Light or better we can say load is FAN. This will help you in controlling the FAN Speed. Relay only act as switch and it won't control FAN Speed.

  • 1
    Link only answer? We are looking for comprehensive answers that provide some explanation and context. Very short answers cannot do this, so please edit your answer to explain why it is right. Additionally, we prefer answers to be self contained where possible. link only answers are frowned upon (as links tend to rot) & will be rendered useless if the linked-to content disappears. If you add more context and detail from the link, it is more likely that people will find your answer useful. – Greenonline Apr 19 at 12:37
  • Thanks Vaibhav, My thought is TRIAC's AC phase may affect arduino board which will affect my analog sensor readings in arduino and their is chance to death too :-/. – Sivamani V Apr 19 at 12:40
  • Now I think I am better clear about what I want to say. – Vaibhav Apr 19 at 16:45
-1

It depends on the motor.

To quote MarkT from this post:

The simple advice is you can't. Standard induction motors in domestic appliances cannot safely be speed-controlled (some can be a little, but its not easy to find out by how much).
Get a DC fan

To quote dc42, from this post:

What sort of motors do the fans have? If they use induction motors, then you won't be able to control the speed much using phase angle switching - the speed is tied to the supply frequency. If they are series-wound motors with brushes, then phase angle switching should work.

The results you reported when you tried to use the velleman kit suggests to me that the fans may have induction motors.


For more information, read:

  • Thanks Greenonline. But how fan regulators do this. From the blog, if I done with PWM signal with normal fan regulator circuit, the output pulse signal will affect the 50 Hz (Indian standard AC frequency) both home main supply box and connected devices. – Sivamani V Apr 19 at 13:04
  • Blog? What blog? Link? – Greenonline Apr 19 at 13:09
  • that's arduino forum forum.arduino.cc/index.php?topic=100899.0 from the joy reply – Sivamani V Apr 19 at 13:13
  • As this reply to Joy's post states, you need to use zero-crossing detection, which Juraj's answer correctly demonstrates. – Greenonline Apr 21 at 9:24
1

Finally i found it as a product available here with the thyristor circuit and electrical-contactless servo (PWM or ANALOG input) motor ( to drive the input) will helps to drive the output from 0 to 220V. smooth fan regulator can also do this with servo motor and without any external electrical component requirement . If it is not efficient way with low cost design command or answer your way. :-).

  • If your design is more efficient than mine your design is considered as answer. :-). Thanks in advance. – Sivamani V Apr 20 at 7:10
  • 1
    this is for manual regulation. you want to turn that pot with a motor? – Juraj Apr 20 at 13:34
  • @Juraj Thank you. That can be done by arduino PWM input. So we don't need to work for that. – Sivamani V Apr 20 at 14:35
  • the board I linked in my aliexpress comment looks better. labels and description swapped input/output (like you do: PWM input ?!), but the electronics should work – Juraj Apr 20 at 14:44
  • You are correct Juraj. That will perfectly match to this circuit ♥. But in question I asked to bring it in low cost design. Your answer is highly acceptable rather than cost. That's why I'm not mentioned my design also correct. – Sivamani V Apr 20 at 14:49
1

There is also the issue of isolation here, to keep the controller side from being connected to the mains for reasons of noise and safety. The previous posters' comments about doing this with triacs or mosfets, and phase angle control are all true. It is nearly impossible to control the speed of a single phase induction motor. Anyway, the most elegant solution is to get a 3 phase fan motor and a variable frequency drive with low-voltage DC control input. Run the pwm output from the Arduino through an opto-isolator (drive the internal led). Use the DC reference on the speed control to power the output of the opto-isolator. Run that through an rc lowpass filter to the speed control voltage input. I think you could get out of this for around 200$US. Check surpluscenter.com. there are many motors and drives out there. -Hugh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.