Pages: 1 [2]   Go Down
Author Topic: any ideas?  (Read 1870 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Not like this: code]pinMode(resetbutton, OUTPUT);
Quote

what is that meant to mean??

i put it in the loop and now the fan does not turn off aswell as the original problem
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what is that meant to mean??

Sorry, my tags got tangled.

I assumed that if you were reading "resetbutton", you'd want to make it an input, not an output.
« Last Edit: January 30, 2012, 03:57:00 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

o ok
still not working now it flashes between the fan and the lockoutled

this is seding me around the bend now lol
Logged

Reno Nevada USA
Offline Offline
Newbie
*
Karma: 0
Posts: 37
C# Developer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
const int heatbutton     = 2;
const int ventbutton     = 3;
const int ignition       = 4;
const int saleswitch     = 5;
const int solenoid       = 6;
const int photo_pressure = 7;
const int lockoutled     = 13;
const int resetbutton    = 9;
const int fan            = 10;
const int map1_or2       = 11;

void setup()
{
  pinMode(heatbutton,     INPUT);   
  pinMode(ventbutton,     INPUT);
  pinMode(saleswitch,     INPUT);
  pinMode(photo_pressure, INPUT);
  pinMode(map1_or2,       INPUT);
  pinMode(resetbutton,    INPUT);             // Added by jameshappy
  pinMode(ignition,       OUTPUT);
  pinMode(lockoutled,     OUTPUT);
  pinMode(fan,            OUTPUT);
  pinMode(solenoid,       OUTPUT);            // Added by jameshappy
  //pinMode(resetbutton,  OUTPUT);            // Commented by jameshappy
}

void loop(){                             
  if (digitalRead(ventbutton) == HIGH) {      // vent button
    digitalWrite(fan, HIGH);
  }
  else {
    digitalWrite(fan, LOW);
  }

  if (digitalRead(heatbutton) == LOW) {
    if (digitalRead(photo_pressure) == LOW) { // low gas pressure
      digitalWrite(lockoutled, HIGH);         // when heat button is LOW
      digitalWrite(solenoid, LOW);
    }
    while (digitalRead(resetbutton) == HIGH) {
      digitalWrite(lockoutled, LOW);
      return;
    }
  }

  if (digitalRead(heatbutton) == HIGH) {      // Heat button
    digitalWrite(fan, HIGH);
    delay(2500);
    if (digitalRead(saleswitch) == HIGH) {    // sale switch if HIGH
      digitalWrite(solenoid, HIGH);
    }
    else {                                    // sale switch if LOW
      // Turn on lockoutled
      digitalWrite(lockoutled, HIGH);         //at this point
      // Turn off solenoid
      digitalWrite(solenoid, LOW);
      // Turn off fan
      digitalWrite(fan, LOW);
      // Turn off lockoutled while the resetbutton is not being pressed
      while (digitalRead(resetbutton) != HIGH) {
        digitalWrite(lockoutled, LOW);
      }
      return;
    }
    delay(3000);
    if (digitalRead(photo_pressure) == LOW) { // pressure if LOW
      // Turn off solenoid
      digitalWrite(solenoid, LOW);
      // Turn off fan
      digitalWrite(fan, LOW);
      // Turn on lockoutled
      digitalWrite(lockoutled, HIGH);         // at this point
      // Turn off lockoutled while the resetbutton is not being pressed
      while (digitalRead(resetbutton) != HIGH) {     
        digitalWrite(lockoutled, LOW);
      }
    }
  }
  else {                                      // switching off
    digitalWrite(solenoid, LOW);
    delay(1000);
    digitalWrite(fan, LOW);
  }
}
« Last Edit: January 30, 2012, 04:47:01 pm by jameshappy » Logged

Reno Nevada USA
Offline Offline
Newbie
*
Karma: 0
Posts: 37
C# Developer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think this is what you need:
Code:
// Turn on lockoutled
digitalWrite(lockoutled, HIGH);

// Turn off solenoid
digitalWrite(solenoid, LOW);

// Turn off fan
digitalWrite(fan, LOW);

// Wait for opperator to clear fault
while (digitalRead(resetbutton) != HIGH) {
  delayMicroseconds(1); // Optional
}

// Turn off lockoutled
digitalWrite(lockoutled, LOW);
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help

but it's still not working lockoutled still not coming on, it work ok when hearbutton is LOW but not when HIGH
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help

but it's still not working lockoutled still not coming on, it work ok when hearbutton is LOW but not when HIGH

I suggest you edit your code and put every { and } on a separate line, with matching pairs indented by the same amount. This will make the structure of your code much easier to see.

Then point to the code which you think should turn the lockoutled on when the heatbutton is high.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have and jameshappy has to look up on the fast code by jameshappy look for (         //at this point          ) in the code and the out put dus not stay HIGH
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do your debug prints tell you? (hint)
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(hint)  there is no errors
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I said "debug", not "error".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Reno Nevada USA
Offline Offline
Newbie
*
Karma: 0
Posts: 37
C# Developer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With almost no comments it is difficult to say what you intend for your sketch to do. If this and the other commnets haven't helped you I suggest you post your intended pseudocode or use cases.

Here is my interpretation of your pseudocode:
Code:
USE CASE: Turn on fan when ventbutton is pressed
USE CASE: Turn on lockoutled when heatbutton and photo_pressure are LOW. Halt system until resetbutton is pressed
USE CASE: When heatbutton is pressed, turn on fan, sleep for 2.5 seconds, check saleswitch
    When saleswitch is HIGH, turn on solenoid
    When saleswitch is LOW, turn on lockoutled, turn off solenoid, turn off fan, halt system until resetbutton is pressed
    Sleep 3 seconds
    When photo_pressure is LOW, turn off solenoid, turn off fan, turn on lockoutled, halt system until resetbutton is pressed
USE CASE: When heatbutton is not pressed, turn off solenoid, sleep for 1 second, turn off fan

Here is a sketch to fulfill the itemized use cases:
Code:
const int heatbutton     = 2;
const int ventbutton     = 3;
const int ignition       = 4;
const int saleswitch     = 5;
const int solenoid       = 6;
const int photo_pressure = 7;
const int lockoutled     = 13;
const int resetbutton    = 9;
const int fan            = 10;
const int map1_or2       = 11;

void setup()
{
  pinMode(heatbutton,     INPUT);    
  pinMode(ventbutton,     INPUT);
  pinMode(saleswitch,     INPUT);
  pinMode(photo_pressure, INPUT);
  pinMode(map1_or2,       INPUT);
  pinMode(resetbutton,    INPUT);
  pinMode(ignition,       OUTPUT);
  pinMode(lockoutled,     OUTPUT);
  pinMode(fan,            OUTPUT);
  pinMode(solenoid,       OUTPUT);
}

void loop(){                              
  // USE CASE: Turn on fan when ventbutton is pressed
  // get ventbutton as HIGH
  if (digitalRead(ventbutton) == HIGH) {
    // Turn on fan
    digitalWrite(fan, HIGH);
  }
  else {
    // turn off fan
    digitalWrite(fan, LOW);
  }

  // USE CASE: Turn on lockoutled when heatbutton and photo_pressure are LOW. Halt system until resetbutton is pressed
  // get heatbutton as LOW
  if (digitalRead(heatbutton) == LOW) {
    bool lockoutledIsHIGH = false;
    // get photo_pressure as LOW
    if (digitalRead(photo_pressure) == LOW) {
      // Turn on lockoutled
      digitalWrite(lockoutled, HIGH);
      lockoutledIsHIGH = true;
      // Turn off solenoid
      digitalWrite(solenoid, LOW);
    }
    // allow lockoutled to remain HIGH (On) while get resetbutton as LOW (until fault is cleared by opperator)
    while (digitalRead(resetbutton) != HIGH && lockoutledIsHIGH) {
        // program is halted!
        delayMicroseconds(1); // Optional
    }
    // set lockoutled to LOW (Off)
    digitalWrite(lockoutled, LOW);
    lockoutledIsHIGH = false; // Optional (falls out of scope anyway)
  }

  // USE CASE: When heatbutton is pressed, turn on fan, sleep for 2.5 seconds, check saleswitch
  //    When saleswitch is HIGH, turn on solenoid
  //    When saleswitch is LOW, turn on lockoutled, turn off solenoid, turn off fan, halt system until resetbutton is pressed
  //    Sleep 3 seconds
  //    When photo_pressure is LOW, turn off solenoid, turn off fan, turn on lockoutled, halt system until resetbutton is pressed
  // USE CASE: When heatbutton is not pressed, turn off solenoid, sleep for 1 second, turn off fan
  if (digitalRead(heatbutton) == HIGH) {
    digitalWrite(fan, HIGH);
    delay(2500); // program is halted for 2 seconds
    if (digitalRead(saleswitch) == HIGH) {
      digitalWrite(solenoid, HIGH);
    }
    else {
      // Turn on lockoutled
      digitalWrite(lockoutled, HIGH);
      // Turn off solenoid
      digitalWrite(solenoid, LOW);
      // Turn off fan
      digitalWrite(fan, LOW);
      // Turn off lockoutled while the resetbutton is not being pressed
      while (digitalRead(resetbutton) != HIGH) {
         // program is halted!
        delayMicroseconds(1); // Optional
      }
      digitalWrite(lockoutled, LOW);
    }
    delay(3000);  // program is halted for 3 seconds
    if (digitalRead(photo_pressure) == LOW) {
      // Turn off solenoid
      digitalWrite(solenoid, LOW);
      // Turn off fan
      digitalWrite(fan, LOW);
      // Turn on lockoutled
      digitalWrite(lockoutled, HIGH);
      // Turn off lockoutled while the resetbutton is not being pressed
      while (digitalRead(resetbutton) != HIGH) {      
        // program is halted!
        delayMicroseconds(1); // Optional
      }
      digitalWrite(lockoutled, LOW);
    }
  }
  else {
    // Turn off solenoid
    digitalWrite(solenoid, LOW);
    delay(1000);  // program is halted for 1 second
    // Turn off fan
    digitalWrite(fan, LOW);
  }
}
« Last Edit: January 31, 2012, 06:55:35 pm by jameshappy » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what i would like it to do is
when swich is one way :
read vent button is high tun fan high
when swich is off:
read heat button low read photo_pressure if low lockoutled go's high solenid go's low then wate for resebutton to go high then lockoutled go's low then return to the stert
when swich is the other way:
read heatbutton high, then fan go's high delay for 2.5s then if saleswitch is high solenoid go's high
but if saleswitch is low the;
lockoutled go's high solenoid go's low and fan go's low and then wate for rese button go's high then lockoutled go's low then return to the stert

delay 3s

if photo-pressure is low
lockoutled go's high solenoid go's low fan go's low what for resebutton to go high then lockoutled go's low then return to the stert
think when heatbutton go's low solenoid low delay for 1s then fan go's low
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what i would like it to do is
when swich is one way :
read vent button is high tun fan high
when swich is off:
read heat button low read photo_pressure if low lockoutled go's high solenid go's low then wate for resebutton to go high then lockoutled go's low then return to the stert
when swich is the other way:
read heatbutton high, then fan go's high delay for 2.5s then if saleswitch is high solenoid go's high
but if saleswitch is low the;
lockoutled go's high solenoid go's low and fan go's low and then wate for rese button go's high then lockoutled go's low then return to the stert

delay 3s

if photo-pressure is low
lockoutled go's high solenoid go's low fan go's low what for resebutton to go high then lockoutled go's low then return to the stert
think when heatbutton go's low solenoid low delay for 1s then fan go's low

I know that means something to you, but it reads like complete gibberish to me.

There are several conventional ways to describe this sort of thing, but one which I think might help here is called 'pseudocode'. It's a stylised form of English, laid out in a block structure similar to 'C', which describes what you intend the code to do. It's often helpful to lay your basic logic out like this before you get stuck into code.

Code:
if switch is in position A then
    if vent button is high then
        turn fan high
    endif
else if switch is in position B then
    if heat button is low then
        if photo_pressure is low then
            lockoutled goes high
            solenoid goes low
            wait for reset button to go high
            lockoutled goes low
etc

Can you describe what you want it to do either in terms of jameshappy's use cases, or pseudocode?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 309
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the one jameshappy did at the top of this page work fine just like the one i did be for i asked for the help, but the lockoutled should come on where it go's high but it does not come on

when the heatbutton is low it will come on when it should
but when heatbutton id high it will not?
Logged

Pages: 1 [2]   Go Up
Jump to: