Yes i know its been a while but better late than never right ?
My plan for this post is to explain how to setup the washer based on the assumptions I did, which indeed is not the expertise of an electronic engineer but a software developer.
Let's fill and drain that tub
Anyways couple of things we noted from earlier post was regarding water inlet and water outlet (See part 1). So basically these two operations are binary, which means its either open or closed.
Also in my particular case the inlet and outlet were operated on a 240V AC input. So lets choose a 10A digital relay. as shown in the image this particular one has two relays in one board and has two input (3-5V) which can turn on the relay on digital 1.
Take a look at the following for relay Pin diagram
Since we just need to power on and off the inlet and outlet as required lets just ignore the NC pin and use COM and NO for the connection. Make sure the power is supplied to the COM and inlet/outlet connection is taken from NO.
For our case we are using the relay with an opto-coupler circuit inbuilt, so that there will be no feedback current coming back to Arduino.
The connection model i am using is as follows,
You can do the same for the outlet.
Caution: make sure the power ratings for the components you use are compatible with the connection. I have seen in some cases inlets use 12v instead of 220v, so if it is 12v use 12v supply or keep your fire extinguisher ready. But seriously, be careful out there.
In the code you can change the digital pin under:
define WaterFillValvePort 4
define WaterDrainValvePort 5
When these ports are at digital 1, the valves will get the supply through and they will open until you set the port digital value to 0.
Side Note: Since my pressure sensor is not working properly and i haven't had the time to spend on a RLC circuit, for the sake of POC we are just going to use time delays to fill and drain water.
void fillWater(int time_mins)
void drainWater(int time_mins)
Let's spin those motors
Now we know how to fill and drain water lets spin those motors,
When it comes to the washer motor those 10A relay wont hold, period. Also for the machine i own, the motor power supply is via 3 wires. one is a common ground and other two are for coils which turns in the opposite direction. Basically the ground and one coil will turn right, while other combination will turn left.
Now to wash we have to rotate the motor in both direction in specific intervals and we don't want to have the supply open to both coils at the same time, right ?
So the solution I came up with is to use a SSR (Solid state relay to turn on and off the main supply) while using a 30A dual-way relay to switch directions. The circuit is quite simple, we just need to turn off the supply switch to the direction we need and then turn on the supply.
Both these relay uses isolation from main supply and input, make sure to use opta-coupled or isolated relay so that no arc can get back through the input.
Now lets check the connection,
In the code you can change the digital pin under:
#define MotorPowerPort 2
#define MototrDirectionPort 6
Wash code implementation:
void doWash(int cycle_delay, int time_mins, String title)
process_name = title;
if (motor_status == CLOCKWISE) motor_status = ANTICLOCKWISE;
else motor_status = CLOCKWISE;
//TURN OFF MAIN POWER TO MOTOR
digitalWrite(MototrDirectionPort, motor_status); //SET MOTOR DIRECTION
//TURN ON MAIN POWER TO MOTOR
As described in the code above, to play safe we turn off the power to the motor then change direction and we turn it back on with a 1 second delay.
So now its matter of figuring out how do the operations in washing machine:
- Drain, in case the tub is not empty
Lets open the outlet valve for a few minute so that we can drain water just in case the tub has some water.
refer: drain(time in minutes)
- Fill the water to tub
We can open the inlet valve by supplying a digital one to the relay. wait for a specific time and then close it by sending digital 0, (turnoff the power).
We have to make sure the outlet valve is closed during this operation, or the water coming in will just drain through it.
refer: fillWater(time in minutes)
- Move the water a bit let the cloths settle-in
Now for us to move the tub a bit so that the cloths can settle in for some socking lets move the motor a bit. You can do it by, turning off the power to the motor via the SSR then set a direction to the directional relay and turn the SSR back on, It will start spinning in that direction now after a time delay again turn off the SSR and chnage the direction and turn it back on, it will spin in the other direction. lets dot it for a minute so that we can go for soaking.
refer: doWash(cycle length,total wash time in minutes)
In this particular case lets just set it to 3 seconds in each direction for a minute
- Soak em for a bit
Sock does nothing but wait for the clothes to soak, you can use in between the process for waiting a bit or soaking.
refer: doSoak(time in minutes);
- Wash or Rinse
Washing or rinsing is the same thing you just need to adjust the doWash timings a bit, you can do it with the same process as defined in the step 3. Make sure you drain the water as in step 1 and fill water back in as in step 2 in between.
To reduce the wetness in the clothes these washing machines do a spin at the end which is in a Clock wise direction most of the case. To do this we can open the outlet valve first to drain the accumulating water from clothes and start rotating the motor in one direction for a few minutes.
refer: doSpin(time in minutes,Direction);
You can arrange these processes in the following code as you desire, do note that after each process the process variable will be incremented by one.
boolean doProcess() //Return is Completed !
if (process == 0) drainWater(1);
else if (process == 1) fillWater(5);
else if (process == 2) doWash(4000, 10, "WASHING DRESS");
else if (process == 3) drainWater(2);
else if (process == 4) fillWater(5);
else if (process == 5) doWash(5000, 8, "RINSING DRESS 1");
else if (process == 6) drainWater(3);
else if (process == 7) fillWater(5);
else if (process == 8) doWash(6000, 7, "RINSING DRESS 2");
else if (process == 9) drainWater(2);
else if (process == 10) doSpin(3, CLOCKWISE);
else return true;
You can refer to the complete project code from the following link: https://github.com/redocnib/ArduinoWashingMachine-POC/
When you takeout the logic board, a washing machine is a set of components which wait for a particular input of power that in turn do independent operations. And if we apply relevant logic to manipulate the components we will have a process that will do what ever you wanted it to do.
I am looking forward to add a pressure sensor to the system so that we don't have to rely on time delay to do the drain and fill operations, also some ESP 32 integrations that can notify a smartphone and control the operations via WIFI.
If you are interested feel free to use this POC and develop it further.