Regulating 120Vac w/Arduino - noob questions

UPDATE: This worked out so well, easily and safely that I've actually created a product and a small company out of it. I've sold several so far without any advertising, I've only posted it on the iRacing forums so far as I work out production issues. I give you - SimEffects


Hello,

Forgive me as I'm brand new to Arduino and while I have a basic knowledge of electronics virtually all of this is new to me.

I'd like to create a device that can vary the flow of 120Vac to a desktop fan - this would then be controlled via input from various driving sims/games such that the faster the car is moving the higher the voltage to simulate a wind effect. My goal is to make this as simple as possible in that you'd plug an existing small fan into the device rather than using a custom fan/enclosure. I can handle the programming side just fine, it's the 120Vac regulator hardware I don't understand.

Are there units that can be purchased that provide this functionality or would I have to piece that together myself? Ideally there would be an off-the-shelf module I could use, that the Arduino would control, that the fan would plug into (then it into the mains). I do understand the dangers of working with 120Vac so I would take all precautions there (this is also why I'd love to find something off the shelf that could do this).

I hope this isn't too basic of a question, if so apologies. Thanks for any guidance you can provide!

UPDATE: This was VERY simple - I purchased the dimmer controller linked just below, 3 wires to the Arduino (sensing off a PWM pin), cut an extension cord, AC to the wall, AC to the fan/lamp/etc. and voila, done. Took me less than 15 minutes to get a prototype working and about 30 more to get it integrated into my simulator (via SimHub).

And shockingly I didn't get zapped once. It's almost like if you take precautions it's no more dangerous than wiring an outlet

Amazon.com: PWM AC Light Dimmer Module 50Hz 60Hz For Arduino and Raspberry LED Smart Home : Electronics

~Ross

Undoubtedly, yes. You're looking for a "thyristor module". I bet something will pop up especially if you include 'arduino' in your search terms.

Edit: e.g. look here AC Dimmers DIY - Robotdyn
Looks pretty much exactly what you need. They also have examples on their website.

AC motors aren't always "easy" to control, different types of AC motors are controlled differently, and I actually don't know how to properly control a "regular small fan"...

DC motors can be controlled with PWM (through a MOSFET) and a lot of "computer fans" have a speed-output signal so you can control the actual RPM in a feedback loop. It's a LOT easier!!!

I've made a light dimmer (a long time ago with a different microcontroller).

An AC light dimmer circuit MIGHT work. A regular AC dimmer works by chopping the AC cycle so the power is on for only part of the cycle.

With it's done with a microcontroller circuit, the microprocessor has to be electrically isolated from the lethal power line voltage.

There is a zero-crossing detector that triggers an interrupt to start a timer. (An interrupt is used because otherwise your program is only reading the input pin once each time through a loop and the timing can vary.) After a delay the power is turned-on and it stays-on for the rest of the half-cycle. A short delay (or no delay) is full brightness, etc.

A TRIAC is used as the switching device. Unlike regular transistors & MOSFETs, a TRIAC can work on AC. TRIACs also have a "special characteristic" that they latch-on until current drops to zero. With AC that's the next zero-crossing. So, you just "hit' the TRIAC with a short pulse at the right-time every half-cycle.

There are special opto-isolators made for TRIACS (such as the MOC3021).

An opto-isolator is also normally used for the zero-crossing detector. Most opto-isolators are designed for DC, but it's possible to ignore the negative half of the waveform because if you find the positive-going zero-crossing you know when the negative-going zero-crossing is coming. (The opto-isolator does need to be protected from the reverse voltage, and that can be done with a diode.)

When I built my dimmer I also built the power supply so it got the (isolated) zero-crossing signal from the transformer secondary.

There are "dimmer modules" that have both isolators and the TRIAC and you might even find one with example code, but I don't have link.

This would be the way to go for OP, IMO. Please see the link I posted above; RobotDyn has both the modules and example code. Looks like a very nice place to start.

Thanks so much, I had read about thyristor modules but being a noob wasn't exactly sure if that's what I wanted. From looking at your link it does look exactly like what I'm thinking - do you know if I would need any other hardware? Does a thyristor take 120Vac input and also control output or do I need separate modules for both sides?

Yup, totally understand this - right now the desk fan I'm using is plugged into a simple light dimmer and while at max setting I certainly don't get full fan speed it works just fine for my application. Ultimately I'd consider turning this into a small device I could build/sell - going this route vs. DC fans makes the entire project much simpler for a customer - they buy my device and a fan (again understanding that not all fans would work perfectly) and it's that simple and cheap. Most of the "cheap" wind simulators you find are $250+ where this would be a fraction of that.

Thanks for all your other thoughts, seems I have a lot more reading to do and I appreciate the help!

~Ross

1 Like

Usually, yes. The RobotDyn modules I've seen so far all work OK with 120VAC.

That's what the thyristor thingy does. Of course, the control logic is up to you to fashion with an Arduino or something like that.
In principle you would only need an Arduino and something like this: AC Dimmer Module, 1 Channel, 3.3V/5V logic, AC 50/60hz, 110V~400V - Robotdyn

Would this be what you're referring to?
https://www.amazon.com/Light-Dimmer-Module-Arduino-Raspberry/dp/B06Y1DT1WP

Ross, because of your level of experience and understanding of electrical principles and electronic components, I would strongly recommend you do not attempt this project. You could be seriously injured or start a fire in your home.

Instead, find a high power but low voltage fan that runs on DC, and a ready-made AC-DC power supply with enough current capacity for the fan. This will make the project not only much simpler but much safer also.

That module from Amazon looks good, yes.

But I agree with @PaulRB as well. It would be quite a bit safer to use for instance a 12V fan that you can control with a logic level mosfet.

Perfect, just ordered it, thanks for your input!

I appreciate your concerns greatly but I assure you I can complete this project very safely. While I'm new to ardunio and these specific parts I've worked with electricity enough in my life to know what to respect and how to handle it. I have absolutely zero concern in my safety with a project like this but again greatly appreciate your concerns. I am however going to start with 12v fans since I can get going on the code side using them to test and once that's working swap in the dimmer module for the real fan. Safety is why I wanted to find a module like that rather than trying to understand it all and build my own.

Thanks again for the input and concern, please don't think I'm being dismissive of that, I assure you I will take all safety precautions and I'll be just fine :smiley: As I'm sure I'll have more questions as I get into the project I hope to find the same great assistance then.

Thanks!

~Ross

1 Like

Point taken; good luck with your project.

Yeah, I'd do that too. In fact, I'd probably start with a LED, then upgrade to a 12V computer fan with a 2n7000 or so and only then hook up the desk fan.

Yeah, that might be a better idea - although I have some fans sitting next to me and I'm sure if I have any LEDs that would work but I'll look around.

Boy am I glad I posted, you guys are great - I was worried I'd get hammered for being a noob, but instead I get help and concern. I guess the entire net isn't toxic, huh?? :smiley:

~Ross

I'm just not in a toxic mood today :slight_smile:

Got it - well I'll be sure to keep my guard up for when you are! It's not my first day on the net, hell I even have a Youtube channel with 75K subs so trust me, I can handle toxic just fine. Just glad I haven't seen it here..... yet.....

~Ross

If this were my product, I’d go to the wreckers, yu scar radiator fan along with a12V 10A DC supplies, and OWM the heck out of the fan.

Low volts, lots of air and the dog will stay alive.

Unless it gets eaten by the fan...

Well maybe if you actually read my goals you'd understand that 12V fans are a non-starter for what I want to accomplish:

My goal is to make this as simple as possible in that you'd plug an existing small fan into the device rather than using a custom fan/enclosure

You do realize that hundreds of thousands of people work with AC power on a daily basis without dying or killing their dogs, right? This isn't plutonium we're talking about, I'm 48 years old and can very easily and safely build this project. So thanks again for your concern, I assure you it isn't necessary.

~Ross

1 Like

Best suggestion is use a low voltage dc auto fan.
Most mains desk fan motors are speed controlled through either capacitors or line choke and you don't want to be fooling around with mains supply.

Use the thyristor PWM dimmer unit (or whatever they call it)

Well, it's fundamentally a dimmer, like ones you put in wall boxes. except the knob is a PWM signal from .. well, Arduino.
In theory you can just wire it as a regular dimmer and put the fan in series

HOWEVER, I know a fan speed controller is different from a light dimmer. A light dimmer might not work for a fan and vice versa.

You might get it to work, but because how async induction motors are designed, they cannot start from, say, 1% and may stall, which might damage the dimmer and motor

If I am to make it I will put a output socket so in the case that it dont work with the fan, I can have a light (or other stuff) plugged in and use the dimmer "as-intended".
Note that dimmers have a maximum wattage rating so make sure your desk fan isn't super-powerful and fry the unit.

Look here

You may be able to purchase a complete module.

And... I dislike and distrust AliExpress, however to aid in your search see this module