Pages: [1]   Go Down
Author Topic: Arduino instead of a washing machine timer  (Read 1686 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I would like to use Arduino instead of a washing machine timer. Basicly the idea is to use 11 relays as outputs to control the motor, 2 water pumps, heater and the dock lock. 4 washing programs will be available and a terminate button to end program thus empting the machine and unlock the door (if necessary).

I'be try this with leds, experiminting with some progamming, before spending the necessary relays, transistors.. ect

Since I'm new to Arduino, any comments are appricated. Some questions thou;

Is Arduino memory enough for perform a complex program?
Are there any Goto or Gosub (s) line comands so to avoid repeated commands?

Thanks in advance
Kenneth Agius from MALTA.

Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's actually a fairly simple program and the arduino is more than capable.  

The challenges will be the mechanical setup, hooking up the relays, etc.

There are program structures such as for loops and if statements to handle the program flow, a goto is generally considered to be bad programming, is basically never used in a high level language.

Gosub is not used in high level languages, you will use functions.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6636
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Make sure you understand the "safety" interlocks built into existing timer before your reproduce it on your arduino.  It would be a shame to miss reading that overflow sensor and end up with water all over...

Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6636
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Gosub is not used in high level languages, you will use functions.
"Gosub" is a BASIC construct for calling subroutines.   Arduino has subroutines (aka "functions") that work about the same, but are defined and called differently.

Here's some code from the Basic Stamp Reference Manual:
Code:
Main:
  DEBUG CLS                             ' Clear DEBUG window
  FOR phrase = 1 TO 6                   ' Print blocks one by one
    LOOKUP (phrase - 1),
           [Text1, Text2, Text3, Text4, Text5, Text6], idx
    GOSUB Print_It
    PAUSE 5000                          ' Pause for 5 seconds
  NEXT
  END
 
Print_It:
  DO
    READ idx, char                      ' Get next character
    idx = idx + 1                       ' Point to next location
    IF (char = 0) THEN EXIT             ' If 0, we're done with block
    DEBUG char                          ' Otherwise, transmit it
  LOOP
  RETURN                                ' Return to the main routine
Similar code in C (for arduino) would look something like this:
Code:
void print_it(int idx)
{
   char c;
   do {
     c = readdata[idx];
     idx += 1;
     if (c == 0) {
        break;
     }
     debug(c);
  } while (1);
}

main(void)
{
   int phrase, idx;
   debug(CLS);
   for (phrase = 0; phrase < 6; phrase++) {
     idx = lookup(phrase, textarray);
     print_it(idx);
     delay(5000);
   }
}
« Last Edit: April 15, 2008, 03:47:17 am by westfw » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks

I still can't understand "gosub" in C.
It seems like VB or VBA thus a function which returns a value. Can it be used several times? What I mean is why writing the same commands when you can call a routine 1,2,3 or many times you want.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Main:
  DEBUG CLS
'do something

gosub TURN_IT
'do something else

gosub TURN_IT
'do something else
                        
 END
 

TURN_IT:
 
'turn motor left for 5 sec
'turn motor right for 5 sec

 RETURN      
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 205
Don't Panic
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code would look something like this:

Code:
void turn_it(){
  turn motor left for 5 sec;
  turn motor right for 5 sec;
}

void setup(){
    //if you needed to set something up when you power the device on, do it here.
}

void loop(){
   //the Arduino runs this code in a loop, forever.

  do_something;
  do_something_more;
 
  turn_it();

  do_something_else;
  do_something_else_more;

   turn_it();

   do_something_else;
   do_something_else_more;

   turn_it();
}

Logged

iDuino - MaxSerial - [url=http://spi

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for help valuable help smiley
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
Gosub is not used in high level languages, you will use functions.
"Gosub" is a BASIC construct for calling subroutines.   Arduino has subroutines (aka "functions") that work about the same, but are defined and called differently.

Gosub works very similary to assembly level of CALL and RETURN, so even though the word is a BASIC construct, I had to choose my wording very carefully.

And I'm also very reluctant to say never use a goto because there are cases where it's the right thing to do, even in a HLL, but for an average user, it is best to tell them to never use one.

Anyway, I'm sure you know all this far better than I do.  See you on the piclist smiley-wink
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6636
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I still can't understand "gosub" in C.
It seems like VB or VBA thus a function which returns a value.
Yes.  C does not have a signficant difference between functions (subroutines that return a value) and procedures (subroutines that do not return a value.)  This makes it somewhat different than BASIC, ForTran, and some other languages.  In C, you just define a "function" that returns "void" (ie nothing.)
Logged

Pages: [1]   Go Up
Jump to: