Tuesday, 11 September 2012

How to Control an A/C motor

A new post after looong silence....
What happened in the meantime?

Our big question was: Can we control the A/C motor of this sewing machine?

Who is 'we'? I have had the most amazing help from an electronics expert, Bernd, in this project.

To be able to 'hack this sewing machine' (make it do what we want), we need to be able to do three things electronically:

  • Sense the needle position
  • Sense/know/estimate the motor speed
  • Control the motor speed, switch the motor on and off.
We have a proof of concept that the sensing might work; for the past weeks, we have been puzzling over the big question: Can we control this motor?

... So... we actually disassembled the whole machine. The electronic circuitry is in a plastic box underneath the motor jammed tightly into the frame of the machine, obviously never to be disassembled, with good reason: Inside the box, we have mains power (240V A/C) oscillating.

So, if you undertake this, be sure to play it absolutely safe and disconnect all power sources:
And then,... and if you manage to open a plastic box that doesn't want to be opened without breaking it, then... you may find something like this:
 

On the board there are plenty of capacitors and resistors, a potentiometer, a diode, and more... and the foot control (not shown here) is a simple variable resistor, a potentiometer. All this electronic circuitry somehow makes the motor start, stop, and go slow or fast, depending on how the foot control is pressed.

So, we decided we have to put our controlling element where the foot control is.
We soldered some additional wires in... at the back, where all the soldering is done:
PCB with extra wires attached, from top
PCB with extra wires attached, from bottom
... and what did we attach at the other end? How can we control 240V A/C with 5V D/C from an Arduino?
It's this little thing:

an optotriac MOC3021, generously donated by Bernd. Inside, a LED activates a triac: when the LED is on, a the triac switches on. It allows to switch a high-power A/C current on or off with a low-power 5-V connection.
This is how we connect it:
... although in our first experiment, we didn't connect an Arduino up yet, just an arbitrary 5V power source.

Here is its datasheet. It tells us that the "static forward voltage" V(F) will be 1.2V at current I(F) = 10 mA -- under these conditions, the LED will switch fully on and activate the triac. The Arduino will send in 5V. We have to dimension the resistor so that, when switched on, the current in the LED's circuit will be 10 mA. Voltage is 5V-1.2V = 3.8V, R = V/I, and we find that we need a 380 Ohm resistor -- 390 is the closest we had at hand.

Again: CAUTION. Mains power is running on the one side of this circuit! We wrapped everything up tightly, like this, to run our test:
Sewing machine frame sideways, motor up, control board in its case, optocoupler circuit tightly wrapped in cardboard.
We connected a 5V power source, and... the motor started! We turned it off again, and the motor stopped! Concept proved!

So... what's next? To do this with an Arduino, and to switch the motor off over small intervals within its A/C power cycle interval to make the motor go fast... or slow. This is called Pulse Width Modulation (PWM). Can we do this using an Arduino?

1 comment:

  1. Hi Barbara,

    Just wondering if you took this project any farther. I would like to do something similar and would love to learn from you and perhaps collaborate.

    ReplyDelete