Pages: 1 2 3 [4]   Go Down
Author Topic: Last stage debugging - Help !![SolveD]  (Read 3340 times)
0 Members and 1 Guest are viewing this topic.
Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello . .

Find attached code still titled under Rev 5 (Updated Version) smiley

All is well, except for the "Pump time off" .. .. as explained above in regards to control behavior of pump.

Thanks . .

taz ..

* GreenHouse_Rev_F_05.ino (11.34 KB - downloaded 14 times.)
Logged


tz
.....

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Minor but you can remove some some code in that -

'lcd.begin' performs a ''lcd.clear''
'lcd.clear' sets the cursor position to 0, 0
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks to me as though you should set lastPump to millis() when you turn the pump on, not adjust it when you're turning it off.
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Minor but you can remove some some code in that -

'lcd.begin' performs a ''lcd.clear''
'lcd.clear' sets the cursor position to 0, 0


Will remove some codes as explained above...

Quote from: wildbill
It looks to me as though you should set lastPump to millis() when you turn the pump on, not adjust it when you're turning it off.

As if i can see that working .. smiley, anyway i shall test it in the afternoon and update the post here.

Thanks

Regards

Taz ..
Logged


tz
.....

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I did try the change in updating lastPump to millis, when my  pump is set to on, here also its not working as it should.

changes brought to code:

Code:

void pumpControlON (){
  if ( percentage_Moist <= 85.00 ){
    digitalWrite(pump_Active,HIGH);
    pump_Status = true;
    lastPump = millis();
  }
}


void pumpControlOFF (){
  if (( millis() - lastPump >= timerRateX ) || (percentage_Moist >= 90.00)){
    //lastPump += timerRateX;
    digitalWrite(pump_Active,LOW); 
    pump_Status = false;
  }
}

The thing i observed is before adding up the conditional function as displaying active and inactive onto the lcd. It did work very well, that is pump run for 7 secs and goes off, if moist percentage still under 85%, it runs again. Since my probe was kept in the air, my led would flashed off after a duration of 7 sec.

May be there are too much things going on in parallel, like displaying percent moist, displaying if pump is active or inactive and checking if threshold value is reached.

Any suggestion ?
Logged


tz
.....

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post the latest complete with changes as they are hard to visualize ...
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code attached with not much changes, only this part of lastPump = millis(), trying to remove the small bug, concerning my pump not getting off after a delay.


* GreenHouse_Rev_F_06.ino (11.37 KB - downloaded 16 times.)
Logged


tz
.....

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sure that it has been mentioned that adding time variables is not a good thing.

Why is the lastPump = millis() line commented out in pumpControlON()? That is where you should be record when the pump was turned on. Recording some time in the future in pumpControlOFF() is just plain wrong.

Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I added the code lastPump = milli(); in the pumpControlON() while first commenting the line //lastPump += timerRateX;, to test if things changed, but unfortunately it remained the same..

So i commented it out, to return my code to original to see if there was any contrast between the change.

No change in behavior detected, but the thing which keeps tickling me,is how come it worked before I added the timer for the LCD, i did try to remove the timer for LCD to see if it works, but to no avail . . .
Logged


tz
.....

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd suggest then, that you put your pump control code into a much simpler sketch to test it in isolation. If that doesn't solve it, it may help to take the moisture sensor out of the equation too and simulate it, using the serial port for instance.

Edit: Before resorting to serial, just using a pot to get a simulated moisture reading might help.
« Last Edit: March 15, 2013, 06:13:01 am by wildbill » Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

It seems i undertood the philosophy behind the pump control, and why it was not working, and how it did work as present.   smiley-grin

The thing i observed is before adding up the conditional function as displaying active and inactive onto the lcd. It did work very well, that is pump run for 7 secs and goes off, if moist percentage still under 85%, it runs again. Since my probe was kept in the air, my led would flashed off after a duration of 7 sec.

Today i did observed the real scenario taking place, as such, my Soil percentage value on lcd displayed around 83 %, with my led for pump lighted on, part of code concerned :

Code:
void pumpControlON (){
  if ( percentage_Moist <= 85.00 ){
    digitalWrite(pump_Active,HIGH);
    pump_Status = true;
      }
}

void pumpControlOFF (){
  if (( millis() - lastPump >= timerRateX ) || (percentage_Moist >= 90.00)){
    lastPump += timerRateX;
    digitalWrite(pump_Active,LOW); 
    pump_Status = false;
  }
}

Here is the control philosophy: If percentage moisture is < 85%, my pump is set to ON, and my timer start counting until 7 secs, if after this time duration, my percentage moisture is > 85% (we should not get confused here with the upper threshold of moisture percentage 90% set), my pump would go off after the counted millis algorithm reached its 7 secs.

Remember i did underline that pump did go off, with the led flashing off, before adding,conditional function for displaying active and inactive onto the lcd, as reference to the above quote, i was wrong in pointing out the culprit smiley. At that time i was still running under code GreenHouse_Rev_F_04, where i noted that my serial port was still opened and running all my Serial commands.. These Serial.commands; explained why my led will flashed off after the 7 secs even when moisture percentage was showing 0 %, while my probe was in the air.

As far as i did understood the cycle of the code, with the serial command lines running, the Uno(slowed) would have time to process the 7 secs millis algorithm, until it updated its percentage moisture.
With program running under code GreenHouse_Rev_F_05, where the serial port communication is disabled, the Uno response time increased, the moisture percentage reading get updated before 7 secs millis algorithm is processed, and since % is reading < 85%, there will be no led flashed off, NO Pump Off . .   smiley-cool  as mentioned above in the control philosophy.

I did observed this whole situation, with the real scenario occuring today, where my soil moisture percentage was displayed with the value in the range of 83 to 87 % , this time i was not simulating dry soil in placing the probe in the air.

Quote from: wildbill
Edit: Before resorting to serial, just using a pot to get a simulated moisture reading might help.
we were close . . .   smiley-wink

Any suggestions, views and analysis are welcomed towards the observation made to confirm if i did understood it correctly.

Thanks

taz . . .
Logged


tz
.....

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

Would like to thanks all of you who brought me much help in understanding and debugging my codes.

I did put it under observation for almost 1 week and found it working as expected. moving  towards circuit building now.

Thanks again for your time.

Regards

Tazlim.
« Last Edit: March 20, 2013, 05:18:10 am by taz3m » Logged


tz
.....

Pages: 1 2 3 [4]   Go Up
Jump to: