Author Topic: Control for heating with solar off grid no batteries  (Read 74972 times)

0 Members and 1 Guest are viewing this topic.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #33 on: August 10, 2016, 02:32:59 PM »
I think ontfarmer has done quite well so far, but he hasn't been exactly a Chatty Cathy. I have saud before that just loading in the software and getting one of the supplied sample programs loaded into a UNO is about 80% of the work.  A lot of people are following this and wondering just how you even start.  His perspective is quite different from mine and his experiences would be quite interesting to others.

I understand the cosmic angst of facing something new. I just bought my wife a new car two months ago.  Got her just what she wanted.  She had to move it in the driveway and it took fifteen minutes to figure out how to get the windshield wipers to work.  Well the manual is 700 pages!  She still won't drive it, says leave the truck for me. She wouldn't drive the truck either till I was in the hospital and she had to.  Now she thinks it is hers.  I just got a new phone and can just barely use it.  I still have not updated the version of the Arduino software downloaded years ago.  It does everything I want now.  Who knows what can of worms I could get into.  We all have fears.  So, your experiences would be very interesting to people.  Document every step of your project here.  Help someone else get started.  I appreciate this takes time.

Got more updates but will hold off for a while.

DamonHD

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 4125
  • Country: gb
    • Earth Notes
Re: Control for heating with solar off grid no batteries
« Reply #34 on: August 10, 2016, 03:23:24 PM »
I just like the way you're turning him into a programmer without it being any more fuss than learning how to use a new tool on the workbench!  B^>

I am terrified by ALL of this stuff, even though I'm apparently quite good at some of it, like novelty and change, and am not especially risk-averse.  Pick your battles, I say!

Rgds

Damon
Podcast: https://www.earth.org.uk/SECTION_podcast.html

@DamonHD@mastodon.social

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #35 on: August 11, 2016, 09:53:59 AM »
I'll talk about some other aspects of the uno hardware. The A/D converters use the power
supply +5V for a reference.  Supply voltages can vary from 4.95 to 5.25V.  Any numbers I
give you for the A/D converter are general and can vary a bit.  When you plug in a laptop
with the USB cable, the laptop may supply the voltage even though the uno is powered by
another source. USB power is often higher because it has to deal with cable losses. I found
this out the hard way when I wrote my refrigerator program. I calibrated my diode temperature
sensor with laptop power. When I got to the camp and it ran off the internal regulator,
the temps were several degrees off.  I solved this with future development projects by
having a dedicated USB cable that has the 5V line cut. I use back to back diodes where I
made the cut. This insures there is always some power connected, but differences of supply
voltage differences of up to 0.6V are ignored.

The A/D converter inputs like to see an input impedance of about 10K.  They have a fairly
high input impedance, but have a charge coupled aspect to them.  A capacitor at the input
of .1uF or higher insures a stable reading.  It also absorbs noise spikes and radio
interference that might be present.  There is another interesting thing you might experience,
ghosting.  Those pins are awfully close together and if viewed at an angle it is easy to
place that pin connector at the next adjacent pin.  When you have a moment you should try
this.  Add another A/D input and assign it to the next pin not used and leave it floating.
Read it out in the serial section. That number will be about 70% of the prior pins voltage.
I've seen it many times on message boards,  Help...I'm not reading the voltage I should have.
That happens often with input A0.  It is the first A/D converter and your mind thinks A1.
In computers zero is a number.

Inputs and outputs must be declared in the program.  pinMode does this by identifying the pin
number and whether it is an INPUT or an OUTPUT.  Just to confuse you further, those are the
pin numbers on the board connectors not the pins of the IC.  Since you won't be building your
own boards that shouldn't be a problem.

pinMode(13, OUTPUT);       // sets the digital LED pin 13 as output, onboard LED

It is very easy to forget to include this when adding a new output to the program.  The compiler
will not flag this as a problem.  Two things will happen.  First, the output will only turn
on for a very short time. Short enough that you may not notice any thing has happened. The
output will not latch to the on state as it normally does and it will go to a floating state.
If you are driving a FET without a gate pull down resistor, the will turn on for quite a while until
the capacitance of the gate discharges.  That can leave you pulling your hair out trying to
figure out why things randomly turn off. Thinking they should have made the compiler smarter?
This is actually a feature that many programmers use.  Here is a simple test you can try.
Comment out // the line that identifies pin 13 as an output. You can just make out the LED
flashing if the room isn't too bright.

void setup()
{
 Serial.begin(9600);        // setup serial port speed
 // pinMode(13, OUTPUT);       // sets the digital LED pin 13 as output, onboard LED
 pinMode(10, OUTPUT);       // digital pulse for timing loop OPTIONAL
 pinMode(3, OUTPUT);        // sets the digital pin 3 as PWM output to drive FET
}

This is the kind of stuff to have in a boilerplate sketch.  You will always be using some
output. Pin 13 is always used for the onboard LED.  You could name every pin and the compiler
wouldn't care if you didn't use them in the program. The same with the serial port, you don't
have to use it.  And it keeps the designated structure of the program.  It is easy to forget
to start and end with the brackets.  void setup()  What's that about? I do not know where they
get these names. They could have used norknid. It just has to be there and having a boilerplate
sketch will do that.  Then you can concentrate on the actual logic code.

This is simply a tool. Downloading the compiler is free.  Edit up one of the sample programs
like Blink or AnalogReadSerial and click on VERIFY. That will compile and check for errors.
Putting the code of the Blink program into AnalogReadSerial would be a good exercise and the
start of a boilerplate sketch.  No need to buy any hardware.  Boilerplates make programming
faster and easier.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #36 on: August 12, 2016, 09:25:39 AM »
I think I told you about ghosting of the A/D converter. I've been playing around with this
program on a breadboard and I can see a tiny bit of ghosting when I am trying to get the
program to increment a count very slowly. This is because impedance's are higher than ideal
at the input of the A/D converter. I suggest you move the pot input from A1 to A3. This
will reduce this interaction between the two. In practical operation this wouldn't mean much. 
I just found it a little annoying when adjusting the pot is so touchy anyway. If you were trying
to do something more precision, grounding the analog pins to either side would help.

Time for more features. I've added a calculated power reading. In doing so I violated my
rule for beginners, to keep everything "out of the box" as possible. Using an unsigned integer
skirts on the border. Integer math allows positive and negative numbers up to 32K. Multiply
something and exceeding 32K produces a negative number. A pretty definite indicator this limit
has been exceeded.  With an unsigned integer, that can go up to 64K. Exceed that and the number
gets much smaller than expected. Unsigned here is pretty handy when dividing by a large number
like 255. The bigger the numerator the better when dividing.  Just be aware of the trouble
you can get into when types of integers are mixed in a program.  Like pasting a section of
code from another program. Going long can get you into a bigger can of worms.  At some point
you should try it. If at all possible keep multipliers to the power of two. This is what
declaring a unsigned integer looks like. Not that scary.

unsigned int power32    = 0;  // output power X 32, a nice binary number
unsigned int maxpower  = 0;  // potential power of heater

You will need to know the resistance of the heating element and enter that in the program. I
chose 9.3 ohms. Heaters will all have a stated wattage and voltage. For example

             2000W / 240V = 8.3 ohms 

This gets multiplied by 10 in the program to make it a nice integer number. That is because
the panel voltage in the program is ten times the actual value.  It all comes out in the wash.


    // CALCULATE POWER OF HEATER
    // panel integer is actually 10 times the voltage
    // this must be reduced first to stay within processor limit
    // of 64K for the unsigned variables maxpower & power32
    // resistance is multiplied by 10 to make a two digit number
    // This is the same as another division by 10 of panel
    //     maxpower = E * E/R
    //     power = maxpower * PWM%
    // except we multiply the PWM3 count by 32 to get a larger number
    // before dividing.  Larger powers and wattages may require different
    // numbers to stay within 64K limit of processor. The numbers are a
    // little choppy due to integer math. This is a pseudo reflection of power.
   
    maxpower = (panel/10) * (panel/93);
   
    power32 = maxpower * (PWM3 * 32 / 255);

Note the parentheses.  If all the multiplications were done first, the number would be too large.

Then we print the number out to the screen.  That number is 32 times the true value.  For
convenience it is divided in the print statement.  For lower wattage heaters that number
could be higher and vice versa.  Testing by forcing values to either limits will insure
you haven't made a mistake. For this variable an integer is suitable.
   
    Serial.print("    ");                     // create space between last data
    Serial.print(power32 / 32);         // print output power reduced by 32
    Serial.println("W");                   // identify variable and do line feed

When using this data to find the panel power point, first tune for the highest wattage.
Then fine tune for the highest % or PWM3 number. Wattage can take some big jumps.
   
   
« Last Edit: August 12, 2016, 09:35:50 AM by OperaHouse »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #37 on: August 14, 2016, 01:25:28 PM »
My plan for heating water with solar panels is to help heat the house. I put up 12 panels 
 3720 watt.  Storage is going to be 2 furnace oil tanks. The water will be circulated through the furnace.
The heating elements  are 120 volt 1000 and 1500 watt, not sure which one will be best in
the winter?
The controller for the heater element is arduino UNO that will be done by PWM.  OperaHouse  has been very kind helping me with all the details, wiring, programing,
 Etc,  Etc.
Here is the panel.


OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #38 on: August 14, 2016, 04:41:54 PM »
This is the box I put my drivers in.  Oddly enough this box was from a commercial water heater.  The only thing in it are the FET drives for my two water tanks.  The uno was about 30 feet away in the house.  Having it up to 100 feet away is a nice feature of this system using opto isolators. Mounting this on the side of the house was prior to my building the power shack, a 4 X 6 foot enclosure for all the solar electronics, batteries and water tanks.  Note the plastic cover to protect it from rain.  When I moved it into the shack there was a frog inside that was electrocuted.  You might want to try the system I used here.  Each heating element has its own FET driver.  Start with the 1000W heater, when that goes to 100% duty cycle start the second heater.  Just a slight variation of the program.  Instead of counting up to 255, the count goes up to 510.  The first 255 is one heater and the next 255 is the second heater.  I see pumps to control too.  You will have fun with this.

The display is a Turnigy power meter.  Unfortunately these only monitor up to 60V.  That works fine for my 36V  array.  I cut a trace modified it to work on 12V.  I don't trust their regulator at 60V. The LED show 12V power on and the other two are for the heaters.
« Last Edit: August 14, 2016, 05:10:08 PM by OperaHouse »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #39 on: August 14, 2016, 06:37:12 PM »
The pump for circulating hot water to the furnace will be powered with hydro from the grid.

I was installing two different size heating elements  1000 and  1500 watt  because of not
knowing how much the panels will provide in the worst of the winter. The plan is to power  only one element at a time 1000 watt first, when the days get longer if there is enough power the wires can be changed to  the 1500 watt.  That way the elements are there and
just change the wires.  Six panels will be used to power the element.  There will be two of these systems.
« Last Edit: August 15, 2016, 03:05:23 PM by Bruce S »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #40 on: August 15, 2016, 11:12:58 AM »
I had to go back to the other thread to figure out what you had in panels.  Somehow I
had the feeling you had less power and this was three strings of 24V panels. This doesn't
make a substantial change, but there are practical aspects like wire.  Three sets of #12
cable is cheaper than four.  That means instead of a buss voltage of about 110V, it has
to be raised to 150V.  I assume those 1,000 and 1,500W heating elements were 120V. A 4,500W
240V element will produce about 1,200W at your operating voltage.  The scale that appears on
heating elements is due to boiling on the surface and that deposits minerals. Operate the
heater with a lower heat density and those deposits will never form.  So I'm in favor of
using elements at a lower voltage than rated.

I don't know your long term goals but it seems you have a lot of tank capacity. I can heat
30 gallons of water up to 140F with 900W of panels. For certain reasons that is not optimized
but it gives a ballpark number to work with.  At home I collected data on heat loss at night
with a 30gallon water heater. It came to about 3KWH a day.  This tank was not well insulated
even though I had an external fiberglass blanket to it. Heat loss isn't a bad thing if it is
the heating season and the tanks are in your living room.  A 275 gallon oil tank has a lot of
surface area.  It would seem more practical just to do heating with a wall or space heater
during the day.  With the uno you can do zone heating.  With 150V buss a 120V heating element
can be used.  Just limit the PWM to about 200.  The world is your oyster with a UNO. Regardless
I think you will be needing a couple more FETs.


ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #41 on: August 16, 2016, 01:27:03 PM »
Space heater is something to consider for heat. Would be a lot less work.  With the hot water  going through the furnace would look after  the rooms that get heated and may get
some a night ?

My wind turbine powers baseboard heaters for zone heating.  I will give that some thought.




« Last Edit: August 17, 2016, 08:58:49 AM by Bruce S »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #42 on: August 16, 2016, 04:03:47 PM »
See, there is always more to the story. I didn't mention it, but was more concerned about the shading on the panels in the picture. It would be good to confine that to one string.  I'm finally off to camp after delaying it 2 1/2 months.  Long trip,probably wont hear from me till Sunday. 

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #43 on: August 24, 2016, 06:29:47 PM »
 Have not heard anything.  Just checking how the trip was to the camp ?

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #44 on: August 24, 2016, 07:49:29 PM »
It was a typical trip.  Just outside Corning NY, about 200 miles from camp, I looked in the rear view mirror and saw smoke.  Leaf spring on trailer snapped and tire was burning a hole in plastic storage container.  Just missed the battery by an inch.  Contemplated just taking what I could and abandoning the rest.  Buying another $200 trailer just for the spring was another option.  Jacked trailer up and and removed the spring pieces.  Found three small pieces of wood along the road.  Duck taped them together and put them under axle.  One inch forward or back on that side would chew up tire on frame.  Nothing held the block of wood in place. Took ratchet strap off load and wrapped it around axle to front and back of frame to keep it in place.  The wood was basically held in place by weight.  If block fell out it would destroy the tire. My wife said the usual...Is this safe.   Made it to camp in spite of very bumpy roads.  Out on Cape Cod for a couple of days with relatives.  Everything fired up at the camp normally and no leaks this year.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #45 on: August 27, 2016, 12:32:11 PM »
What have you done lately.  You should have burned up something by now.

How important is tracking the power point?  At my camp I don't do it.  I'm only there for
one season so the temperatures are pretty consistant.  My water heaters do not present
enough load in full sun so voltages on them go over the poWer point anyway for one hour or more a day. Early mornings don't provide a lot of power anyway and all that goes to charging the
battery so the refrigerator can come back to temperature.. Running a temperature sense line out to the panel may not be cost effective or practical.  Even a sun absorbsion plat at the house can have issues. If you want to keep it simple, adjusting the power point manually would be good enough. Lack of tracking hasn't affected me in a tangible way and other priorities have kept me busy. But, going from summer to winter is a big change in the power point and if you do have a year round system it should be somewhat automatic. I had a panel at home to do some development work last spring. I didn't get far with that. Now that is at the camp and part of the water heater array. Some simple routine for power point tracking will show up later.  At least one IC manufacturer uses this panel temperature method and claims this is a tracking chip.

The key point of this system is the gigantic difference it makes between a direct connection
to a simple resistive load.  Solar panels hate a fixed resistance load.  Once sun intensity
drops just a little, the voltage drops a lot.  Power is voltage squared divided by resistance.
That magnifies the problem and from the charts the voltage drops very quickly. With this system
the voltage isn't allowed to drop.  The load adjusts to maintain the voltage.  At early sun and
late afternoon the results are dramatic.  And of course clouds can happen at any time.

I have to rethink my system with the new medical load.  I need to parallel the house and the fridge battery at night and then disconnect them in the morning as the fridge comes on line.  The house battery is located in the house about 40 feet from the power shed battery.  The wire resistance of that long run prevents that battery from getting a high current charge.  I sense that it doesent get back up to a full charge potential.

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #46 on: August 27, 2016, 08:03:36 PM »
I have been working installed a wire to the panels for the tracker, got part of the tracker put together.  added the information you gave me to the sketch.  Picked up 240 volt elements to try.  Is the resistance for the heater just added?  maybe you can give me a example.  Unsigned interger  didn't understand but that doesn't matter as long as it works.

Hooked up the three 1000 watt 240 volt baseboard heaters they where producing heat at
140 some volt.  The two FET got the heat sink quite warm. A bit like your wife in the new
car a bit confused not wanting to wreck something.  Waiting on digital  metre.  Putting elements in tank then will power them and see how that goes.

[quote author=OperaHouse With this system the voltage isn't allowed to drop.  The load adjusts to maintain the voltage. 
I will check to see if this works on mine? Have not changed the PWM to 200 yet.
Should I  ask about new medical load?  Hope things at fine.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #47 on: August 30, 2016, 12:33:25 PM »
No need to change the PWM limit to 200 if the elements are 240V.

A binary 16 bit number is 64K maximum.  The standard integer math is signed. The highest bit is used for negative or positive indicator so the maximum number is +32K or -32K.  If you know that your numbers will never be negative, that bit 16 can be used for a number up to 64K.  That doubles the possible number size.

I know this is coming out in drips an dabbles.  In integer math, the remainder is always dropped. This will consistently give you lower numbers in your calculations.  If 26 is divided by 10, the answer is 2.  If half the divider of 10 is added to the number before division, the number will round up. 26 + 5) / 10 = 3.  So, remainders of 4 or less get rounded down and 5 and over get rounded up.  In the example I used some ruff justice and added 6 since the second number is divided by 93 and the adder for that division should be higher.

    // Ineter division always drops the remainder so numbers are consistently
    // low. This routine corrects that consistant low number.  Both divisions
    // are basically divisions by 10.
   
    panelrndup = panel + 6;                    // add 6 so division rounds up
                                                            // remainders 4 and over and rounds
                                                            // down remainders below 4
                                               
    maxpower = (panelrndup/10) * (panelrndup/93);

Why don't you draw exactly what you have for an output circuit.
   

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #48 on: September 01, 2016, 02:04:00 PM »
Three 1000W 240V heaters in parallel will not be enough load to drop the voltage.  That is likely about 900W total.

I optimized some of my own software because the numbers were when I had fewer panels.  I ran out of power two nights even though the additional load is only 9AH.  Turns out the second battery is not up to snuff.  If I remember to parallel the two batteries everything works.  Fall is coming and still concerned about the days being short and cloudy.  Yesterday was overcast all day and only got a lukewarm shower.  There are generally two days at the end of the season when I have to fire up the generator just to keep the fridge going.  Might need to run an extension cord to the neighbor.

This is the power shed and software development center. Your proto board is on the table above the water heaters.  I swore I would keep this one place nice and clean.

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #49 on: September 03, 2016, 01:56:58 PM »
When the three 1000 watt baseboard heaters  where plugged in the voltage dropped 20 volts.
When I entered the last info to the sketch it said that " panelrudup " was not declared.

You have a lot in that power room, doesn't look that bad to me. Putting some things together right now, then  I will draw the output circuit.

Busy on the farm again, will get back to this in a few days.

Thanks

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #50 on: September 04, 2016, 01:24:37 PM »
You didn't declare  panelrudup as an interger at the start of the program with the other variables.  And you can call it what you want but it is RNDUP not RU.  You may have two spellings if it was declared.

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #51 on: September 08, 2016, 01:16:57 PM »
While we are waiting, here are some routines that may be useful in other projects.  The SERIAL MONITOR in tools is very useful in debugging a program.  Not only can you get data from the micro, but you can send it back.  The first code is a simple loop counter so the screen just doesn't become a blur of data.  it counts program loops and resets at 10 or any other number.  This only works in the last routine.

The next code allows me to reset program variables without having to wait.  The inhibit is used in the refrigerator section of code.  It prevents a hot start just after the refrigerator has turned off.  inhibit starts at 5 for minutes and counts down to zero.  If you change some code, you hate to wait 5 minutes to see if it works.  This manually resets it immediately to zero so new code can be tested without waiting.  Handy for a lot of applications.

The last allows you to use a pot to vary a setpoint to see if it is optimal before setting it in stone.  The A/D reads 0 to1023.  to make a finer adjustment just divide that number by 2 or 4.  Then subtract half of the maximum value.  That will give you a +- range.  Add that to the fixed number under test.  Then just display the numbers so they can be entered manually in the program.  I have a pot with pins on the leads.  Just connect to GND, analog input , and power +5 or 3V3 for smaller numbers if the +5 pin is already used.  AI3 is my variable used for analog pin #3.  The actual read is elsewhere in the program.


update = update + 1;                                               // loop counter
if (update == 10) update = 0;                                  // reset every 10


 if (Serial.available() > 0) kbd = Serial.read();             // look for and get keyboard 
                                                                                //character to change diagnostic screen 
                                                                                // kbd is the character returned
                                                                                //from keyboard


  //     RESET VARIABLES COMMAND FOR TEST
    if (kbd == 'R' || kbd == 'r')                                   // if R or r reset variables
  {     
    SLUMP = 15000;
    DLV   = 0;
    DLV2  = 0;
    DLV3  = 0;   
    DLV4  = 0;   
    DLV4  = 0; 
    SLUMPCT = 0;
    inhibit = 0;
  }


 if (kbd == 'p' || kbd == 'P' || (keyboard == 'P' && update == 1))           
                                                                             // if P or p  POT debug screen
                                                                             // update slows down data display
  {
    keyboard = 'P';                                                   // retain keyboard value otherwise
                                                                             //it will be lost
    Serial.print(" ");                                                 // space before start of data
   
    Serial.print(AI3);                                               // raw A/D value from pin #3
    Serial.print(" AI5    ");
   
    POT = AI3 / 4 - 127;                                           // divided value gives +- 127 also
                                                                             // gives deadband
   
    Serial.print(POT);                                                // display POT value
    Serial.print(" POT");
    Serial.print('\t');                                                 // send tab for spacing
   
    SET12 = POT + 1500;                                         // add adjustment             
   
    Serial.print(SET12);                                            // adjusted standard value
    Serial.print(" SET12    ");
   
    Serial.print("   15000    ");                                   // normal value
   
    Serial.print(PWM9drv);                                         // adjusted standard value
    Serial.print(" 12V drive    ");
   
    Serial.print(panel12);                                            // panel voltage
    Serial.print(" 12V panel");
    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 ('P');
  }




« Last Edit: September 08, 2016, 01:34:52 PM by OperaHouse »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #52 on: September 10, 2016, 07:44:56 PM »
 Made up a bracket to support the capacitors  and the rest of components.  Hooked up the
wires that's when the problems happened. When I came upstairs to check the uno the led
light was on but not blinking just stayed on, the TX light did not flash. 

When I put the wire in to drive the FETS, started at the uno  went 15' with 24 awg put the opto isolator there which is powered by the uno. That is where the 15 volt wall wart is to power the 30' of 24 awg to the FETS.  Tried uploading but no success  getting the code
below. The testing I done on the baseboard heaters with temporary wiring went well but not this.

Arduino: 1.6.9 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 5,928 bytes (18%) of program storage space. Maximum is 32,256 bytes.
Global variables use 284 bytes (13%) of dynamic memory, leaving 1,764 bytes for local variables. Maximum is 2,048 bytes.
           (  I erased from 1 > 9 )

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x84
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #53 on: September 11, 2016, 06:38:07 AM »
Should have added this.  Checking to try and find what was wrong the voltage was the same
on all three pins of the FET   150 volt. Wondering if that on the gate got back to the uno?
Thought it could not get past opto isolator?

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #54 on: September 13, 2016, 12:21:14 PM »
Where are you measuring from?  You should measure from the negative side.  It sounds like you measured from the positive. That is the only way all three pins could be about the same voltage.

Just take a deep breath and go away for a while.  I was working on my system last week making some major changes.   All at once almost nothing was working right but the fridge.  I plugged in the USB and my debug screens were giving weird numbers.  I do more changes.  Suddenly I realized I had plugged in YOUR proto board an downloaded software to that system instead of mine.  Then the laptop shut off from low battery.
« Last Edit: September 13, 2016, 12:42:33 PM by OperaHouse »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #55 on: September 17, 2016, 12:45:14 PM »
Arduino: 1.6.9 (Windows 7), Board: "Arduino/Genuino Uno"

I am still using 1.0.   The Board: "Arduino/Genuino Uno" bothers me for two reasons

1. That you actually bought a real UNO.  Generally I suggest people buy three clones because you never know what is going to happen.  The opto isolator will offer some protection, but there are a lot of other ways you could torch it.  People are so creative.  If you do not have a real UNO, that may be an issue with the communications driver.

2. I don't know if that is a selection or they are sensing something on the board.  Many were using FTDI chip software driver on clones made to emulate that chip.  FTDI got pissed and wrote some software to brick the boards that didn't have a genuine chip making them useless.  With the fighting that is going on at Arduino, there may come a day when Adruino software may not work on clones.

You haven't exactly been a Chatty Cathy on this project and I don't know exactly what you have done.  I had hoped that you would have documented every step of the project here.  I know  that many times what I have said has been misinterpreted.  I know that what I consider obvious may not be that way to you.  Little things like if you are using a laptop to program or a desktop can make a difference.  There can be big issues with a desktop when the desktop makes a ground connection via the the USB cable to the system common.  You have a lot of voltage and current and it is best to start with a single string of panels and not all the array that can smoke some wires.

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #56 on: September 18, 2016, 11:06:49 AM »
Took your advice walked away from it  worked on other things.  The first two uno I got where
$30. apiece. Then on ebay  ordered two more for $9. each delivered in our dollar. Thought
should have spare one or two on hand. That is a lot more than you guys get them for. Guess
 should of been buying the clones.

I have Windows 7 on desktop. Should I be changing to 1.0 ?  Had the polarity wrong going to the gate. Couldn't get the uno to upload it would verify but come up with that code when uploading.

Took one of the new uno that I just got, uploaded the sketch on it that is working. There is just one string that is hooked up trying to get that working first.  Know I have misinterpreted some times.  Very grateful that you have got me this far.  I will try to do more documenting and communicating.
Here are the two different uno's




ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #57 on: September 19, 2016, 11:21:10 AM »
Here are  some details of the wiring from the panel into the house.  I mounted a box on the frame of the panels, the wires from the panels go into the box,  there are two single pole 15 amp  150 volt dc breakers in the box.  Six panels per breaker, from the box into the house I used # 4 wire. ( already had around )  Those wires go into a junction box at where the tank with the elements are.  The capacitor bank, fet are mounted on the end of the tank.

Here are some pictures

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #58 on: September 19, 2016, 01:47:54 PM »
Could you help me on reply # 5  for control of pwm ?  You explained that in detail and diagram.  I got  the pot, etc  put it together but  was not successful  in getting it to work.
The diagram shows to plug into a pwm pin. I don't know which one.  The blinking light on
the uno varies with the power of sun. Hope you under stand what I am trying to describe.
The load to the element is not being controlled.
Thanks

« Last Edit: September 19, 2016, 04:20:50 PM by Bruce S »

OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #59 on: September 19, 2016, 02:01:07 PM »
I ordered a UNO clone.  The picture showed the ugliest board ever, but it was cheap.  What came was a board identical to a genuine UNO.  I think someone got caught making identical copies and they were unloading them using this picture.  Arduino would never think this pictured board was a threat to their business.

If the outside pins of the FET were reversed, that could destroy the gate of the FET.  A very high percentage of the time this will reflect as a short between the two outside pins. 

If the D and S were reversed the FET would likely just conduct safely and be ok.  Excess current through the internal protective diode also could damage it.

I need to jump back and look.  The drive pin is on 3  .  Generally avoid using 5 & 6 as PWM as these are 980 Hz which is getting a little fast for simple drivers.   You can always look back to the code.  Just find the analogWrite statement.  The first number following it is the pin number.

I was just writing some code for the fan posts and I had copied a prior program.  The PWM analogWrite wasn't working at all.  I stared at the simple code for the longest time before I realized I was trying to send PWM data to a digitalWrite.  I had intended to edit that line and forgot in a rush.  It is also easy to to use X=1 in a logical IF statement when you intend to use the logical format of X==1.  At least my older compiler won't catch it and your mind sees it as perfectly reasonable.
« Last Edit: September 19, 2016, 02:11:32 PM by OperaHouse »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #60 on: September 26, 2016, 08:56:00 AM »
I spent quite a bit of time going over the postings trying to make sure nothing was missed.
Done some updates to the sketch reply # 16  panel = panel - panel / 2;  panel = panel +
rawdata;  deleted  * 32 multiplier,   now when serial monitor is brought up all readings are
0 ?  Must done something wrong, it  verifies and uploads.
Checked the wiring the fet are correct, does it make a difference if the capacitor bank is wired in line or just joined to the side ?  The fet are powered from pin three.
You explained the RX  TX  LED  flashing,  on mine the TX gives one flash and the LED gives multiple flashes according to power level.  The RX never flashes,  maybe this tells you something I have done wrong ?
Going back to the code pin 10 is the pin for the PWM.  I wish some of these things where
obvious to me. Do you see a problem with the desktop or 1.6.9 ?
  Thanks


OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #61 on: September 27, 2016, 12:25:52 PM »
It is natural for everyone to want to jump to the finish line.  Forgot to bring my glasses to the library today and I can barely see anything.  The serial data screen is the window to the program.  You should have at least a number for rawdata.  If not there is an issue with the hardware.  I suggest you add this to the serial screen;

serialPrint ("V1.0      ");                 // current version

This will indicate that the latest version of the software has actually been loaded into the UNO.  For little changes edit to V1.1, V1.2, etc and major changes V2.0, V3.0 etc.   Save those versions so there is something to go back too.

This program is a system.  The rawdata is a number from 0-1023.  If it is stuck at one end, nothing will happen.  The voltage divider should be selected so that the nominal number is between 600 and 700.  That number is doubled by the routine you quoted to a value between 1200 and 1400, this will represent a voltage  between 120 and 140V.  These are generalized values.  Whatever the voltage is on the capacitors should be the same as the readout.  Adjust the voltage divider pot  connected to the capacitor bank till you get that value.  At least get half that value for the raw data,  aprox 600 - 700.  Then you can work on the math issue.

The control loop is very simple.  If the capacitor bank voltage is less than the set value, the other pot, then the PWM number counts down.  Just the opposite happens  when the capacitor bank voltage is higher.    All these values should be in the serial data screen.

The issue I see is that there is likely more current available from the panels than can be used by the heater coils.  Even if the program is working properly it will appear to do nothing with the PWM stuck at 255 and capacitor bank voltage exceeding the set voltage.  Initially using one solar panel bank may allow the program to auto adjust.  It is ok to have more panel than heaters.  My water heating system is that way.  At peak sun periods my PWM goes to 255, fully on, and the voltage rises on the heaters.

I am getting only a pinhole view of the entire system.  The code you quote seems perfectly fine.  That may be what you think you are doing, but not the same in the actual code.  You can always copy and paste the entire program or a section.  then I can run it on my test module.

« Last Edit: September 27, 2016, 02:59:40 PM by Bruce S »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #62 on: September 28, 2016, 06:56:54 AM »
 Changed the code back to analog Read, put  (panel * 32); back,  now the serial screen is printing out the number value's like it had been.  I am thinking that
there was not enough added to code or maybe I didn't delete enough for it to print ?
Here is the code.
Code: [Select]
//This is a simple pwm driver to keep solar panel voltage
// at power point and prevent short pulses. A blinking LED
// gives heating status. Outputs a PWM drive to a FET.
// This project had a boost converter that boosted 12V panel voltage to 35V
// and was then PMW into water heater element for performance data.
// 4/26/15 Opera House
// 3/3/2016 Unknown version. Found with some mistakes that were corrected
// Compiles but untested. Unknown performance. Sent 7/25/16
int pot       = 0;           // raw A/D pot vpltage
int panel     = 0;           // calculated panel voltage in mv
int setpoint  = 1092;         // power point raw data count, set for power point
int blinktime = 0;           // blink loop counter
int PWMcount  = 0;           // PWM counter value
int PWM3      = 0;           // PWM3 output value
int meter     = 0;
int DAILY     = 0;     
int panelrndup = 0;
int rawdata    = 0;             // raw A/D panel value
int variablepot =0;          // veriable pot to range 0-1023. Setpoint to go higher so
                            // the variablepot will be doubled.       
// Ineter division always drops the remainder so numbers are
// consistently low.  This routine corrects that consistant
// low number.  Both divisions are basically divisions by 10.
unsigned int power32 = 0;    //output power x 32, a nice binary number
unsigned int maxpower = 0;   // potenial power of heater





//CALCULATE POWER OF HEATER
//panel integer is actually 10 times the voltage// this must be reduced first to stay within
//processor limit
// of 64K for the unsigned variables maxpower & power32
// resistance is multiplied by 10 to make a two digit number
// This is the same as another division by 10 of panel
//     maxpower = E * E/R
//     power = maxpower * PWM%
// except we multiply the PWM3 count by 32 to get a larger number
// before dividing.  Larger powers and wattages may require different
// numbers to stay within 64K limit of processor. The numbers are a
// little choppy due to integer math. This is a pseudo reflection of power.

//Ineter division always drops the remainder so numbers are consistentley
// low. This routine corrects that consistant low number. Both divisions
// are basically divisions of 10.







void setup()
{
  Serial.begin(9600);        // setup serial port speed
  pinMode(13, OUTPUT);       // sets the digital LED pin 13 as output, onboard LED
  pinMode(10, OUTPUT);       // digital pulse for timing loop OPTIONAL
  pinMode(3, OUTPUT);        // sets the digital pin 3 as PWM output to drive FET
}


void loop()  {

  // A resistive voltage divider produces about 2V-3V at pin A0
  // Typical operating voltage gives an A/D count of about 500
  // These values are for single 12V panel.  Adjust for your array.

  //  READ ANALOG VALUE AT PIN A0
  panel = analogRead(0);
  // A/D values go from 0 to 1023
 
  // MULTIPLY A/D VALUE TO OBTAIN PANEL VOLTAGE IN TENTH OF A VOLT
 
  panel = panel - panel / 2;
 
  //Sum the readings by subtracting one average reading first
  // It isn't obvious but the routine effectively multiplies the A/D reading
  // by the divisor. It can be any number, First a fraction of the total is
  // subtracted Then new rawdata is added.

  panel = panel + rawdata;  // Add latest A/D reading to panel total. This makes
  // a running average.

  // ADJUST PWM COUNT UP OR DOWN

  // FAST RECOVER from high panel voltage at startup or cloud passing
  // These first two just add/subtract an extra count each loop.  Count could be increased.

  // FAST RECOVER from high panel voltage
  if (panel > setpoint + 25) PWMcount = PWMcount + 1;

  // FAST RECOVER from low panel voltage
  if (panel < setpoint - 25) PWMcount = PWMcount - 1;


  // NORMAL UP DOWN CORRECTION 4 COUNT DEADBAND
  // NORMAL HIGH VOLTAGE RAMP UP
  if (panel > setpoint + 2) PWMcount = PWMcount + 1;
  // voltage is over setpoint

  // NORMAL LOW VOLTAGE RAMP DOWN
  if (panel < setpoint - 2) PWMcount = PWMcount - 1;
  // voltage is under setpoint


  // CHECK COUNT LIMITS This is the up down count
  // is count too high?
  if (PWMcount >= 255) PWMcount = 255;

  // is count too low?
  if (PWMcount <= 0) PWMcount = 0;

  // Set count to output.  This is the output value not to be confused with count value.
  PWM3 = PWMcount;

  // PREVENT NARROW DRIVE PULSES that cause FET heating.

  // is count too high and makes narrow pulse?
  if (PWM3 >= 255) PWM3 = 255;  // FULLY ON

  // is count too low and makes narrow pulse?
  if (PWM3 <= 5) PWM3 = 0;      // FULLY OFF

  // ROUTINE FOR DETERMINING LOOP TIME & PWM INTERACTION  Must have done this to check
  // time it takes to make program loop.
  // This section could be eliminated.
  digitalWrite(10, 1);
  delayMicroseconds(100);
  digitalWrite(10, 0);
  delayMicroseconds(500);    // delay for viewing analogWrite


  // PWM FET DRIVER OUTPUT PIN #3   Output Heater PWM
  analogWrite(3, PWM3);
  // PWM values are between 0 and 255



  //  BLINKING LED STATUS DISPLAY
  // The following is not necessary but provides useful visual information on how the program is running
  // One blink indicates program is running. Up to 8 additional blinks indicates drive level.
  // blinktime counts the number of program loops

  // FIRST BLINK - JUST TO SHOW THAT THE PROGRAM RUNNING
  if (blinktime == 2)  digitalWrite(13, 1);                 // pin #13 is the on board LED, 1 is ON
  if (blinktime == 3) digitalWrite(13, 0);                 // turn off LED = 0
  // turns the LED off so it blinks

  // PWM STATUS OF POWER LEVEL more blinks higher level
  // SECOND BLINK - IF DRIVE GREATER THAN
  if (blinktime == 6 && PWM3 >= 30) digitalWrite(13, 1);
  if (blinktime == 7) digitalWrite(13, 0);                // sets the LED off so it blinks

  // THIRD BLINK - IF DRIVE GREATER THAN 60
  if (blinktime == 9 && PWM3 >= 60) digitalWrite(13, 1);
  if (blinktime == 10) digitalWrite(13, 0);

  // FOURTH BLINK - IF DRIVE GREATER THAN 90
  if (blinktime == 12 && PWM3 >= 90) digitalWrite(13, 1);
  if (blinktime == 13) digitalWrite(13, 0);

  // FIFTH BLINK - IF DRIVE GREATER THAN 120
  if (blinktime == 15 && PWM3 >= 120) digitalWrite(13, 1);
  if (blinktime == 16) digitalWrite(13, 0);

  // SIXTH BLINK - IF DRIVE GREATER THAN 150
  if (blinktime == 18 && PWM3 >= 150) digitalWrite(13, 1);
  if (blinktime == 19) digitalWrite(13, 0);

  // SEVENTH BLINK - IF DRIVE GREATER THAN 180
  if (blinktime == 21 && PWM3 >= 180) digitalWrite(13, 1);
  if (blinktime == 22) digitalWrite(13, 0);

  // EIGHTH BLINK - IF DRIVE GREATER THAN 210
  if (blinktime == 23 && PWM3 >= 210) digitalWrite(13, 1);
  if (blinktime == 24) digitalWrite(13, 0);

  // NINTH BLINK - IF DRIVE GREATER THAN 240
  if (blinktime == 26 && PWM3 >= 240) digitalWrite(13, 1);
  if (blinktime == 27) digitalWrite(13, 0);

  // A single blink indicates processor is running but no heating



  // PROGRAM DATA SENT TO ARDUINO SERIAL SCREEN IN TOOLS
  // send calculated voltage to TOOLS debug screen. This will give a real
  // time read of voltage. A pot can be adjusted matching the computer value
  // to the digital voltmeter.
  if (blinktime == 100) {
    Serial.print((float)panel / 10);          // print actual panel voltage
    // float formats to two decimal places
    Serial.print(" voltage is ");              // identify variable
    Serial.print(panel * 32);                 // print voltage raw data X 32
    // will need to be adjusted for other panels
    Serial.print("  raw A/D is ");            // identify variable
    Serial.print(panel);                      // print raw voltage A/D variable
    Serial.print("  the count is ");          // identify variable
    Serial.print(PWMcount);                   // print PWM counter value
    Serial.print("  PWM3 is ");               // identify variable
    Serial.print(PWM3);                      // print PWM output value and do line feed
    Serial.print("  ");                       // create space between last data
    Serial.print(PWM3 * 100 / 255);          //print percentage output value
    Serial.print("% power");                 // identify variable do line feed
    Serial.print("  ");                      // create space between last data
    Serial.print(power32/32);              // print out power reduced by 32
    Serial.print(" W ");                       // identify variable do line feed
    Serial.print("  ");                       // create space between last data
    Serial.print("V1.0  ");                   // current version
    maxpower = (panel / 10) * (panel / 93);
    power32 = maxpower * (PWM3 * 32/255);
    meter = map(DAILY,0,9180,0,255);        //Maximum PWM = 255 x 6 readings a hour = 1530
   // counts, 1530 counts/hr x 6 hours = 9180 counts.
                    // Wattage at maximum set voltage = 820 W x 6 hours = 4.92KWH
   
    panelrndup = panel + 6;          //add 6 so division rounds up
    // remainders 4 and over and rounds
    // down remainders below 4
    // maxpower=(panelrndup/10)*9(panelrndup/93);

   








  }

  delay (50);                               // once per loop delay
  blinktime = blinktime + 1;                // LOOP COUNTER
  if (blinktime > 100) blinktime = 0;       // reset the counter


}                                            // end of program



OperaHouse

  • Hero Member
  • *****
  • Posts: 1308
  • Country: us
Re: Control for heating with solar off grid no batteries
« Reply #63 on: September 28, 2016, 10:20:04 AM »
I see that something was lost in translation.  it should read:

 //  READ ANALOG VALUE AT PIN A0
  rawdata = analogRead(0);
  // A/D values go from 0 to 1023

In the beginning we were just reading the A/D value and using a single reading to represent panel voltage.  That A/D reading was multiplied by 32 to get a panel voltage.  That worked in my system which was 36V. I didn't know what your system was at that time. Panel now becomes rawdata in the read statement.  Later it seemed convenient to take two readings and add them together.  This provided some averaging to make the number more stable.  The rawdata number should be in the 600-700 range.  Conveniently, doubling that becomes 1200 - 1400.  That looks like 120-140V if you then divide by 10.  In your code rawdata was always zero and nothing was ever added in.

   Serial.print(" voltage is ");             // identify variable
    Serial.print((float)panel  / 10);      // print voltage / 10 (float) will read out two decimal places
                                                       // will need to be adjusted for other panels
    Serial.print("  raw A/D is ");           // identify variable
    Serial.print(rawdata);                    // print raw voltage A/D variable

Now panel is divided by 10.  Adding (float) to the statement prints a two decimal place  number even though the last place will always be a zero because you are dividing by 10. 

I haven't looked further.  You will still need to adjust the voltage divider so you get an appropriate voltage.  The debug screen should now start giving you some data.  Sorry I went a little fast, but you don't learn anything if everything works the first time.

right now the setpoint voltage is set to 109.2 volts.   This was just an example.  Haven't calculated it but your voltage will probably be about 130V or 1300 for a setpoint.  I talked about using a second pot and reading that to have an adjustable setpoint.  For now change this number to 1300.

int setpoint  = 1092;         // power point raw data count, set for power point
« Last Edit: September 28, 2016, 10:28:37 AM by OperaHouse »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #64 on: September 28, 2016, 04:57:49 PM »
  When I changed the code  the debug screen is now giving data.  Was great to see that
happen. I will go ahead and make the changes you mentioned.
   Thanks





« Last Edit: September 29, 2016, 08:36:03 AM by Bruce S »

ontfarmer

  • Full Member
  • ***
  • Posts: 198
  • Country: ca
Re: Control for heating with solar off grid no batteries
« Reply #65 on: September 29, 2016, 08:30:22 AM »
The data is now printing out on the serial screen.  I made the changes you mentioned. The
 detailed information you gave made it easier for me to follow.  I'm going to go back over the posts to try and understand and check that I have not missed things.
Thanks