Author Topic: Chest fridge control with a UNO  (Read 11332 times)

0 Members and 1 Guest are viewing this topic.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Chest fridge control with a UNO
« on: August 08, 2012, 10:29:16 PM »
Finally got around to building a new fridge control using the UNO.  The previous analog control operated as a timed dump load when the battery reached a certain voltage.  The battery charge voltage would be boosted  when fridge temp raised.  It worked fine for years till I added a lot more panels for cloudy weather.  It would trip up sometimes on very sunny days when a lot of warm beverages were added.  The old system did not have ant way to prevent a hot start.

As you can see it was made using the "science fair" construction method using a wood panel and hot melt glue.  I love a grinder with a thin cutoff wheel.  All parts are scavanged from the dump and the UNO was a China knock off under $16 shipped.  The second photo shows a three relay board I cut away from an ols UPS.  The blue box above is the previous control that contains a LM341 voltage detect and 15 minute timer.  The 2000/4000W HF inverter at the bottom is dedicated to the fridge.  I miss getting these broken ones shipped to me for about $20. People have caught on and they now sell for over $60.  I hope this demonstrates that anyone can use these boards.

I wrote this program about 3 months ago, mostly around 3am on those nights I couldn't sleep.  So I was expecting some strange things when I first tried it.  These may be useful to remember if you try using one.

First try the fridge relay turned on and stayed on.  In software you must declare a pin as an output or an input.  If you don't the pin can still be forced high.  However when you turn it off that pin just floats.  There was enough gate capacitance in the fet to keep it turned on till I touched the gate with a meter probe.  This trick may prove useful some day.

Not wanting to add any more parts than I have to, I didn't add any resistors to pull down the gate of the FETs.  Durring RESET and program loads, the fridge relay would come on and off for a second causing a hot start and tripping the fridge motor thermal protector.  Gate drain resistors of 300K solved that.

Temperature sensing was from 5 or 6 small signal diodes in series that gave about 3.8 volts.  The UNO is 4.9mV per bit and several diodes in series gives a good change. I also add ten samples together which is like having an extra bit.   I calibrated this and it tracked well with my laptop connected.  When the laptop was disconnected the fridge turn on temp was much higher.  When the programming cable was connected, the UNO was powered by a 5V sypply that was 70mV higher and the UNO A/D used that higher reference.  I sliced into the USB cable and cut the 5V wire.  For a little protection I spliced in a pair of back to back diodes on that 5V line. 

The basic program functions like this:
1. senses battery voltage and turns fridge on for 15 minutes if temp is above 36
2. if temp still above 36 and battery above run voltage continue another 5 minutes
3. keep repeating above if conditions are the same
4. if either conditions fail, inhibit restart for 12 minutes to let compressor bleed down
5. Look for manual start button that allows for much lower start voltage
6. on board LED flashes once every 6 seconds to indicate program is running. Additional flashes are for ever degree over set temp.

I will probably add an automatic lower voltage start if the temp reaches 40F.  In addition this also runs a pump periodically and controlls another 15A of panels right now.   About 20% of the program is running.  Not connected yet are two power point PWM regulators 24 & 48V and a water heater PWM inverter.  It's funny I couldn't find the fridge program on the laptop when I got to camp.  I forgot it was a minor part of the waterheater program.   I hate batteries and only use a car battery to provide the 90A surge for starting the fridge.  I have 800W of power that is currently not used most of the day.  That is enough to heat water and I have a nice 10 gallon unit I will soon be connecting.

I have a relay coil connected to a set of solar panels.  When the sun has come up enough in the morning the contacts close and the micro is powered.  Sun goes down and the micro is off for the night.  I had it powered all the time and the first night it drove me nuts as it really lit things up in the house.  I got up that night and pulled the power wire out.  The relay was added the next day.
« Last Edit: August 08, 2012, 10:37:11 PM by OperaHouse »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #1 on: August 16, 2012, 03:28:29 PM »
Over a week and everything is running fine.  Here is some information on the charge controller section.  This pair of FET were cut out of an old UPS.  The design is a little unusual because it uses a battery to provide the power to drive the high side FET.  I get nice lithium batteries from our town recycling area so I have more batteries than I can use.  The 14V that powers this was an odd non rechargable battery.  Since the circuit draws next to nothing the battery will last its shelf life.  I have had this one connected to this for years and it is still at full voltage.  This little piece of UPS real estate contained the two FET, a 100K resistor, and an opto isolator.  Just needed to provide some connections.  15A and this doesn't even warm up.

The code is very simple.  Just choose a voltage to turn on and a voltage.  The speed at which it is allowed to change is controlled by blinktime.  This is program loop counter and 250 counts is about 8 seconds at which time it resets to zero.  A change can happen about every two seconds. Battery voltage is in mv.  The LED in seriesw with the output gives me an indicator of when the battery is fully charged.

    if ( blinktime == 40  && battery < 14150) digitalWrite (8,HIGH);
    if ( blinktime == 80  && battery > 14350) digitalWrite (8,LOW);

On the system I have two Morningstar SL-10 controllers and this controller operates the extra 15A of panels.  This morning at 10am with a couple of fridge cycles I was reading a total charge current of 26A.  Quite good condidering the sun was 90 degrees off axis of the panels. I hate batteries and the system is designed to run of a single car battery from my truck that I dont bring with me.  OK, and there is a boat battery I leave on it to keep it charged when not boating.  Right now it has four identical make and model batteries on it.  Last year I left one battery home and had to buy another.  That left one very sulfated uncharged for 5 months battery.  Then my wife's car went dead on two occasions so there is another battery.  Add in a winter and now I don't know which is which.  I do have a HF battery load tester I got for $3 at a garage sale.  With some added wires that is now used to monitor the battery bank.  Seems like too much work to sort out the good ones and it is hard to read that meter.   I added a couple of lines of code to the UNO this morning to measure the lowest recorded voltage. This voltage slump test has a seperate diagnostic screen which is displayed on a laptop.  The inverter normally drawa about 90A for six seconds when the fridge turns on.  Could be even higher for a short period.  That is more than the HF unit is good for.  The battery bank is set up so batteries can be isolated.  Just test the batteries one at a time.   This morning I did a test of the entire bank at 9am when it hadn't fully recharged.   Low voltage was 10.842V  and running was 12.532V.   This voltage is the actual voltage internal to the inverter and includes lead losses.  When it is fully charged some afternoon I will test each battery seperately.
   
« Last Edit: August 16, 2012, 04:26:56 PM by OperaHouse »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #2 on: August 19, 2012, 01:58:09 PM »
Yes, every logic step is done with an IF statement.  You should try to do everything as a single line statement.  DO NOT NEST if statements inside of if statements.  NEVER use DO or FOR loops.  This will insure your code does not turn into spagetti.  Here is the main function of the fridge program:

 // AUTOMATIC OPERATION    note:  // designates the start of a comment
  if (battery > 13200 && TEMP >= 35 && inhibit == 0 && endcool < minutes)                 
 // battery full, temperature high  enough,  not hot start, not already running
  {
    endcool = minutes + 15;         // set cooler to end 15 minutes from the present time
  }

This is simple enough to understand.  If all these conditions are met then the statement between the brackets is implemented.  Note that this code do does not turn on the fridge relay.   The program has a minutes counter that totals up the number of minutes the micro has been on. The variable endcool is the time in the future the fridge is scheduled to turn off.  Standard run time is 15 minutes.

The next logical statement  looks at temperature and the battery under load which will always have a lower voltage.

  // EXTEND NOMINAL TIME
  if (battery > 12700 && TEMP >= 35 && inhibit ==0 && endcool - minutes == 2)             
 // IF battery has sufficient charge and not cool enough and 2 minutes from shutoff
 // then extend cooler end time 3 by minutes
  {                                                                                 
    endcool = endcool + 5;            // 5 - 2 = 3 more minutes
  }

There id no limit to the number of extensions as long as battery voltage is sufficient and it is not cold enough.  This allows the fridge to keep running when a lot of soft drinks are added and there is full sun to power the fridge.

Finally, the actual turn ON or OFF is performed by this statement.  If the minutes hasn't reached the scheduled turn of time turn the relay ON.  This will actually happen hundreds of times.  The micro doesn't care.  When a port is turned on it will stay on as a latch till you turn it off.  In this simple case an ELSE is appropriate.

  //   This is the ACTUAL TURN ON or OFF based on previous logical operators
  if (endcool > 0 && endcool >= minutes)        // should cooler be on or off
  {
    digitalWrite(4, HIGH);           // CLOSE fridge relay
  }
  else
  {
    digitalWrite(4, LOW);           // OPEN fridge relay
  }

Starting the fridge within a couple of minutes of turn off is a hot start.  If the freon has lot blead down completely the motor will go into overload and bimetalic breaker on the motor will trip.A smaller inverter may go into overload and trip off forcing a manual reset.  To prevent this a restart is prevented by INHIBIT for a number of minutes.  This happens at one minute from turn off.  Bet you were wondering why the extended time happened at 2 minutes.  If the time wasn't extended at two minutes, at one minute we know that the fridge will  be turning OFF.
 
// This section inhibits refrigerator from hot restart at the end of the cycle by an inhibit timer

  if (endcool - minutes == 1)  inhibit = 12; 
                                       
// if cooler is about to turn off, prevent restart for 12 minutes
// In the last minute of running always set the inhibit timer

  if (minutes != lastime && inhibit > 0  &&  endcool < minutes)                       
 // This section checks to see if another minute has elapsed and updates INHIBIT
  {                     
    inhibit = inhibit - 1;            // decrement the inhinit time counter then
    lastime = minutes;            // Update last time marker
  }
« Last Edit: August 19, 2012, 02:21:16 PM by OperaHouse »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #3 on: August 21, 2012, 02:51:24 PM »
The analog signals are fairly easy. The temperature is produced by reading the forward voltage on a string of silicon diodes fed from +5V through a 2200 ohm resistor into analog pin AI4.  A running sample is made by subtracting 1/10th of the total and then adding the next sample.  This basically gives ten times the analog reading.  This gives a decent size number to work with and averqages out the noise.  Every signal has noise and this uses it to an advantage by giving almost an extra digit of resolution.


// Read the temperature, crfeate a sample of 10 and convert to degrees F                     
    Ctemp  = Ctemp - Ctemp / 10;                                                       
 // Sum the readings by subtracting one average reading before conversion tF
    Ctemp  = Ctemp + AI4;                                                               
 // Add latest A/D reading.  This gives ten samples added together.

Any type sensor may be used like a thermisistor.  The conversion is very easy using the MAP function.  Through a diagnostic debug screen, just get the reading at room temperature (82deg with 7090 count) and in an ice bath (32deg with 7930 count).  The linear interpolation mapping actually extends beyond those two points.  Now you have a temperature in understandable terms.  Note how this works even though increasing temperatur creates a decreasing voltage.
 
  TEMP = map(Ctemp, 7090, 7930, 82, 32);                                                   
// For five small signal diodes with 2.2K pullup to +5V
 
Battery voltage works in much the same way.  A voltage divider  of 300K from the battery with a 10K pot in series is tapped with a 87K resistor.  This gives about 25mv per count for a 4:1 divider.  A . 22uF capacitor at the input pin adds a little filtering and gives a stable reading.  The multiplyinjg effect creates a number that approximates the battery voltage.  Adjusting the pot finishes the calibration.  Make sure in normal operation that the voltahe at the analog pin does not exceed 2.5V for safe operation when monitoring other voltages.

  battery = battery - battery / 26;                   
 // Sum the readings by subtracting one average reading   

  battery = battery + AI0;                              // Add latest A/D reading

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #4 on: August 23, 2012, 04:05:34 PM »
Timing is everything.  It takes time to go through all the logical operqations.  I count the number of times the program cycles through all the steps.  That count is called BLINKTIME.  Once it reaches 245 the count is reset and cycletime is incremented

   blinktime = blinktime + 1;                 // increment blink counter
   if (blinktime  > 245)                         // 300 ish is about 10 seconds
  {                                                                         
    blinktime = 0;                                // Reset counter
    cycletime = cycletime + 1;             // count the nimber of mini cycles
  }

Every program will take a different amout of time.  This has to be determined by experiment.  I use blinktime to time the periods an LED is on or off as a diagnostic.  It also is used to create minute marker CYCLETIME.  Once cycletime reaches 7 that counter is reset and the minute is incremented.

  if (cycletime  > 7)                            // about 1 minute                           
 
  {                                                                         
    cycletime = 0;                               // Reset batch second counter
    minutes = minutes + 1;                 // increment minute counter

The following is how I use BLINKTIME to flash the on board LED.  It always flashes once every eight seconds just to show the program is running.  Additional flashes indicate how many degrees the fridge is over the preset temperature.

 //  LED INDICATOR
 
  if (blinktime == 1)  digitalWrite (13, LOW);                 // indicator LED OFF   START
 
  if (blinktime == 15) digitalWrite (13, HIGH);               // ONE BLINK INDICATE PGM RUNNING
  if (blinktime == 30) digitalWrite (13, LOW);                // indicator LED OFF
 
  if (blinktime == 45 && TEMP >35) digitalWrite( 13, HIGH);       // TWO BLINK >35 FRIDGE SHOULD BE ON
  if (blinktime == 60) digitalWrite (13, LOW);                          // indicator LED OFF
 
  if (blinktime == 75 && TEMP> 36) digitalWrite (13, HIGH);       //  THREE BLINK > 36
  if (blinktime == 90) digitalWrite (13, LOW);                          // indicator LED OFF
 
  if (blinktime == 105 && TEMP > 37) digitalWrite (13, HIGH);     //  FOUR BLINK > 37
  if (blinktime == 120) digitalWrite (13, LOW);                         // indicator LED OFF
 
A little clunky but straightforward
 
 
« Last Edit: August 23, 2012, 04:36:33 PM by OperaHouse »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #5 on: August 25, 2012, 12:17:49 PM »
When building a program, start with small sections of code like a counter to time and a diagnostic screen.  This will allow you to see if sections of code are working as expected.  The following code prints out all the parameters of the fridge.  Printing uses the 9600 baud serial port.  This data is read and displayed in the TOOLS section of the Arduino compiler.  It also performs another function, time delay.  Sending out all that data serially at slow speed slows the program down a bit so that loop numbers aren't that large.

//                                              REFRIGERATOR DIAGNOSTIC SCREEN
    Serial.print(TEMP);                                            // fridge/cooler temp in degrees F
    Serial.print('\t');                                               // tab to next column

    Serial.print(battery);                                         // battery voltage
    Serial.print('\t');                                               // tab to next column

    Serial.print(cooltime);                                        // Minutes the refrigerator has been on that day     
    Serial.print('\t');                                                // tab to next column

    Serial.print(endcool);                                          // Time when the refrigerator will turn off
    Serial.print('\t');                                                 // tab to next column

    Serial.print(minutes);                                           // debug value  Time computer is up and running
    Serial.print('\t');                                                 // tab to next column

    Serial.print(inhibit);                                             // countdown to prevent hot start of compressor
    Serial.print('\t');                                                 // tab to next column

    // NOTE: printlin is used this time instead of print.   println adds a new line character
    //automatically after the data string so the next set of data is on a new line.  The
    // Auto Scroll box in the SERIAL MONITOR tool can be unchecked to freeze the screen.

    Serial.println (Ctemp);                                         // A/D reading times 10

This screen shows from left to right the calculated temp, battery, total time of fridge operation, end time minutes, current minute time,  inhibit minutes left, and the A/D readings used to calculate temperature.  Taken at one minute before shutoff, the 12 indicates the inhibit counter has beem loaded with 12 preventing restart for 12 minutes..
 

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #6 on: August 26, 2012, 02:53:38 PM »
Steadfast in another post was trying to cool some chickens on hot days and was looking for a low voltage drop out relay.  This was further complicated by having an inverter with a surface keypad with a momentary turn on/off instead of a slide switch. Keeping a battery from going below a suitable discharge level is anot a simple thing.  Just starting a motor may drop the voltage momentarily below the desired setpoint, so a delay is needed.  Starting a fan early in the morning  wastes battery power befor it is needed  at the hottest time of the day.  And guessing what the weather is going to be like may leave you with dead chickens It is interesting that the chest fridge program is identical to what is needed.  Just set points need to be changed.

We may not all have chicken, but we all have excess power that goes to waste at certain times of the day.  A smart control can look to see when a battery is fully charged and vent the attic or pump some water.  Think of a water tank with three level switches...full, low and desperate.  Maybe you can skip a couple days and wait till you hit the desperate level.  Skip timed plant irrigation or cause extra watering on very hot days.  If you can write down the thought process involved in looking at the voltmeter, temperature, level, or whatever, you can create a program.   These controllers have matured enough that they can now be used by the general public.  I remember when you had to buy a development systema, prom burners and the environment was downright unfriendly except to the technically minded.  With the FREE development systems you can actually try programming at no cost.  Frankly, just downloading the software is about 70% of the work.  These development systems are like your wife.... Always right and you can't argue with them.  Just go away for a day and it will finally dawn on you why you were wrong.

Some inverters like Steafast's will hae a momentary pushbutton.  This section of code uses DELAY to create a 1/4 second pulse to simulate a pushbutton.   It uses BLINKTIME to insure that a change occurs no more often than every 4 seconds allowing inverter output indicator to be stable.  The remote LED is replaced with an opto isolator (or relay on the 120AC) and is read by the micro at an input pin.  This insures the system doesn't get lost in sequence.  It can only be turned off when it is on and it can only be turned on when off.


// Code section if inverter has momemtary push button
 
  if (endcool > 0 && endcool >= minutes && digitalRead (5) == LOW && blinktime == 10)    //  To turn fridge on               
  {
   digitalWrite(4, HIGH);                      // CLOSE fridge relay
   delay (250)                                   // for 200ms then
   digitalWrite(4, LOW);                      // OPEN fridge relay   
  }

  if (endcool > 0 && endcool < minutes && digitalRead (5) == HIGH && blinktime == 150)   // To turn fridge off
 {   
  digitalWrite(4, HIGH);                        // CLOSE fridge relay
   delay (200)                                    // for 200ms then
   digitalWrite(4, LOW);                       // OPEN fridge relay   
  }

Bruce S

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 5374
  • Country: us
  • USA
Re: Chest fridge control with a UNO
« Reply #7 on: August 27, 2012, 04:00:21 PM »
OperHouse;
Thanks for the clarification.
I have a hydroponics system that uses a membrane style push button switch, this will help.
I can then make use of an if/then statement which will allow me to turn on lights or keep them off during low battery situations.
OR during those extra power days circulate the feed/water/air pump a little more often.
Thanks!
Bruce 
A kind word often goes unsaid BUT never goes unheard

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #8 on: August 28, 2012, 04:34:54 PM »
I used to germinate plants with ultrasonics.  Those were interesting results.  The fridge program also randomly operates a pump.  Six times a day it checks to see if the voltage is over 13.9V and then it operates. Some days it may be six and others one.   I have been doing it randomly for years when I walk by the basement.  So far it is doing a better jub than I was.

Just ordered another China UNO for just over $15 without the printer cable.  Most everyone has a drawer of these.  At home I have an electronic load and a calculating power meter. With those two, just turn a pot and you can easily get max power.  I want to build an interface for camp to connect any 6-24V panel and have it check for max power point and at standard voltages.  I have a couple of Photowatt panels that are going bad.  Right now I only use half of each panel in series.  You know what that 25 year guarantee is worth.  So I need to start testing all of my panels each year to catch these failures earlier. 

Here is the schematic to the basic setup.  Power comes in through an inductor.  I used a common mode choke found in most electronics.  The dual windings are placed in series by doing a diagonal connection.  That will filter out any nasty spikes.  Then just about any capacitor to common.  Initially I had four diodes in series.  One provides reverse voltage protection and the others provided a known voltage drop.  When I later increased the value of the resistor I dropped the value to two.  As it is now I have about 10.5V going to the micro.  This is to keep the onboard regulator nice and cool.  If you are going to be powering outside devices like 5V relays it would be better to give them their own regulator.  I cut FETs out of circuit boards for drivers and use about any resisroe to isolate them and limit current just in case they short or you touch them to power.  Most fets can easily drive a couple amps at just under 5V gate drive.   I have used opto-22 devices like ODC5 with these and they can be found on ebay for only 80 cents each at times.  I have just soldered to the pins.  The modules may be cheap but a board to mount four of them will cost over $20.  Careful,  There are two standard pin spacings.  For 120V AC use they are a pretty good way to go.  One drawback is most of the mounting boards have a common +5V buss so you have to ues LOW LOGIC for output devices.   

The temp sensor is a string of small signal diodes.  I give these a light coating of hot melt glue.  When it cools I stick it into some heat shrink tubing.  When you shrink the tubing with heat it all seals together to form a watertight assembly.  I havent seen the need to use shielded cable.  At the micro I use an inductor to filter out any RF noise with a capacitor to ground.
 

thirteen

  • Hero Member
  • *****
  • Posts: 980
  • Country: us
  • Single going totally off grid 1,1, 2013
Re: Chest fridge control with a UNO
« Reply #9 on: August 29, 2012, 02:45:40 AM »
It seems to me that for people living off grid we are relaying on more and more electronic equipement to run our off grid places. Maybe it just seems like it to me. I admit things do help and offer better control over our systems. I've seen to many items burn up and stop everyting. If you are close to a place for repair parts that is ok. For me there is about 3 months you have a tough time just getting out for help let alone finding the right parts. I am just wondering what people carry for spare parts back in the sticks.
MntMnROY 13

Bruce S

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 5374
  • Country: us
  • USA
Re: Chest fridge control with a UNO
« Reply #10 on: August 29, 2012, 10:23:16 AM »
13;
While I am not off-grid, I do like to think one day I will be  ;).
So in my stash of stuff , when I see old TVs , I pilfer out, chips, diodes, ceramic resistors and wire.
 I don't get too selective about about what I'm pulling, I go after the big diodes and large ceramic resistors and switches. With Diodes, switches and resistors I can then mimic a computer.
Relays are good too, but switches I can be certain of.
We always need wire  8)
Hope that helps.
Bruce S
A kind word often goes unsaid BUT never goes unheard

thirteen

  • Hero Member
  • *****
  • Posts: 980
  • Country: us
  • Single going totally off grid 1,1, 2013
Re: Chest fridge control with a UNO
« Reply #11 on: August 29, 2012, 02:19:23 PM »
I AM JUST CONCERNED ABOUT GETTING PARTS IF NEEDED DURING THE WINTER I WILL BE GOING OFF GRID NEXT SPRING OR MAYBE IN JANUARY  I WILL BE PUTTING IN A SOLAR SYSTEM IN NEXT SPRING/SUMMER  IF MY MONEY WORKS OUT I'LL GO IN JANUARY BUT I'LL HAVE TO SNOWSHOE IN FOR ABOUT 6 MILES  (54 MILES TO TOWN).  I KNOW I WILL BE GETTING TWO SOLAR PANELS THIS YEAR WE'LL SEE IF I CAN GET THEM IN BY NOV. THE SNOWSHOEING WOULD DO MY OLD FAT BODY GOOD OR KILL ME OFF. FOOD AND MATCHES ARE UP THERE JUST WAITING FOR ME.
MntMnROY 13

Bruce S

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 5374
  • Country: us
  • USA
Re: Chest fridge control with a UNO
« Reply #12 on: August 29, 2012, 02:31:17 PM »
Not to be mean, but did someone forget to turn off the Caps lock button ;).
A kind word often goes unsaid BUT never goes unheard

thirteen

  • Hero Member
  • *****
  • Posts: 980
  • Country: us
  • Single going totally off grid 1,1, 2013
Re: Chest fridge control with a UNO
« Reply #13 on: August 29, 2012, 08:01:28 PM »
Yes.  I started that way and desided to leave it.
MntMnROY 13

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #14 on: August 30, 2012, 03:17:11 PM »
Wel,l isn't tht the way with everything.  My sister lives on Nantucket and she went in to have new rear brakes installed.  They gave her a quote of $4100 on a 6 year old vehicle.  I remember when I got my pickup truck.  Brake pads were going to be $32, I was livid.  Hadn't paid more than $18 before that.  Beyond availability, there is becoming this technical divide.  When I am at home I have a lot of access to new electronics.  At camp I scavange things from the town dump.  Can't beat an old UPS for parts.  I am trying to show that you don't have to spend a lot of money to have cutting edge technology.  I would never have a micro system without a couple spare processor boards.  $15 is cheap for a spare.  When all else fails, substitution is good diagnostic and 5 years from now tht great board won't be available.

Nack to programming.  Math requires a little attention.  2 + 2 = 4, but 20,000 + 20,000 won't necessarily be 40,000.  In most cases it will be a negative number.  There are ways to do larger numbers.  Just do some quick math and avoid situations  where numbers go beyond 32K.  Interger division can be another problem.  The remainder is truncated so 100 divided by 51 = 1.  Using larger sample sizes will give acceptable results.   I love copy and paste but it can often waste more time than it saves.  It is easy to forget to change a variable name in a line of code.  Then when the code fails to work it takes forever to find the problem.  That variable looks so familiar you look at it a hundred times and it swtill looks right.  I had a section of tested code I knew worked.  some time later it didn't.   I had coppied a section of code and instead of copy and paste I must have clicked cut.   The compiler is pretty good about finding code errors and it will highlight a line.  If you don't see the problem in that line, look at the one just before.  When doing logic statements...... if ( X = 30) is not the same as ... if (X==30).  The first will always be considered TRUE.  Only the second with == is a logical statement.  The first code will compile and you will look at that line a long time before you figure it out.

I have told you how nice it is to have a debug screen when writing a program and it would sure be nice to just plug in the laptop and get run data at the end of the day.  In the troubleshooting anouncments there was a mention that Mac and UNIX users would find that connecting the USB cable would reset the UNO and all data would be lost.  It appears this is the same for Windows 7.   I wanted to get the daily running total so I used one of the six available PWM outputs.  Connecting the output through a 22K ohm resistor to a 1uF capacitor will allow an intergrated voltage to be read corresponding to run time.  Cooltime was used as the variable for the PWM.   Since I never expected cooltime to be over 255 no conversion was necessary.

The following is an example of how to output temperature.  It is desired for the nominal temperature of 0 to 47 degrees to be read by a digital voltmeter.   The maximum output of the PWM is about 4.7 volts which woule correspond to 47 degrees.  MAP is used to convert the numbers.  47 is converted to 255, the maximum number the PWM can take.  The IF statement limits the maximum number the PWM will see.  It is prefered you use the constrain statement instead.


 //  Convert cooltime to an analog PWM signal at pin 5 so it can be reas by an external meter
 
 meter = map (TEMP, 0, 47, 0, 255);               // convert 0-47 to 0-255   Values can extend beyond those limits
 
 if (meter > 255)  meter = 255;                      // limit the upper end of meter to 255 max PWM can take
                                                               //  OR a better way is to use constrain to limit upper and lower 
 meter = constrain(meter, 0, 255);                 // limits range of sensor values to between 0 and 250
 
 analogWrite(11, meter);                               // analogWrite values from 0 to 255

An analog meter can be used instead.  Just use a meter of 1ma or less and select an appropriate resistor that would cause a full scale reading  if connected to 5V.
 

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #15 on: October 15, 2012, 02:44:12 PM »
It's time to close up the camp now that the weather has changed.  A couple of days ago we woke up to 44 degrees inside the house.  Not much of a need for refrigeraation at those temps.  With the shorter days the system now shuts down about 6pm.  Diverting excess power to the solar shower worked for four days then ten days of miserable weather set in with clouds, rain, fog, drizzle and not a sight of the sun.  The system was at the bare edge of working.   I had to insert this line of crisis code to run the fridge if it hit 39 degrees even if the batteries were depleted.

// AUTOMATIC OPERATION WITH HIGH TEMPERATURE
  if (battery > 12700 && FC >= 39 && inhibit == 0 && endcool < minutes)                 
 // Force fridge on at higher temps with lower battery requirments
    {
    endcool = minutes + 12;           // set cooler to end 12 minutes from the present time
    }

Finally after nine days of this I had to run the gas generator to power the fridge and charge the batteries.   I also added battery monitoring to the blinking LED to give a visual  on battery condition.  One long blink indicates when the battery is under 13V and additional short blinks for each step lower in voltage.  It seems useful.   As i mentioned before, the program also has a battery slump detector.  Inverter start up draws 90+ amps and the program saves the lowest voltage and outputs it as an analog PWM signal to be read by a DVM.  I came to camp with four identical batteries.  One out of the truck that stays at home, one boat battery that normally stays on the camp system till used.  Added to this was a battery removed from the car when it wouldn't start it and another that I left in the garage to sulfate for 5 months.   I had in my mind to test them all but never got around to it.  This slump test makes it easy to figure out which two to leave behind.  This also revealed a bad connection in my battery bank about a month ago.

Initial tests with the 10 gallon diversion water heater indicates that next year I will have plenty of hot water.  29V on the 2000W 120V element (about 140W) was enough to heat up the tank by 5pm.  It will be no problem at all to boost that to about 250W.  Next year I will have panels in 12, 24 and 48V groups all controled by the UNO.

Bruce S

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 5374
  • Country: us
  • USA
Re: Chest fridge control with a UNO
« Reply #16 on: October 15, 2012, 03:01:25 PM »
OperaHouse;
Good to see this worked out so well!.
Question why the extra panic at 39f? Maybe 40.5F if you can code that in.
That's were if one of ours hits the level an alarm goes off telling me something is wrong.
At 40.5 is where my wife's safe food handling books tell me that the safe buffer is now past.
Or is that to give you enough time to switch on the genset?
Thanks for the great programming lesson!!
Bruce S
A kind word often goes unsaid BUT never goes unheard

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #17 on: October 15, 2012, 03:29:16 PM »
My parents are in their 90's.  I visit them sometimes and see their fridge set to 43. I turn it down when they aren't looking.  My mother just says she hasn't died yet.  When visiting I have adopted the policy of eat out or take out.  39 was juat an arbitrary number.  Initially I wrote the code to kick start the fridge in the morning when it is foggy and had it functional only for the first 150 minutes.  I didn't want the batteries to stay in that low charge stste.  When the weather got worse it I removed the time limit.  Soon that was the only mode it operated in.  I hate this time of year.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #18 on: July 30, 2013, 02:01:54 PM »
An update.  The batteries are older and don't seem to hold as much charge.  The system normally runs only with the sun except for a last timed cycle of the day and the first in the morning.  Inverter has been giving me an occasional low voltage alarm in the morning.  I plugged in a vintage electric alarm clock to see how long it actually ran and found each cycle was 16 minutes.  In the program it is written as 12 minutes.   After adding a number of additional subroutines that minute has stretched out.   I adjusted the time loop count and reduced the number of run time minutes to 9.  So far that is working along with buying additional panels.  I added this 12V fan to cool the motor.  The compressor has a lot of surface area and this is the hottest part of the system.  Seemed like the right thing to do when it was 95 in the house.  It attaches with adhesive refrigerator magnets and is powered off the relay power.

bob g

  • Hero Member
  • *****
  • Posts: 1107
  • 8.8kwatt idi diesel thermal conversion unit
    • microcogen.info
Re: Chest fridge control with a UNO
« Reply #19 on: July 30, 2013, 02:17:17 PM »
this is a very cool project!  thanks for posting it.

on the topic of spares, having moved back to central kansas from the seattle/tacoma area, i am faced with the fact that i have to drive anywhere from 30 to 60 miles to find even the simplest of bits and pieces.

so i have reverted to my youth, wherein i check the dump daily, and collect anything that might be useful later.

even steel banding i collect the two most popular sizes, because i have found there are times i need a short piece to shim up something or make a spring or whatever... and if i don't have it on hand, i have a heck of a time finding even something that simple.

i collect wire, and part out tv's, washers/dryers and electric ranges,, and grab up any puter's that get dumped.

i also collect steel tubing, such as that used in old exercise equipment, because sometime i need a short piece of thin wall tubing,,,

its funny how once you get into the mindset how you will look at things laying about much differently than you once might have... what once was a piece of junk/rubbish... now becomes i vital parts source.

bob g
research and development of a S195 changfa based trigenerator, modified
large frame automotive alternators for high output/high efficiency project X alternator for 24, 48 and higher voltages, and related cogen components.
www.microcogen.info and a SOMRAD member

madlabs

  • Hero Member
  • *****
  • Posts: 686
  • Country: us
Re: Chest fridge control with a UNO
« Reply #20 on: July 30, 2013, 04:31:33 PM »
I'm with ya Bob. Not only do I live in a rural area but I am poor and I love re-using stuff, I'd do it even if I had money. My bro in law and I call the dump the "mall", like "I'm going to the Mall, anything in particular you're looking for?". And there is usually no way to tell, once the project is finished. It all looks good and I love surprising folks by telling them that the materials for someting came from the dump. Err, Mall.

Nice job on the freezer! I'm planning on doing the same thing soon. My plan is to use surplus electricity during the day to pump the freezer colder than usual. Then at night allow the temp to rise to the normal setting. Are you doing anything like that?

Jonathan

Jonathan

bob g

  • Hero Member
  • *****
  • Posts: 1107
  • 8.8kwatt idi diesel thermal conversion unit
    • microcogen.info
Re: Chest fridge control with a UNO
« Reply #21 on: July 30, 2013, 08:03:04 PM »
i tell my wife the dump is my favorite store!

it's amazing what comes up there every once in a while.

and it gets to be fun trying to see what one can build using stuff he finds laying around.

as opposed to some folks that see a hunk of junk and pick it up to take in for a couple bucks at the recycler.  i see them hauling in stuff i know i would pay them twice what they would get for it and still feel like a stole it.

bob g
research and development of a S195 changfa based trigenerator, modified
large frame automotive alternators for high output/high efficiency project X alternator for 24, 48 and higher voltages, and related cogen components.
www.microcogen.info and a SOMRAD member

thirteen

  • Hero Member
  • *****
  • Posts: 980
  • Country: us
  • Single going totally off grid 1,1, 2013
Re: Chest fridge control with a UNO
« Reply #22 on: July 31, 2013, 03:30:25 AM »
You could always tell her you are going to the mother-in-law gift shop.  Just short chuckle. 13 no insult intended 13
MntMnROY 13

keithturtle

  • Full Member
  • ***
  • Posts: 224
  • Country: us
  • Things that fly
    • aftertherapture
Re: Chest fridge control with a UNO
« Reply #23 on: August 01, 2013, 12:37:31 AM »

as opposed to some folks that see a hunk of junk and pick it up to take in for a couple bucks at the recycler.  i see them hauling in stuff i know i would pay them twice what they would get for it and still feel like a stole it.

I've done real well at the local recycler with finding magnet wire- I get it for scrap retail price and it's still only a fourth of what new wire costs.  Sure there is some waste, but if I'm selective I do real well.  Last deal was 77 lbs of 19 ga mag wire on a broken spool for just over 200 turtlebuks.   Lots of coils to be wound from that find.

Dumpster diving should be an Olympic sport

Turtle
soli deo gloria

OperaHouse

  • Hero Member
  • *****
  • Posts: 1309
  • Country: us
Re: Chest fridge control with a UNO
« Reply #24 on: June 26, 2014, 04:25:17 PM »
Another season has started at the camp and the fridge program  is still working and making hot water.  Ironic that the refrigerator  control program is called waterheater although for two years it just ran the chest fridge and water heating didn't start till end of the season last year when I was given a suitable tank.   A couple of days ago I noticed that the independent fridge thermometer had a higher temperature than expected.  These can sometimes vary because of how newly added food is placed.  I manually ran the fridge to put in a little extra cold before it would shut down for the night.  Next morning I noticed it still wasn't running.  Then I discovered the wires to the temp sensor were broken.  That open appeared as a really low temp.  I quickly added a line of code to flash the condition LED should it happen again.

The water heater is a PWM dump load that operated the panels at power point for highest power transfer.  I had been running 24V panels at about 35V but found at peak times voltage was over the power point and just wasn't getting enough power into the heater.  The other day I changed the panels to 36V and chose a power point of about 52V.  I was surprised that just one line of code had to be changed and the hardware was just fine with the higher voltage.  It has been cloudy and rainy for a couple of days but I can see the improvement.   Right now I am running two UNO with one dedicated to the water heater.  The identical program runs in both.  It was just easier not running all the extra wires and didn't like shutting down the fridge each time I make a software change.  There is a time delay to prevent hot start each time it is reset and there is always that potential software bug that may take an hour to find.    The program also controls charging and this year I will be having 36, 24 and 12V banks.  When things are more finalized I will do a post on the water heating and charging elements of the hardware and software.