Go Down

Topic: any ideas? (Read 2099 times) previous topic - next topic

Joes

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

AWOL

#16
Jan 30, 2012, 09:13 pm Last Edit: Jan 30, 2012, 09:57 pm by AWOL Reason: 1
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.
"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.

Joes

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

this is seding me around the bend now lol

jameshappy

#18
Jan 30, 2012, 10:41 pm Last Edit: Jan 30, 2012, 10:47 pm by jameshappy Reason: 1
Code: [Select]
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);
  }
}

jameshappy

I think this is what you need:
Code: [Select]
// 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);

Joes

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

PeterH


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.
I only provide help via the forum - please do not contact me for private consultancy.

Joes

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

AWOL

What do your debug prints tell you? (hint)
"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.

Joes

(hint)  there is no errors

AWOL

I said "debug", not "error".
"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.

jameshappy

#26
Feb 01, 2012, 12:50 am Last Edit: Feb 01, 2012, 12:55 am by jameshappy Reason: 1
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: [Select]
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: [Select]
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);
 }
}

Joes

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

PeterH


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: [Select]

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?
I only provide help via the forum - please do not contact me for private consultancy.

Joes

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?

Go Up