Hi,
It is better if you post your fritzy into your post.
OPs Fritzy....
Tom...
Hi,
I am sorry but Fritzy diagrams do not show the needed information, there are no label on any switches or LEDs to say what they reperesent, the wiring crosses over so connections to the UNO cannot be identified.
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a picture of a hand drawn circuit in jpg, png?
Your pen will be able to label and identify components.
Thanks.. Tom...
Got it. Okay the program starts corectly, but when i turn the level switch off is the valve still open for idk another 19 seconds, then the heater turns on, but the washing cycle stops until the heater switch is in the position, that the temperature is enough hot and then the washing cycle continues. Tom help.
Hi,
You are using two switches on each input so you can apply 5V and 0V to the arduino input.
A safer way is to switch the input with one switch and pull the input high or low when the switch is open with a 10K resistor.
Tom...
Thanks Tom, but now let's go to the program, which is bothering me a week now.
Dominik
Hi,
Can you give us a list of your inputs?
Can you give us a list of your outputs?
Can you give us an estimate of these times?
T1===the delay time after washing the water supply valve
T2===the time between changing the direction of rotation of the engine wash (stop)
T3===the rotation time of the washing engine left or right
T4===the operating time of the squeeze/wring
T5===the time after the termination and the end of the program
What is the estimated wash time?
What is the estimated squeeze/wring time?
This looks like a state machine type program.
I would think if the door was lifted the the machine would stop it program, and resume when the door is closed.
I'm not completely familiar with this sort of machine, but it looks as thought it has a heater built in to heat water during the wash cycle, where is the rinse cycle?
I only see
Thanks.. Tom...
This is from the program in Reply #12
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 have twice started to write a comment about this and both times stopped because I realized I was confused. Change your code so that it does not do digitalWrite(ledPin, !digitalRead(ledPin)); and, instead, explicitly sets the LED pin either HIGH or low. Like this
if (currentMillis - startMillis >= ONperiod) {
digitalWrite(ledPin, LOW));
startMillis = currentMillis;
}
if (currentMillis - startMillis >= OFFperiod) {
digitalWrite(ledPin, HIGH);
startMillis = currentMillis;
}
it will make it much easier to debug.
And I "think" you needs to have two different variables - call them onStartMIllis and offStartMillis so that the two IF tests don't both test the same variable and interfere with each other.
To implement a series of events such as a washing machine program you will definitely need a "state machine" approach in which the system progresses from one state to the next until it is finished. By using a variable to keep track of the state any confusion about timing should be avoided. Have a look at this suggestion I made in another recent Thread
...R
List of inputs:
• start button = 1
• door switch = 2
• level switch = 3
• heater switch = 9
List of outputs:
• valve = 8
• heater = 10
• pump = 11
• washing left = 4
• washing right = 5
• squezze/wring = 6
• operation = 7
Estimate times:
• T1===2 seconds
• T2===5 seconds
• T3===7 seconds
• T4===28 seconds
• T5===10 seconds
Everything is like in the timing diagram you send Tom.
Interesting challenge. Lots of programs, all of different pieces of the cycle. I'm really wondering how you can easily program that in code, all the while keeping it flexible.
There's a quote complex finite state machine in here: a lot of states it cycles through. Each state being a part of the wash cycle, and each state having a separate duration after which the machine advances to the next state (in part also based on the sensor input such as the temperature for the heating stage). Within the states you may have different states, e.g. a "washing" state that moves the drum back and forth at intervals.
You want to keep those things as flexible as possible, preferably set by a bunch of #define or similar statements, or as an array, at the start of the program. This allows you to make easy changes to the washing cycle later.
It's a job made for cooperative tasks, some could use state machines.
4 inputs can drive 7 outputs, but if you code it in one logic knot it will be a bear to debug and a whale to change much at all.
Hi,
The Start button cannot be pin1, that and pin0 are programming pins.
When washing left and washing right pins are both LOW, I assume the motor will stop?
You also need to note that
Tom...
You are correct Tom. Let's discuss the program. The first thing is, that every delay has to be switched with millis() and then we can see, what logical problems we will find. Can we get to that today Tom?
Dominik
I'd be tempted to build a washing machine simulator using another arduino to test this with.
At worst, it would let you control the inputs manually and report on what the controller was doing with the outputs.
Better, it could have a script of inputs and how they change over the machine's cycle so that you can run the machine repeatedly against the same scenario for debugging. You could build up to multiple test cases to test in error situations as well as the happy path.
Washing machine cycles take time. You can arrange that the simulator runs at ten times real speed (or more) to help you get the controller squared away.
Your project is quite a tricky one at your level of experience, debugging will be hard. A simulator would help I think, although of course, writing it is not trivial either and you may find that its own defects lead you astray.
Hi,
I think the code will need a lot of serial monitoring.
The code will have to be done in stages, and possibly assembled using switch .. case function.
I have to hit the sack guys, its nearly midnight here and I need some sleep.
Tom...
Majcen:
Let's discuss the program.
Have you studied Reply #26 ?
...R
Studied, tried, but doesn't work Robin.
Dominik
void pranje() {
digitalWrite(motor_levo,HIGH);
delay (7000);
digitalWrite(motor_levo,LOW);
delay (5000);
digitalWrite(motor_desno,HIGH);
delay (7000);
digitalWrite(motor_desno,LOW);
delay (5000);
while (digitalRead(stikalo_nivoja) == LOW) {
digitalWrite (ventil,LOW);
gretje();
}
}
void gretje() {
digitalWrite(LED_grelec, HIGH);
if (digitalRead(grelec) == LOW) {
digitalWrite(LED_grelec,LOW);
trikratna_ponovitev();
}
}
The program here does the washing cycle left and right and when there is enough water, the heater turns on, but the washing cycle stops. I want it to work together at the same time. How do I do it?
Dominik
It's not hte problem with millis(), the problem is with the pause, which i can't figure out, how to write.
Doing something and doing nothing works the exact same way with millis() timing.
Your timing code cycles through a bunch of states, and based on those states your code runs a motor, or just doesn't do anything, or checks a heat sensor whether the water is warm enough or whatever.