WARNING!!! At first, I'll write a quotation:
STOP!!! This circuit is attached to a 110-220 voltage. Do not build this if you are not confident about what you are doing. Unplug it before coming even close to the PCB. The cooling plate of the Triac is attached to the mains. Do not touch it while in operation. Put it in a proper enclosure/container.
WAIT!!! Let me just add a stronger warning here: This circuit is safe if it is built and implemented only by people who know what they are doing. If you have no clue or if you are doubting about what you do, chances are you are going to be DEAD!!! DO NOT TOUCH WHEN IT IS CONNECTED TO THE GRID!!!
Now let me introduce my project. It's an Arduino-controlled motor speed regulator which uses phase cut dimming method and PID algorithm.
Controller main features:
- Two speed ranges for quicker desired RPM change.
- Rotary encoder lets to set desired RPM before motor start.
- Push button of encoder starts and stops the motor.
- 2x16 LCD display for status and RPM display.
- Motor soft start.
- Keeps RPM and torque at load.
- Speed and torque control by PID algorithm.
- Motor stuck (or speed sensor malfunction) protection.
- Overspeed (usually when triac is damaged) protection.
There is the video where you can watch the controller at work:
Motor stuck protection at work:How it all started
After watching this video (in Russian language):
I decided to build a similar lathe. And successfully repeated this project. With some changes of course. Only one thing left - the motor. At first I used the asynchronous one phase motor with running capacitor. Main disadvantages of this kind of motor:
- No cheap speed adjustment. Nor mechanical, nor electronic. Have to use set of pulleys or expensive electronic controller.
- Limited speed - only 1400 RPM.
- Limited working time - 10 minutes run / 6 minutes idle. Otherwise it goes hot.
As you could notice the guy from video used the motor which was salvaged from old washing machine. The same motor I had in my workshop. Only one thing left - the motor speed controller. Without it the motor will spin at it's maximum 15000-19000 RPM. It's too much for wood lathe. To control the motor peed we could use a SCR voltage regulator, but at low RPM the motor will be weak with no torque. Fortunately this kind of motors has tacho sensors and we can do a closed loop system to have a stable RPM even at load and control the torque.Searching for solution
There is well known chip TDA1085 which is specially designed to control motors with speed sensors speed. But I didn't had this chip and to see the RPM I had to make a tachometer. At Chinese stories I found a cheap AC motor speed controller with RPM stabilization feature. I bought one and tested. Everything is fine except few things:
- Only 400W. (could be increased by changing the triac)
- Max RPM is 1450! After my used pulleys will be around 480 RPM only!
- No RPM display.
After surfing the internet I found several speed controller projects and decided to make my own controller using found ideas.
There is a list of resources I used:
- A lot of theory. Also I used a tacho sensing circuit part from here.
- Also NXP application note. Lots of useful information.
- Some theory, useful code and schematic is here.
- Got some ideas and took some pieces of code from here (Russian).
- Dimming code I used from here (IMHO the best dimmer).
- RPM counting code took from here (Russian).
- Took some pieces of PID usage code from here.
- The PID library.
- The PID library description. Also here.
- Some useful information about PID library usage.
I won't give a theory how AC phase cut works because there is nothing new. I provided some links with dimming and motor control theory above (the first and the second link). NXP and Microchip has lot of useful information about controlling motors.
The schematic diagram drawn as separate blocks:
- Arduino Nano V3
- 16x2 HD44780 LCD with PCF8574 I2C module. (Given module schematic is not exact!).
- Tacho pulses detection. Uses LM393 comparator to convert tacho pulses to microcontroller level.
- Zero cross detection. Every time when AC line crosses zero point microcontroller receives a signal. High voltage circuit is isolated from microcontroller by using optocoupler.
- Relay control circuit made by using simple NPN switching transistor.
- Motor control circuit is isolated by optocoupler and uses a triac with snubber circuit (C4, R14). It's possible to use a snubberless triacs (no C4 and R14 required then).
- AC/DC power module. 5V, 0.5-1A is enough. I used an old phone USB charger.
- Rotary encoder, 10A power line switch with indication, any 3 position switch for RPM range switching.
All components are soldered on protoboard. For more controllers I'll trace a PCB. Some pics:
I used a BTA41 triac because I had this in my stock. It's possible to use a 10-16 Amperes triac. I.e. BTA16.
Full listing of used components you could find in txt file in the zip archive.Construction
I had the plastic enclosure in my workshop which met my requirements. So I used it for this project. The box dimensions: H 150mm (~5.9"), W 70mm (~2.76"), L 110mm (~4.33"),
I tried a lot of motor control and phase cut synchronization algorithms but most of them had own disadvantages. Motor control wasn't stable. Sometimes it jumped during start, sometimes during run. Sometimes motor ran till its maximum RPM for unknown reason. Finally I decided to use and understand a PID control method.
The code uses 2 external interrupts. One for zero crossing, one for tacho sensor. A timer for triac pulses delay control. A PID algorithm for output control in relation of setpoint and input. For soft motor start I made a RAMP acceleration algorithm. During start PID parameters has lower values and returns to normal values during motor run. This prevents against hard motor starting (jumping).
LCD refresh interval is 2 seconds. It's enough to observe real RPM change. Making this faster can affect the system stability. It's because the LCD library uses delay functions.
I used a lot of global variables to simplify a system tuning by your needs and different motors. Later I'll include test and tuning sketches into the archive.
All used libraries can be found in the zip archive.Conclusion
I'm happy how my DIY controller works. Now I need to mount the motor on lathe and test in real environment.
I want to thank colleagues from Arduino groups on Facebook for help. And thank my wife for patience :D
Comments an questions are welcome.
Sorry for my English. ;-)Update
I added one new parameter to my code. It's pulley ratio. In my case it's 2.96. It's difference between smaller pulley on the motor and a bigger on the spindle. Pulleys I used were salvaged from dumped vehicles. Use a sketch without ratio parameter or set it to 1 if no pulleys will be used.
I mounted the motor on my lathe and tested it a little. I'm happy. Everything works like expected. It's enough torque even at low speeds.
Soon I will make a cover for motor, holder for control box and etc.