Hello guys,
I'm doing a project to automate a washing machine. The electrical part is done, I just have problems writing the right program. The timeline of the wasing machine in in the attachment. Check out the project on TINKERCAD under the link: Tinkercad | From mind to design in minutes. Thanks for your help.
Most modern washing machines have many different possible wash cycles built-in, with their own microcontroller.
1/ Are you trying to build your own? - that's quite a job. Cheaper to buy one.
2/ Do you work for a firm designing washing machines ? - ask a colleague.
The main problems, I suspect, are with the various drivers, particularly the main motor which both needs to reverse and to be variable speed. Not trivial.
Majcen:
Hello guys,
I'm doing a project to automate a washing machine. The electrical part is done, I just have problems writing the right program. The timeline of the wasing machine in in the attachment. Check out the project on TINKERCAD under the link: https://www.tinkercad.com/things/dJAxJmEhHLO. Thanks for your help.
I see your timing diagram, can this be done by turning pins on and off then the action of each pin can be described as a series of time intervals between changing the pin for each pin.
Arduino time is kept in unsigned long variables, both the millis() and micros() functions return unsigned long. When we subtract a start time from and end time we always get the difference, when we subtract a start time from "now" we can compare how long that has been with a desired elapsed time and act IF the interval is over.
The pins have different numbers of on-off times, each pin will need an array of time intervals, an index and how many intervals for variables.
How far along with Arduino and/or C?
Do you want the machine to respond to user input at any time?
The Arduino is connected to a board with optocouplers. Three pins (4, 5 and 6) in the Arduino are used to controll these octocouplers, which give then 24V to the Siemens Sinamics V20 Inverter which then controls a three phase motor.
I know that everything in this program is build on multitasking, but I don't know how to do it correctly, especially because I have trouble understanding the millis() function and putting it to my program.
Majcen:
I know that everything in this program is build on multitasking, but I don't know how to do it correctly, especially because I have trouble understanding the millis() function and putting it to my program.
Put coffee on. Stare at watch until 1 minute has elapsed. Pour coffee.
Cook bacon. Stare at watch until 2 minutes have elapsed. Serve bacon.
Fry eggs. Stare at watch until 3 minutes have elapsed. Serve eggs.
The flaw in this is that whichever way you do it, something is going to be cooked too early (and get cold).
In computer terminology this is blocking. That is, you don't do anything else until the one task at hand is over.
What you are likely to do is this:
Start frying eggs. Look at watch and note the time.
Glance at watch from time to time. When one minute is up then ...
Start cooking bacon. Look at watch and note the time.
Glance at watch from time to time. When another minute is up then ...
Put coffee on. Look at watch and note the time.
When 3 minutes are up, everything is cooked. Serve it all up.
In computer terminology this is non-blocking. That is, keep doing other things while you wait for time to be up.
Something he doesn't say; cooking 1 at a time takes 6 minutes, cooking together takes 3.
And then he goes into the how of the code, the techniques of time on Arduino.
That is link 1 of the 3 in my signature space below. Part 2 has a section on State Machines. State machines let you break a job into steps and run each in turn, and more. You already know how to read pins so add timers and state machines, you have power in your toolbox. Think about learning C pointers in the near future, they're extremely useful.
Majcen:
Write the code please so I will understand.
If you're too lazy to even read and try to understand a tutorial (including code examples that demonstrate the technique nicely) you won't get anywhere with your project. Especially as a washing machine's software is quite simple and straightforward, in contrast to the hardware (high power, high voltage, waterproofed motor and heater controls plus a good number of sensors).
Majcen:
Write the code please so I will understand.
I can do that for you. I accept Paypal.
Let's move this thread over to Gigs and Collaborations, where people who do not have the time, desire or ability pay other people to write code for them.
We can negotiate the amount of money you will pay.
OR, you can stay here. You can follow the suggestions being made here, read the sources provided and write some code. See how it works.
If you get stock, there are a lot of people who will help.
unsigned long startMillis; //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long ONperiod = 1000; //the value is a number of milliseconds
const unsigned long OFFperiod = 500; //the value is a number of milliseconds
const byte ledPin = 13; //using the built in LED
void setup()
{
pinMode(ledPin, OUTPUT);
startMillis = millis(); //initial start time
}
void loop()
{
currentMillis = millis(); //get the current "time" (actually the number of milliseconds since the program started)
digitalWrite(ledPin,HIGH);
if (currentMillis - startMillis >= ONperiod) //test whether the period has elapsed
{
digitalWrite(ledPin, !digitalRead(ledPin)); //if so, change the state of the LED. Uses a neat trick to change the state
startMillis = currentMillis; //IMPORTANT to save the start time of the current LED state.
}
if (currentMillis - startMillis >= OFFperiod) //test whether the period has elapsed
{
digitalWrite(ledPin, !digitalRead(ledPin)); //if so, change the state of the LED. Uses a neat trick to change the state
startMillis = currentMillis; //IMPORTANT to save the start time of the current LED state.
}
}
I want to start with the diode on HIGH potential, but then the program doesn't work. Help!
"Program doesn't work" does not provide any useful information from which to help you.
You need to tell us in as much detail as possible exactly what the program does and what you want it to do that is different.
To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum
Okay, thanks for the advice. So what I am trying to do is, that when te program strarts, I want that the LED is on and is then ON for T1, after that it toogles and is OFF for T2. Doing it with millis().
Majcen:
So what I am trying to do is, that when te program strarts, I want that the LED is on and is then ON for T1, after that it toogles and is OFF for T2. Doing it with millis().