Go Down

Topic: Dishwasher control advice needed (Read 1 time) previous topic - next topic

Robin2

If there was an overfill then I have a flood sensor on the bottom try (still to be programmed in) which will shut down the inlet valve.

If at all possible, have an anti-flood system that shuts off the water (perhaps shuts off all the power) without needing any signal from the Arduino

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

wildbill

I'd use the watchdog timer too, to recover from a crash. To help with that, write status info to EEPROM as the cycle progresses.

steve8428

I have not thought about the flood sensor at the moment as i still need to get it all running. Probably a good idea shut all power down by a relay in the event of a flood. At the moment there is a polystyrene disc on the bottom try which will float up in a flood and makes a micro switch. i could easily connect this is a relay to turn all the supply off when made.

WildBill thanks for the tip. i don't know how to do what you are suggesting. But later i will google this to see what i can find out

steve8428

I have now completed the door pause function. When the door is opened the flag status and the time door is opened if recorded. All pumps and valves are stopped. The program comes out of the current flag process to prevent any variables changing and gets put into a holding flag = 10.

When the door is closed the flag is reset so the program goes back to where it left off. The time the door was opened for is calculated and added to the interval of the current flag process. When that process is finished the pause time is rest to 0 so the next process does not have any delays.

This is the test code below which works well on bread board but still needs testing on the washer

Code: [Select]
int door = 30;
byte doorState;
byte pause = 1;
unsigned long TimeStopped = 0;
unsigned long pauseTime = 0;
unsigned long lastChecked = 0;
int duration = 300;
int flagStatus;

int flag = 0;

//-----Drain variables------
int drainPump = 25;
unsigned long drainStartTime = 0;
int drainRunning;

void setup() {
  Serial.begin(9600);
  pinMode(door, INPUT);
  digitalWrite(door, HIGH);
  pinMode(drainPump, OUTPUT);
  digitalWrite(drainPump, HIGH);
}

void loop() {
    doorFun(); // this will be in side prog_status loop so only called when wash in progress
    switch(flag){
      case 0:
           drainFun(10000);
      break;
      case 1:
        //Fill function
      break;
      case 10;
        Serial.println("Program Paused");
      break;
    }
}

void drainFun(long Draininterval){
  long interval = Draininterval + pauseTime;  // now have pause delay. If program was paused the delay will be added to the interval so the total
                                              // run time will always be the same if no pause the it will be equal to 0
  if(drainRunning == false){
    drainStartTime = millis();
    drainRunning = true;
  }
  digitalWrite(drainPump, HIGH);   
  if ((millis() - drainStartTime) >= interval){
        flag++;  //stop this process
        drainRunning = false;
        digitalWrite(drainPump, LOW);
        pauseTime = 0;   // reset pause time to zero so next flag is not running a pause add on.
      }
   }
// door function check door switch every 300ms. Time delay to stop any double reading when switch changing states
void doorFun (){
  if (millis() - lastChecked >= duration){
    lastChecked = millis();
    doorState = digitalRead(door);
  if (doorState == 0 && pause == true){ //door open
    pauseFun();     // call the pause function
  }
  if (doorState == 1 && pause == false){ //door closed
    restartFun();  // call the restart function
  }
  }

}

void pauseFun(){
  digitalWrite(drainPump, HIGH);
  if (pause == true){ //pause = true statment is so this is only called once to record the stop time. Then pause will be = false
    pause = false;
    timeStopped = millis();  // record the stop time
    flagStatus = flag;  //record what flag state the program was at
    flag = 10;  // set flag to 10 so program stops counting current flag state
  }
}
void restartFun(){
  flag = flagStatus;  // restart so set flag to number it was stopped at
  pauseTime = millis() - stopTime;  // record the time the door was opened for so we can add it to the interval
  pause = true;  // reset pause to true so door function can be recalled
}


With this i can add a pause button which will call the same pause function.


steve8428

#34
Jul 14, 2017, 06:20 am Last Edit: Jul 14, 2017, 06:21 am by steve8428
I still need to work out how the salt flush for the water softener works. I have a solenoid on the side of the salt box which I think when energized allows water into the salt box. But i cannot find any information on how this part works on the internet. If anyone can explain this part it would be a great help.

I also have a Whirlpool Turbidity Sensor which I hope i can use. The cables are all yellow so i don't know yet what ones do what. i will remove this next week and have a play.


I also still need to add some safety features.

  • As already stated a shut off if water overflows, Thinking of using external relay to cut off supply for this
  • Inlet water flow needs to be counted so the heater element will not turn on without water in the machine
  • An external watch dog to monitor that the arduino has not crashed and left the machine running with no control. I might use a micro arduino to monitor a pulse from the main arduino. If pulse stops possible crash use overflow relay to turn machine off.


Still lots to do.

steve8428

Just completed a full rinse today and have noticed two problems. When the wash pump starts up there is a kick from the Wash pump on start. This at first caused the jet selector switch to chatter which caused the wash count to increase by about 4 each time. I sorted this by putting a millis() time delay of 300ms before reading the switch the same as I did with the door function.

Code: [Select]
   
if (millis() - jetlastChecked >= duration){ //duration = 300
      jetlastChecked = millis();
   if(washCycle > currentWash){
     jetSWreading = digitalRead(jetSwitch);


This sorted the switch bounce but I am not sure the wash motor needs to be switch off during the movement of the jet selector. This jet selector moves within a second or two and is not a tight fit, water will pass around the side of the selector disc so the pump would not be under load.

The reason I am thinking this. Every time the pump is turned OFF and ON again the washer kicks a little and you hear a start up thud from the pump. This is something I never noticed from the original manufacturers wash. This has also caused the relays to chatter on two occasions, when the relay chatters the pump keeps kicking and will not start.

If i leave the pump on and just move the  selector every interval it all works OK and sound more like what it did before breaking. When the selector is not on the jet position it makes a whooshing noise which sounds normal from what I remember.

This will also help with the heating of the water as the heater can be on all the time the water temperature is low.

If anyone has worked on dishwashers and know more about this please let me know. There is not much information on the web.

I will at the moment proceed with the pump always on during a wash process

jadonmiller

I have been following this project for the last few days. I think it's great! Could you please post your current version of the code so lazy people like us don't have to piece together the various updates?  :)

Thanks!
The words "lead-free" and "solder" are like "vegetarian" and "meatloaf" - it won't work!

steve8428

I have had a little play with the turbidity sensor but not having much luck. The sensor has 6 terminals and I cannot guarantee the wiring diagrams I have found on the web are correct.

So far I have connected the supply up to the VDD 5v and GND ground and then pins 1 to AO and 6 to A1 of the arduino.

running the following sketch I get a reading of 0 which does not change when I cover the sensor. Not tried in in water yet

Code: [Select]
int temp = A0;
int x = A1;

void setup() {
  Serial.begin(9600);
  pinMode(temp, INPUT);
    pinMode(x, INPUT);
  Serial.println("SETUP COMPLETED");
}

void loop() {
  int reading2 = analogRead(x);
  int reading = analogRead(temp);
  Serial.println(reading);
    Serial.println(reading2);
  delay(1000);
}

 


So if I cannot get this working then I might pull the circuit out of the housing so I can use the housing and make my own sensor.

For the temperature i would like to use the DS18D20 1-wire device as I have used these before and they are very reliable and accurate.

For the turbidity I wonder if I could make my own with an LED and LDR setup or use a IR LED and IR receiver.

I will let you know how I get on but I am away at the end of the  week so might not be much posts for a while

steve8428

I have a strange thing happening which  I cannot work out why. In the following sketch at the bottom of this post I have an IF statement at the beginning which records the fill start time if the fillRunning variable is == to 0, which it will be at the start for this function. As it is, it works, but originally I had this IF statement just above this part
Code: [Select]
if((millis() - fillStartTime) >= fillInterval){ which worked on the first time around but the second time the fillStartTime would not be updated, even though the fillRunning was == to 0.

Don't know if this makes sense. It would be nice to know why this is happening so I can rectify it if i get a similar problem

Code: [Select]

long fillInterval = (100000 + pauseTime);  // pauseTime is calculated when door on opened

if(fillRunning == 0){         //fillRunning initially zero at setup
    fillStartTime = millis();
    fillRunning = 1;
    long start_time = ( millis() - fillStartTime);
}

int reading = digitalRead(flowSW);

if(reading != lastflowReading){
   if(reading == HIGH){
     flowCount++;
   }
}

lastflowReading = reading;

if(flowCount < 800){
   digitalWrite(fillValve, LOW); // fill valve ON
}
else{
   digitalWrite(fillValve, HIGH); // fill valve OFF
   flowCount = 0;  //reset flow count for next time
   flag++;            // increase flag to move to next function
   fillRunning = 0; // reset fillRunning to 0 for next time


if((millis() - fillStartTime) >= fillInterval){
   fillRunning = 0;
   if(flowCount < 50){
      faultCode = 2;  // This will stop wash and lock it in fault mode
      flowCount = 0;
      pauseFun();     // call pauseFun to shut the wash down
    }
  }
}

Robin2

Don't know if this makes sense. It would be nice to know why this is happening so I can rectify it if i get a similar problem
It will be easier to help if you post the two versions of the program. It would be too easy to imagine the wrong location for that line of code.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

steve8428

Hi Robin, first code is below

Code: [Select]

void fillFun(){
  int reading = digitalRead(flowSW);
  if(reading != lastflowReading){
    if(reading == HIGH){
      flowCount++;
    }
  }
  lastflowReading = reading;
  if(flowCount < 800){ //800
    digitalWrite(fillValve, LOW); //ON
  }
  else{
    digitalWrite(fillValve, HIGH); //OFF
    flowCount = 0;
    flag++;
    fillRunning = false;
  }

  if(fillRunning == false){
    fillStartTime = millis();
    fillRunning = true;
  }
  long interval = (100000 + pauseTime);
  if((millis() - fillStartTime) >= interval){
    fillRunning = false;
    if(flowCount < 50){
      faultCode = 2;
      flowCount = 0;
      pauseFun();
    }
  }    
}


and this is the current code i changed it to

Code: [Select]
void fillFun(){
 long fillInterval = (100000 + pauseTime);
 if(fillRunning == 0){
    fillStartTime = millis();
    fillRunning = 1;
  }
  int reading = digitalRead(flowSW);
  if(reading != lastflowReading){
    if(reading == HIGH){
      flowCount++;
    }
  }
  lastflowReading = reading;
  if(flowCount < 800){ //800
    digitalWrite(fillValve, LOW); //ON
  }
  else{
    digitalWrite(fillValve, HIGH); //OFF
    flowCount = 0;
    flag++;
    fillRunning = 0;
  }
    
  if((millis() - fillStartTime) >= fillInterval){
    fillRunning = 0;
    if(flowCount < 50){
      faultCode = 2;
      flowCount = 0;
      pauseFun();
    }
  }
}


with the first code the program will run ok on the first loop, but second time around fillStartTime = millis(); does not happen even though fillRunning is false. When doing a serial print fillStarttime is sill counting from the first time around.

With the change in code location it works all ok. On the second loop fillStartTime is updated so the count starts at zero and all works.

Stange i cant see why but at least it works at the moment

Robin2

I think the problem is here (extract from first version)
Code: [Select]
  else{
    digitalWrite(fillValve, HIGH); //OFF
    flowCount = 0;
    flag++;
    fillRunning = false;
  }

  if(fillRunning == false){
    fillStartTime = millis();
    fillRunning = true;
  }


You can see that fillRunning is set to false just before the next test. But in the second example the test is at the top of the program.

I could well be wrong :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

steve8428

I thought I would do an update on where I am with the dishwasher so far. The previous problem on POST#40 I believe this is sorted and was due to me running to many tests including an LCD refresh every loop which caused the flow count to be extremely slow. Hence the fault time was reached. At least I know now the fault code for the flow function works.

Attached is the complete code so far if anyone is interested in going over it. At the moment I have not tested the "on/pause/restart" and "reset" buttons. But the wash itself works very well. I have now done 3 washes and the dishes and pans including baking pans have all come out clean and dry.

I still have a number of things to do but will be away till mid August
.
The salt box is still not working still need to work out how this works.

The flood sensor is not connected. The manufacturer's schematic shows this in line with the fill valve and not the processor card. This would be easy if I do this.

Fault codes still need to be written

LCD screen would be nice

A Program button so I can choose a wash or rinse cycle

For now I will do some more washes to see if any faults occur that need addressing

I also hope to have this on my web site as a project soon



steve8428

The previous uploaded code had a lot typo errors So I have attached a better version which now has the on/pause/restart button working.

Not got the reset part to work correctly yet.

Go Up