Fieldlines.com: The Otherpower discussion board

Microcontrollers => Microcontrollers/General => Topic started by: ontfarmer on July 10, 2016, 05:59:37 PM

Title: Control for heating with solar off grid no batteries
Post by: ontfarmer on July 10, 2016, 05:59:37 PM
Put up solar panels with heating water planned. I have had a lot of help from the members
of the forum.
Planning on putting the controller together have capacitors, mosfets, opto isolater,resistors,
diodes, arduino.  to use for PWM control.
Will let you know how it goes.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on July 13, 2016, 09:29:01 AM
Where to start......
The voltage of the solar array will have to be monitored.  Here is a way to easily calculate
the values for the voltage divider.  Determine the maximum voltage the divider will see using
the total open circuit voltage of the panels.  Lets say that is 140V.  Choose a common resistor
value for the lower resistor R2 of 22K.  The A/D value can be easily multiplied in the micro
by a whole number, avoid floating point math in a micro.  That calculation can get you close.
Adding a pot between R1 & R2 will allow you to adjust the A/D value slightly to get the calculated
voltage spot on. If you only have a 25,50 or 100K pot, a 5K or higher resistor in parallel can
reduce the effective resistance to 5K.  With the pot set to mid position, that adds 2.5K to the
value of R2 for a total of 24.5K ohms.  We are setting the max value the A/D will see at 4V to
give some safety margin.  There are 35 four volts in 140V.  One of those 4V is across R2.  That
leaves 34 four volts on R1.  24.5K times 34 gives 833K for R1.  A standard value for R1 is 820K.
I suggest a couple resistors in series to prevent flash over or a single 1W resistor. A capacitor
of .1uF at the A/D input provides noise protection and a stable low impedance for the A/D converter.


If you have at least a 36V array, the best way to power the micro is with electronic wall warts.
The most common is the 5V used for cell phones. I have a local thrift store that sells them for
29 cents each.  I use them all over my system to power meters.  They are electrically isolated
and if they fail they won't destroy your electronics like non isolated step down converters.  I
love those $2 ebay 2596 converters but won't use them anywhere near their voltage or current
ratings. Two 5V wall warts can be used in series to make 10V to supply the UNO board. An additional
5V unit in series will supply 15V for the FET driver electronics.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on July 17, 2016, 08:32:27 AM
   The wheat harvest is now done. Hope to get back to this project.

Very impressed with the detailed  instructions and diagram that you done in terms
l can understand.
 
  Will make it possible for me to put this together.

Thanks

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on July 21, 2016, 09:31:33 AM
The schematic shows how to connect three 5V electronic wall warts.  It is a good idea to add an
extra capacitor for surge capacity and maintain voltage during momentary dropouts. It is suggested
tat a diode be used ot isolate the solar panels from the capacitor bank to prevent current back
flow. Use a diode for each series string prevents back feed form other panel strings and allows
you to use smaller cheaper diodes.  Remember that once the capacitor bank voltage drops below
the set point of the micro, the current draw stops except for the bleed resistor on the capacitor
bank.  Even new capacitors will need some forming before rated currents are drawn.  VFD motor drive
instructions suggest that the unit be powered up for 24 hours before the motor is operated.  This
would be a good idea for this capacitor bank too.  Use the array to power it for a day or power up
with line voltage.

A convenient way to get signals in and out of the board is with these Dupont leads. 
http://www.ebay.com/itm/40PCS-Dupont-Wire-Color-Jumper-Cable-2-54mm-1P-1P-Male-to-Female-20cm-WC-/172024782427?hash=item280d79de5b

Buying the male and female leads allows me to cut them in half and also use them with pin headers.  Following resistor number color codes for the wires makes it easy to identify input and outputs, input1 would be a brown wire.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on July 25, 2016, 05:21:42 AM
Picked up resistors, pot, capacitors, diodes, soldered them together I have  male and female leads.

Was  able to get old TV, PC from a drop off have to get the 5 volt wall warts.

Look forward to your reply.











Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on July 25, 2016, 08:07:51 AM
This general post I had ready.  Will PM you some working software to get you started.  Sent, let me know if you got it.

One thing you will likely want to do is some data logging.  There is no need for added displays.In the Arduino software there is a TOOLS page.  Just select Serial Monitor and you can read out any data stored in active memory through the USB port onto your laptop.  In your software just use the print functions for data and to format the screen with labels.  This is not permanent memory as it will be lost when power is removed.  It is also erased every time the USB port is plugged in as that automatically sends a RESET to the micro. That problem can be worked around by putting an electrolytic capacitor from the RESET (+ of capacitor) to the GND pin of the micro.  I use a 100uF, but it probably works with a 4.7uF.  This works with all the variations of this board.  The photo shows this capacitor along with the Dupont pins and resistor leads making connections to the board. 

A power meter can be easily included in the software. In many cases the voltage will be fixed.  Since the resistance doesn't change, the power is proportional to the PWM number sent to the FET driver.   Feeding that through a 4.7K resistor to a 10uF capacitor will give a proportional voltage of 0-5V of the PWM. There are many small LED meters that can be purchased on ebay for under $2. Make sure the meter has at least two decimal places. A pot can be used to cal in the meter.  Choose at least 100K pot  to put as little loading on the capacitor as possible. Multiple data values can be displayed using a LED to identify what units they are such as peak wattage.
 
This averaging method can also be done across the heater element and it will read out the actual average heater voltage. Adjusting the voltage sense pot for the maximum voltage is the best way to determine the power point voltage.

Mounting the UNO can be a problem. Some have three mounting holes, some have none. Clearance is very tight and you are likely to short out or damage the board with metal hardware .  I have always used a slice of dense packing foam and just hot melt it to a surface. There are snap in mounts for the UNO that cost more than the board.  Go cheap and easy. 

The software isn't hard to calculate daily power.  Just add the PWM value every six minutes to the DAILY variable.  Over a day that number will likely stay under 16K The UNO has a convenient MAP function that will do the conversion for you into a 0-255 value that the PWM port can take.

               meter = map(DAILY, 0, 9180, 0, 255);

Maximum PWM = 255,  255 X 6 readings a hour = 1530 counts, 1530 counts/hr X 6 hours = 9180 counts

This falls well under the 16K limit. If you expect power to be lower, you could double the number of readings each hour.  Just choose some number of hours that will give you a realistic value for the day.  Use the power point voltage the capacitor bank runs at to obtain the maximum wattage
that could be obtained from the heater at 100% duty cycle.

Wattage at maximum set voltage = 820W X 6 hours = 4.92KWH

The maximum voltage out for the PWM is almost 5V averaged. This matches up closely with the values in the example.  0-2V, 0-3V, 0-10V and 0-20V meters are common. A resistor voltage divider can be used then to obtain voltages under 5V.  Values over 5V (5KWH) can't be obtained unless an op amp is used to multiply the voltage.





Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on July 27, 2016, 02:04:44 PM
Couldn't find a way to load the sketch file directly into the PM. You will have to copy it
into a new sketch.  The email word processor sorta clobbers it a bit with some comments ending
up on a new line. The compiling will stop at those lines as an error. Initial software can be
tested by connecting the pot to the 3.3V pin of the micro.  The transition from counting up to
counting down will probably happen with A0 at 3.0-3.1 volts at the input.  The Serial screen
in TOOLS will display the raw count and the number sent to the PWM.  The counting is slowed
down on purpose.  You will see at the two extremes the count will vary from PWM output.  This is
to prevent narrow pulses that would only result in FET heating.

The analog voltage signal is pin A0 and the PWM signal to drive the opto isolator is pin 3. The
opto isolator provides a simple way to do voltage level shifting  and isolation.  A blown FET
can never destroy the micro and the FET and capacitor bank can be as close to the heating as
possible with the controller being 100 feet away. A LED is in series with the drive and
provides an indication of drive being present. If you have 13.5 or 15V there will still be
enough voltage after subtracting the LED voltage to drive the FET.  Opto isolators are slow but
fast enough at 490Hz. The waveforms I have observed are quite clean.  The slow transition pretty
much eliminates inductive problems. I have no heating problems at 52V and doubt your supply at
over 100V will either. What FET did you choose?  A 10-20 ohm gate resistor is optional when
using multiple FET. Most often when a FET fails the Gate will short out.  This makes it easier
to figure out which FET is shorted as the bad one will have the lowest resistance to common.
I don't use them as the system already has enough resistance in it. I use a RC snubber across
the FET to eliminate any possible noise.  Your PC power supply will have at least two of these
on the AC coming in.  These X rated capacitors are suitable for the continuous surges.  Use a
15-47 1W power resistor in series.  Capacitor value is not that critical.

The first testing of the drive should be done with only one bank of capacitors and one or two
100W light bulbs. This will keep you out of extreme current conditions that might destroy things.
Available current from solar panels quickly drops off as you approach maximum panel voltage.
There will likely be enough range in the adjustment pot to hit maximum voltage and operate the
PWM mid level with just a single lamp.  If not reduce the number of panel strings connected for
the test.   The on board LED (Pin 13) will flash according to power level.  There is always a
single flash to indicate the program is working.  Then it will flash up to eight times (I think)
to indicate power level before a pause.  The TX and RX LED will flash as data is sent to the
laptop when connected.  If that all works, the other capacitor banks can be connected.  These
will be lethal voltages so wait for the voltage to drop with a voltmeter before connecting.
Breakers or light switches can be used as disconnects.  While not rated for DC, when turned off
the voltage potential across the contacts from the capacitor bank will not be that great.




Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on July 27, 2016, 06:59:00 PM
Just got in been a busy day. Hope to work on this tomorrow. The 3 FET I got is IRFP250NPBF
 200V  30A    Phototransitors  60Ma  30V    The ones out of old TV RF 2001 200V  20A

Thanks for the details. I will send PM to you.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 04, 2016, 07:14:01 AM
Done the sketch for arduino followed the information you send me, having a lot of problems.

Stray 302 in program? error expected ')' before '==' token?  'serial' does not name type?

Could use some guidance, seem to be doing every thing wrong.

Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 04, 2016, 11:45:39 AM
That code compiles without error, I just tried it again.  When I copy it into PM or here, the word processor clobbers it.  Long lines are terminated and placed in a new line.  This is likely your problem.  Normally I suggest writing a little code, like adding onto blink, to get a feel for hoe things are ordered.

Check every line:
// are comments and ignored everything else is code.  If it reads like English, it belongs on the end of the previous line. Back it up or put a // in front of it.

Each line should begin with an if, print, void, or int.  A bracket is also ok.

Variable names followed by an = are ok.

Lines starting with a tinted word are likely ok.

Display will stop at the first error.  The error is usually the line before.

click on HELP then REFERENCE.  Every line that doesn't start with a // should follow the listed format.
time to learn a little code.  It is trial by fire.  If you don't understand it, you can't modify it later to suit your needs.  If all else fails, copy a few lines where it stops and post them here.  The problem is simply how it was copied.

When I sent you that code in a PM I went into sent messages to see what the editor had done with it.  There were no listings for any of the messages I have sent.  If they were there I could probably tell you the problem.  If you don't figure it out, send it back to me.


Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 05, 2016, 05:48:28 AM
This is what I  have done and getting an error;
int panel = 0;
int setpoint = 546;
int blinktime = 0;
int PWMcount =0;
int PWM3 =0;



void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
 
  pinMode(10,OUTPUT);
  pinMode(3,OUTPUT);
}

 

void loop() {
panel = analogRead(0)
(panel > setpoint + 25)PWMcount = PWMcont + 1;
(panel < setpoint - 25)PWMcount = PWMcount - 1;
(panel > setpoint - 2)PWMcount = PWMcount - 1;
(PWMcount > = 255)PWMcount = 255;
(PWMcount < =0)PWMcount = 0;
PWM3 = PWMcount;
PWM3 > = 250)PWM3 = 255;
Pwm3 < = 5)PWM3 = 0;
 digitalWrite(10, 1);
 delayMicroseconds(100);
 digitalWrite(10, 0);
 delayMicroseconds(500);
 analogWrite(3,PWM3);
 (blinktime == 2) digitalWrite(13, 1);
 (blinktime == 3) digitalWrite(13, 0);
 (blinktime == 6 && PWM > = 30)digitalWrite(13, 1);
 (blinktime == 7)digtalWrite(13, 0);
 (blinktime == 9 && PWM3 >= 60)digitalWrite(13, 1);
 (blinktime == 10)digitalWrite(13, 0);
 (blinktime == 12 && PWM3 >= 90)digitalWrite)13, 1);
 (blinktime == 13 )digitalWrite(13, 0);
 (blinktime == 15 && PWM3 >= 120)gigitalWrite(13, 1);
 (blinktime == 16)digitalWrite(13, 0);
 (blinktime == 18 && PWM3 >=150digitalWrite(13, 1);
 (blinktime == 19)digitalWrite(13, 0);
 (blinktime == 21 && PWM3 >=180)digital(13, 1);
 (blinktime == 22)digitalWrite(13, 1);
 (blinktime  == 23 && PWM3 >= 210)digitalWrite(13, 1);
 (blinktime == 24)digitalWrite(13, 0);
 (binktime == 26 && PWM3 >= 240)digitalWrite(13, 1);
 (blinktime == 27)digitalWrite(13, 0);
 Serial.print("voltage is");
 Serial.print(panel*32);
 Serial.print("raw A/D is");
 Serial.print(panel);
 Serial.print("the count is");
 Serial.print(PWMcount);
 Serial.print.("PWM3 is");
 Serial.printin(PWM3);
 delay(50);
 blinktime=blinktime + 1;
(blinktime > 100)blinktime=0;
 // put your main code here, to run re
}
     

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 05, 2016, 06:34:29 AM
You must have copied this over by hand.  There were things misspelled, missing ; missing all the if.  Spacing is also an issue.  Sometimes you left it out, sometimes added in.  >= is a function > = is not.
Replace what you have with this and you will get farther.

panel = analogRead(0);
if (panel > setpoint + 25) PWMcount = PWMcount + 1;
if (panel < setpoint - 25) PWMcount = PWMcount - 1;
if (panel > setpoint - 2) PWMcount = PWMcount - 1;
if (PWMcount >= 255) PWMcount = 255;
if (PWMcount <= 0) PWMcount = 0;
PWM3 = PWMcount;
if (PWM3 >= 250) PWM3 = 255;
if (PWM3 <= 5) PWM3 = 0;

Almost every line had a mistake.  They can be hard to see first off.  Things like gigitalWrite, printin, an extra . and binktime.  gigitalWrite is likely too big for a micro! Comments in the code will help you a lot later.  I've corrected the errors and it does run.  Just go one line at a time.  By the end, the lesson will be learned.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 05, 2016, 06:56:36 AM
This is what I received. Thanks I will try again, copying by hand is the only way I know.

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 panel     = 0;           // calculated panel voltage in mv
int setpoint  = 546;         // 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

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
   
   
    // 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 >= 250) 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("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.println(PWM3);                     // print PWM output value and do line feed
    }
   
    delay (50);                               // once per loop delay
    blinktime = blinktime + 1;                // LOOP COUNTER
    if (blinktime > 100) blinktime = 0;       // reset the counter
   
   
 }                                            // end of program





Report To Admin







Pages: [1]
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 05, 2016, 07:32:32 AM
Just learned how to copy and paste.  Error code  type ?

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 panel     = 0;           // calculated panel voltage in mv
int setpoint  = 546;         // 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

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
   
   
    // 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 >= 250) 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("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.println(PWM3);                     // print PWM output value and do line feed
    }
   
    delay (50);                               // once per loop delay
    blinktime = blinktime + 1;                // LOOP COUNTER
    if (blinktime > 100) blinktime = 0;       // reset the counter
   
   
 }                                            // end of program







Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 05, 2016, 08:00:18 AM
It may stop at the first line if // was not copied.


This is a simple pwm driver to keep solar panel voltage
// at power point and prevent short pulses. A blinking LED

Editing the old code to get it to work would be good practice for learning to find errors.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 05, 2016, 08:19:48 AM
Thanks I will spend time on that to learn.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 05, 2016, 03:27:00 PM
Once you have that working and are more comfortable,it will be time to modify the code
to more suit your application.  The A/D converter has a range of 0-1023. As I said before
the typical A/D value we are shooting for is between 500 and 700. With your panel string
being about 100V for the power point, a simple multiplier of two would give an nice
number down to a tenth of a volt. 1132 would be 113.2 volts. It would be even nicer if
that number was averaged.  This routine does that.  The divisor becomes the multiplier.
In reality with the number of bits used it is only accurate to the quarter volt.  This
code should be placed after the A/D read statement.



// 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 this 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.



A new variable has to be added, rawdata, to the program.

int rawdata = 0     // raw A/D panel value

And in that declared variable section the setpoint value now has to be doubled.

This has to be placed up where the other variables are declared and the panel
variable in the analogRead statement has to be replaced with rawdata.  Near the end
of the program in the print statement where the panel variable is multiplied, that
* 32 multiplier is deleted.  panel variable is read out directly.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 05, 2016, 07:10:05 PM
You may not think it from your first experience, but the compiler is very helpful in
finding errors in your code.  It stops at the first statement it has trouble with. The
problem may be in that line or a couple of lines before. It might even be at the beginning
of the program where everything is declared.  You made about all of the common mistakes.
I make the same ones. Your mind is set up to speed read and it quickly ignores things that
are a litttle off like spelling.  The compiler is unforgiving with that.  Brackets are
another issue.  Each one has to have a mate.  If you click on the first one, the compiler
will put a box around the closing one.  I use copy and paste to save a lot of typing. That
can be deadly as yo can miss a beginning or end piece of a statement.  It is pretty easy
to forget to change a variable in a snippet of code.  Operations like if, print, digitalRead,
etc. are highlighted in color.  If you type digitalread it won't be highlighted. I haven't
given you everything at once.  I want you to understand the code so you can comfortably modify
the code as you understand your unique operating situation.  It is a good idea to have every
line of code stand on its own instead of nesting one routine instead of another.  It is much
easier to debug if a problem arises. 

The SERIAL screen in TOOLS allows you to write out the variables as the program progresses.
Sometimes your thought process is a little off and you count 11 times instead of 10.  Or
maybe you don't count at all.  Pin 13 controls the on board LED.  Always have some routine
that flashes the LED every so many loops of the program.  Nothing worse than looking at a
micro and wondering what it is doing.  Be aware that printing to a screen in TOOLS really
slows doen a program.  It helps to do that every so many loops.  It doesn't help to have
data flying past you faster than you can see.  That SERIAL screen can hold a lot of data.
You can always use the cursor to go back and see how things progress. In most situations
there needs to be a delay in the program. The standard PWM of the UNO is 490Hz. It wouldn't
be good to be updating it all the time.  Try to understand how the loop counters work in
the program.  It is a good way to sequence things in the program like blinking a LED or
reading data.

When you get some code that is working, even if not a full implementation, save it with a
version number after the name.  Also note in the header the last date it was modified
and what changes were made.  That gives you something to go back to when the code really
goes south.  Note what in the code was changed in the header.  I don't always do it, but
I do wish I had when I start looking at multiple versions.  Use lots of comments to explain
what is happening in the code.  Six months from now you will be trying to figure out what is
happening and what variables mean.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 06, 2016, 05:48:30 AM
Spent time checking code corrected a few things you pointed out. What a good feeling that it complies.
It took hours for me to hand type. If my wife was here she would of done it correct in a few
minutes, lost here a couple years ago.
I will keep you updated.

Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: DamonHD on August 06, 2016, 07:26:37 AM
What OperaHouse says about keeping versioned copies and good comments is excellent practice.

Rgds

Damon
Title: Re: Control for heating with solar off grid no batteries
Post by: Mary B on August 06, 2016, 02:54:30 PM
I remember trouble shooting 10,000+ lines of code for a trucking company. Compiler wasn't helping find the error so I had to sit down and go through the program line by line. Second tie through I found a missing .
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 06, 2016, 05:53:34 PM
That makes what I done seem very small. Great hearing from you, thanks for the warning about the capacitors.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 07, 2016, 07:59:01 AM
Now that you have been able to compile the progrm, have you tried loading it into the UNO?
Connect the 3V3 pin to the A0 analog input pin through a 100K to 400K resistor. The USB
cable from your computer will supply power to the board without using any external power.
Click on TOOLS and select SERIAL. The screen will appear and data will start to appear
every thirty seconds or so.  My screen will be a little different since making changes.
The 3V3 pin connected to A0 give a raw A/D count of about 657 to simulate panel voltage.
That will be doubled and give a panel count of about 1314, representing 131.4 volts.
Now touch one finger to the resistor lead on A0 and eith the other hand touch the metal
connector body.  The panel voltage will drop as this places a load on the resistor. Remove
your finger and the voltage will climb up again. When the panel number is above the setpoint
the PWM will count up.  When the panel number is below that the PWM will count down. This
will happen very quickly.  The PWM can change more than 80 counts for each time SERIAL
data can be printed to the screen. This

If things don't happen as expected.  Hit the RESET button on the board.         

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 07, 2016, 12:54:44 PM
Did I tell you testing was important and cut and paste was dangerous?  Finally got around
to actually testing in detail.  I was checking out a thermal tracking circuit using diodes.
Noticed that it took a bigger differential with panel and setpoint than I was expecting.
In the up down counting routine that adds or subtracts 1 is reversed.  Anyone can make
mistakes in logic.  TEST, TEST, TEST. It should read:

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

The power point of solar panels changes with temperature.  Mornings are cooler, winter is
colder.  Solar panels are just a bunch of diodes.  In this circuit I have 6 forward biased
diodes in series.  This produces about 3.5 volts.  Lower temperature produces a higher
reference voltage.  A 1K to 2K resistor produces a couple ma of current through the diodes.
If the total loading on the diodes is greater than 200K it will track pretty well. A 20-50K
and 150K resistor would give a nice adjustable range.  But all that for later.  Correct the
code in your program.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 08, 2016, 10:02:08 AM

See, you're getting used to it.  I've made some more changes to the program.  These will
make it functionally easier to set up.  The pot that reads the panel voltage will be
adjusted so that the voltage on the SERIAL screen matches your DVM reading of the capacitor
bank.  Now that that adjustment is set, there needs to be a way to change the setpoint
voltage. A second pot is added to the system to change the setpoint. Each end of the pot
is connected to GND and +5V, the wiper is connected to A1 of the uno. This will allow
a new variable, pot, to range from 0-1023.  The variable setpoint has to go higher than
that so the variable pot will be doubled just like we did with panel. The variable pot
will have to be declared.  The A/D routine and multiplier can be copied and the variable
names changed.

A word of caution.  The worst thing that can happen is to lose the ground connection to
the board.  There are three ground pins and I suggest they ALL be connected to the external
common.  If you have access to the power plugs common, I suggest you connect to that too.
This will be the best protection for the board.  The GND pins are next to other supply
voltages.  Tripple check before applying power so it doesn't short out those.

Add the setpoint reading to the print section.  As the line may be getting a little long,
the other identifiers could be shortened by using an = instead of "is" and eliminating a
space.  Everything in blue including spaces is literally printed as you see it.

I thought the blinking was a little less than pleasing.  All the blinks I made one count
long.  After the first blink, the one that indicates the program is running, I waited 13
counts.  Then between each blink after that I waited 5 counts.

I made the program loop run a little faster.  The loop counter now resets after 80 counts
instead of 100.  You will have to make sure the print routine still works.

I'm not trying to be mean.  There is a purpose to all this. I want you to gain a familiarity
with the system so you will be comfortable with it and be able to make changes that suit
your circumstance.  Hopefully you will be able to see other applications to use this board
on.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 08, 2016, 05:08:34 PM
I uploaded the uno and the tx and the light started blinking. Connected 3.3 pin and Ao pin
tried what you said but must of done something wrong.

The panel is 124 open volt, raw A/D count 689  Hooked up Opto and FET surprised when I
plugged in the drill and it worked!!   A/D count dropped about twenty points.

Corrected the mistake you mentioned.  Very fortunate for what I have learnt from you but
 a long way too go.  Getting a little familiar will some terms.

I will need a couple days to get things under control.

Already have new projects planned with the UNO when this one is finished. Will get the
 attention of some of the "smart" people.

  Thanks

                     









Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 08, 2016, 05:13:40 PM
May not pass code?
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 09, 2016, 05:31:41 AM
I will pickup a pot  for the board.  Is plugging into the three ground pins  and joining them to the neutral on the bottom side of the power plug what you mean or should the ground pins be soldered also?

Not quite sure of the wording for declaring the pot? The blinking is fast but it will be sorted out.

Taking this as educational not of being mean.

Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 09, 2016, 07:59:19 AM
I see that you have compiled it and are getting serial data out. That's 80% of the effort.
That version I sent you was saved more than a year ago.  I chose it because it didn't have
a lot of extraneous stuff in it. Obviously later versions were corrected. Now we are adding
most of it back in.  All variables have to be declared at the beginning.  int indicates it
is a standard integer and you assign an initial value to it. Integers an be up to + or -
32K. Remember that that when the variable will be multiplied.  The format is as follows.

int pot       = 0;           // raw A/D pot voltage

The semi colon (;) indicates the end of every statement.  Math follows the MiDAS rule in an
equation.Multiplication is done first, then division, adding and last subtracting unless
parentheses are used. Look in the case of calculating PW percentage.  (you should add this)

    Serial.print("    ");                        // create space between last data
    Serial.print(PWM3 * 100 / 255);     // print percentage output value
    Serial.println("% power");              // identify variable and do line feed
   
This will give values between 0-100.  If the following was done.

  ((PWM3/255) * 100) The only two answers would be 0 and 100. 

That is integer math, a calculator wouldn't care.  Note the println at the end. That creates
a carriage return at the end.  You are old enough to remember a typewriter.  If you don't
remove the ln from the previous print statement, the % printing will be on a separate line.
The ("    ") creates a space.  Otherwise the two numbers would run together.

I also changed the code to the following.

    Serial.print("voltage is ");              // identify variable
    Serial.print((float)panel / 10);        // print actual panel voltage
                                                     // float formats to two decimal places

(float) changes the printing format to two decimal places, so what is displayed is 124.30 
instead of 1243.  The math is still integer so it is faster. This can also be done to setpoint.

I take the simplistic form of code to display on this site.  I add spaces for readability and
don't use shortcuts like ++ to increment up.  This helps it look more like English and not so
intimidating.  If you keep this format it will be easier to understand when it is looked at a
year later.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 09, 2016, 09:49:52 AM
Back to hardware.  No need to solder the grounds.  It is just good to have multiple sources
of contact in case one gets pulled out by accident.  Also gold isn't being used as much and
humidity over time can cause corrosion on tin contacts.

The tracking circuit is quite simple.  It is six diodes in series. That number will give a
reasonable voltage change.  The diodes can be potted in epoxy or some heat shrink tubing.
For heat shrink, I apply some hot melt glue the length of the diode string and let it cool
before inserting into the shrink.  Then it all melts together when heated and forms an
environmental seal. I understand the reluctance to attach anything to the panel itself.
Just placing it in the junction box as close to the panel as possible will work. There will
be a thermal delay but should work well.  If there is a long wire run, just putting the
diodes on a black aluminum plate at the house should work. It should face the same direction
as the panels.

The diodes closely match the thermal properties of the panel, as temperature goes down the
voltage goes up.  The voltage power point of the panels is usually rated at 25C. I blame
Jimmy Carter that I can't think in terms of C. It has to be a pretty cold day for the panels
to be that temperature at mid day.  For most of us the power point voltage will be lower.
The power point voltage is still a good number to work with.

The diode string is powered from the +5V of the board through a 1.2K resistor. This gives
the diodes a couple of ma of forward bias.  Any general purpose silicon diode can be used.
I have used 1N4148 and 1N4002 types  The forward voltage will be about 3.6 volts. A voltage
divider across this diode string will allow us to dial in the setpoint for the panels. The
voltage divider should be at least 200K total, including the pot, to keep the loading minimal.
The Wiper signal is filtered by a .1uF capacitor or larger which provides a low impedance
for the A/D converter input A1.  A 20K pot will give about a 5% adjustment from midpoint.
With a linear pot, the midpoint resistance to each end will be half.  Volume control pots
will not be equal resistance to both ends.  They can still be used but the adjustment will
be touchy. With the adjustment pot set midway, a second pot can be used to find the
resistance value or just have on hand a lot of resistors.  The ideal power point will be
when the maximum average voltage is found on the heater.  That resistor capacitor method
was explained earlier.  If the PWM goes up to 255 or 100%, the panels have more power
than the heaters can take.

Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on August 09, 2016, 10:21:34 AM
OperaHouse;
I keep following these posts. The amount of knowledge you put out is phenomenal.
I do have to 2nd your point about making it readable.
I have from my Basic and ABasic days; made notes to what I did and why.
To this very week they still come in handy.

Keep it up!! and THANK YOU!!

Bruce S
PS>>> I was going to make mention of not connecting all the ground points together, but I see you have addressed that already.
Cheers
 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 09, 2016, 12:59:10 PM
There is so much that you can do with these, I don't know why there are not articles here
all the time. You don't have to get into complicated code, only yes/no decisions. At $6 it
isn't a big risk. 

I have a pump that is scheduled to go on 10 times a day for a certain period. When it reaches
that time it looks to see if the battery is fully charged.  If it is, the pump turns on.

Two batteries run my system.  One is the house battery, the other runs the refrigerator. House
battery disconnects at night, it reconnects when the refrigerator battery fully charges. That
battery connects and disconnects many times a day.  Just a few lines of code.  The mechanical
relay operates with PWM, high current to pull in and reduces to one quarter power shortly
after.  A big energy savings with larger relays.  I still like relays for durability.

Wrote this battery slump test.  We all have some load that is pretty uniform in current draw.
This routine records the lowest voltage.  It can set an alarm when things look strange. The
lowest voltage is recorded about one second after turn on. My fridge draws 120A at startup,
a nice battery test. That voltage is put on the battery with a sticker.  You can see which
battery is getting old or when there is a connection loose. Five data points are stored over
a few seconds besides the lowest voltage.  A nice window into what is happening.

They also make a nifty controller for small systems or a dump controller for water heating
operating externally of an existing controller.

It all sounds more exciting than it really is.  Most of the time I feel really embarrassed
when I see how little of the program memory was used.  If you can get past just loading in
a sample program like BLINK, you have it made. $6 seems like a small investment for this
much potential. Most of the programs start with a simple boilerplate routines organized in
a sketch. I copy that starter sketch. A/D read and averaging, input and output lines, screen
display, relay PWM, LED blink, defined variables and loop counter are all there.  I hate to
type and it is easy to forget the format for functions.  Copy and paste saves me all that
work. Click as many as you need and just change the variable names. Delete the stuff not
wanted.
Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on August 09, 2016, 03:08:28 PM
FIRST : To the OP! Apologies if this drifts too far.
BUT!! OH is making very good points and it is important even for old people like me to be reminded to not let the big picture get in the way of getting started.

OperaHouse;
The point I just made is very to the point. It was back in one of your other pgm sessions that I realized I was making it too hard. Was trying to thing of finding programs that were looking costly, then putting the whole idea on hold because of that.
ALL most of it took was looking / reading / remembering

Looking at your codes, looking at DamonHD's codes

RE-Reading up on simple basic commands

Remembering just how easy it was using the simple stuff like if/then statements.

I messaged your earlier  statement into a a simple air pump timer to run for my hydro-ponics setup.
TADA , now I have a cute hand-me-down HF panel that is used to charge a small bank of recycled 18650s and one of the cheapo USB charge controllers.
Now I have some kick-N peppers and cherry tomatoes that I don't have to fight 95F weather to keep hydrated.
ALL because someone reminded me of how easy this stuff can be.
Again THANK YOU!!


PS>> DamonHD's coding skills are still decades beyond me :-/

   
 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 10, 2016, 12: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: DamonHD on August 10, 2016, 01: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
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 11, 2016, 07: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 12, 2016, 07: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.
   
   
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 14, 2016, 11:25:28 AM
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.

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 14, 2016, 02: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 14, 2016, 04: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 15, 2016, 09: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.

Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 16, 2016, 11:27:03 AM
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.




Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 16, 2016, 02: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. 
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 24, 2016, 04:29:47 PM
 Have not heard anything.  Just checking how the trip was to the camp ?
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 24, 2016, 05: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 27, 2016, 10:32:11 AM
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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on August 27, 2016, 06: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on August 30, 2016, 10:33:25 AM
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.
   
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 01, 2016, 12: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 03, 2016, 11:56:58 AM
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
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 04, 2016, 11:24:37 AM
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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 08, 2016, 11:16:57 AM
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');
  }




Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 10, 2016, 05: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 11, 2016, 04: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?
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 13, 2016, 10:21:14 AM
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.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 17, 2016, 10:45:14 AM
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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 18, 2016, 09: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



Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 19, 2016, 09: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
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 19, 2016, 11:47:54 AM
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

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 19, 2016, 12: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.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 26, 2016, 06: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

Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 27, 2016, 10:25:52 AM
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.

Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 28, 2016, 04: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


Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 28, 2016, 08: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
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 28, 2016, 02: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





Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 29, 2016, 06: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
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 29, 2016, 01:01:32 PM
Did another quick look.

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

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


You started adding code for a second pot to adjust setpoint and stopped.

panelrndup was just placed randomly in the program.

Take a good look at the serial data display on screen and see if that is what you want.

I have downloaded your code and will see what it does.

Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on September 30, 2016, 06:21:24 AM
I changed the code that you mentioned to = 250 instead of = 255.  What else needs to be added to the code for the second pot to adjust set point ?  Where should I have entered  panelrndup   in the code ?

There has been very little sun here for several days, so have not got the normal print out on the serial screen.  They are forecasting sun in a few days.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on September 30, 2016, 09:30:48 AM
You have already declared pot as an integer.  Now you need to read the A/D converter. the process is the same as before.


//  READ ANALOG VALUE AT PIN A3, setpoint pot
pot = analogRead(3);
// A/D values go from 0 to 1023

setpoint = setpoint - setpoint / 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 pot data is added.

  setpoint = setpoint + pot;  // Add latest A/D reading to panel total.
                                          // This makes a running average.
                                          //  This will give a setpoint between 0 & 2,046
                                          //  or 0 & 204.60 volts.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on October 02, 2016, 05:04:01 AM
      I want to mention to the ones following this project how great it has been that 
 OperaHouse  is making this possible for me to have.

Changed the serial screen print out, it took me a few times trying before I got it figured out.
The order they are entered in Serial.print is what made the difference in printing out.

Entered    pot = analogRead(3);    setpoint = setpoint - setpoint/2;   setpoint = setpoint + pot;    to code where  rawdata = analogRead(0);   is.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on October 05, 2016, 01:17:46 PM
Didn't have the best day yesterday.  I was updating one of my buck converters that charges batteries.  Didn't work after the install.  Blew out a LED and shorted a FET.  Put the old system back.  Later I decided to perform at lest a partial upgrade.  Managed to blow out a wall wart.  Of course I do this all with the power on and bare wires dangling.  You get away with it most of the time.

I ran your program and the serial was a long run on sentence.  You have probably corrected that by now using a serial println at the end.  There is something that you should be aware of and that is printing takes time and it can seriously disrupt how the program operates.  Got around to doing some timing the other day.  My one minute had increased to 2.6 minutes.  That is the downside of doing loop counts.  The program had grown a little, but a lot of that time was the result of printing.  Now that you are a programmer, you don't have to be wordy like "the voltage is".  Programmers don't make things so that other people understand them.  Those screens will open up so that there are more characters on a line.  I prefer to not have to make a screen wider than standard.  To keep the speed up and the number of characters down use multiple debug screens.  Think I did a post on that.  That had some screen always active.  But, you have the option of having no screen except when asked for.  That can really speed things up. Not much of a problem at this stage.  Going back and reading those posts again is a good idea.  They will have more relevance now that you have some experience.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on October 10, 2016, 07:20:49 AM
Not had much time to spend  on this, very busy on the farm.  Going back over spending time reading the  posts again has helped me.  Not having previous experience with this and terms that are used, has at times been hard for me to understand.  I have learned a bit on the
programing,  added  println at the end of serial,  changed from  "  is "  to  = ,  shortened some other ones.  That made a big difference on the space that is used on the screen.  So
 far I  bring the screen up when wanted.  Tried moving  " meter = map(Daily,0,9180.0,255);"
up  to where the other ones are but keep getting  error codes  ? so it is still below serial.print.

Have had a lot of sun lately makes a big difference to the water that is getting heated.  When
things slow down a bit,  will have more time to work on this and hook up the other string of panels.
 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on October 13, 2016, 06:47:57 AM
I'm adding another screen command to my system, it does a power point test giving the power point voltage and maximum wattage at that moment.  It will be a good check of the condition of the panels.  Since my system doesn't track power point it will give me info as to how it changes through the season.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 03, 2016, 04:13:24 AM
Haven't had any time for a while to spend here.  OperaHouse how was your trip back from the camp ?  The landscape would be colour full at that time of year.  Read the post on controlling  multiple heaters with the uno.   I am going to try that when time permits.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on November 05, 2016, 11:47:46 PM
In grade school we had to take one of these personality tests to guide us into what
our occupation should be in the future. Personally, that is pretty young to be deciding
your future and the social sciences are just hokum anyway.  But, I always liked the result.
It said my professions should be: scientist, engineer, farmer. Some of my relatives out
in Iowa were farmers. Farmers are resilient and have faith in the future.  They have to
in order to put effort into crops not knowing what the yield will be and enduring many
bad years in a row. I have faith in you.  And if I have to drive up there with a basket
of parts to get it working, I will do that.  Been a few years since I've been in London.

You are literally at the point where you are forgetting faster than learning. I don't
remember where we are in this discussion. There is always five minutes in a day that
can be used.  I understand the hesitation.  My wife wanted a newer vehicle.  Four months
ago I bought her just what she wanted, a 2014 Explorer.  Since then she has driven it
only three times, less than two miles and only one way. Not like she isn't used to something
big, this is her fourth Explorer. Just buying this vehicle is a pretty convoluted story
in itself. I had new plates on the vehicle, a clear title and the guy is walking away
saying to enjoy it. I hadn't paid a dime at that point and that wasn't the weird part.  It
is different to drive, but not that much. She is now driving my old pickup which she
would never drive before and calling it hers.  Need to work on my wife's taxes tomorrow.  Been putting that off and they keep sending these nasty letters about taking her bank account.  Was
on the phone with them an hour and a half. She said my wife made a lot of money for not paying much tax.  One thing I've learned is tax laws follow no reason.  You just follow them where they
go.  Math is my stock and trade.  Then again it could have been lack of blood giving me a brain
cloud.

Not pushing you, just never know what will happen.  The doc is pushing me to get a pacemaker
just because my heart rate is under 40.  Haven't warmed up to the idea yet. In the literature
all the people pictured are old people.

Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 10, 2016, 05:53:09 AM
  This has been like learning to ride a bicycle,  you watch,  listen to instructions,  seems very
easy straight forward.  Then you take control and on your own,  unexpected things happen.
When you talk about tax laws and  following no reason,  some of this has been like that to me.
I am powering a baseboard heater for the present time.  Was going to try and add to code for controlling second heater.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 11, 2016, 07:02:20 AM
  The baseboard heater is 240 volt  750 watt so that is less than 200 watt of power.  Going to hookup a second one and try that. The days are getting shorter and the sun not very high
these days.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 15, 2016, 08:11:46 AM
  Have you got any interest in coming to the London ?  You mentioned being there in the past,  maybe there are things in the area you would like to see ?  It would be great to meet you, spend some time and show you some things around here.  The door would be open.
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on November 15, 2016, 08:45:31 AM

Is it at all possible to buy some sort of an external controller so one could use an old Windows laptop to do this sort of thing?

I get the power consumption would be a bit higher but all this programming stuff for these boards seems terribly critical.
I have also seen these micro windows computer boards that run windows. Forget the name now, think it starts with V and they are made in Israel.

It would seem using a PC direct would be much easier for twits like me,  but I'm not sure what you would call the part that you hooked things to for the control signals that interfaced with the laptop?


Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on November 15, 2016, 12:52:47 PM
When I started out eons ago it was a major hurdle just to get a compiler to run on a PC.  A PC just draws too much power, multiple voltages and interfacing issues.  The basic concept is simple, you could even use a GHURD controller if a capacitor bank is included.  One could even be made with a wall wart if they would have standardized with one part.  If you can load the Arduino compiler (FREE)  on your computer the other issues are minor.  For a $5 investment it is a lot of power.  I use the NANO version which is half that cost and has more capability.  Loading in the communication driver is a headache for the NANO.

I don't want to minimize anything.  There are a lot of ways you can get into trouble, but a lot of
non technical people have been successful with these projects. They can solve some really complex
problems cheap.  I just ordered another three of the $2.50 ones today. My whole camp runs on one,
fridge, two water heaters, pump, and two charge controllers and I still have some space left. This
year I finally added a test program to test the maximum power of the solar panels.  That answers the
question...Are the panels still good? These debug routins use the serial read screen in the Tools
section of the compiler.  The status of the house is from two blinking LED. One blink every ten
seconds tells me it is running and everything is OK. A lot of people want a big data solution with
tons of data on a screen. To me that is just RE porn. I don't want to be writing programs for people.
I am willing to help people get started.  If you can express what you would do if sitting there
flipping switches and turning a knob, you can program.  In my younger years I loved designing
circuits with a lot of pots to adjust.  Now I do everything with one of these boards in easily
changed software and add a half dozen parts.  Next year I need to do a video on the hot water
system. It sure beats the lame videos of people making hot water on youtube.
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on November 15, 2016, 06:21:03 PM
It sure beats the lame videos of people making hot water on youtube.

If I wasn't already in awe at your skills and appreciative of the help you give people which I greatly admire and learn from as well, You would have won me over for life with that statement alone.

What the FK is it with people and coiled copper tube??
Have they No clue at all whatsoever about surface area and heat transfer for a start and worked out that a 4" bit of pipe has so much more ability to absorb heat than the spread out bit of copper tube they throw on top of an open fire which is about 99% inefficient to start with?  Ugggh!  If I look at one more clown with coiled copper tube I'm going to throw up!

NO, that 10 Ft of 3/4 copper pipe thrown on on a fire is going to do jack all to heat your swimming pool. The losses from the inevitable above ground pool through the sides and evaporation alone are going to exceed the piddling about of heat you are putting in the thing which probably isn't even 1Kw. You'd be better off throwing an electric jug in there..... Or pumping the water through a car radiator with the electric fan going on a hot day to get a better heat rise in the water.

I have to get onto the seals I need so I can get the 200Kw heater I have converted from gas to waste oil going.  It will probably be about the 2nd heater on YT that will actually work!

Anyway.....

Perhaps you could help with a couple of other things?....

The base problem I have with these controllers is I don't even understand what they can do.  I recognise it is the same as asking what can you do with a computer but the fact is I am ignorant and really don't understand their capabilities or potential.  Do you know of any sites or white papers on  these things written for ignorant morons... IE, me, that could help me get the most fundamental and basic understanding?

Could you link to your supplier for the boards and do you have any recommendation of a startup kit that would be appropriate for the sort of use we would have for them?  I know they can control a heap of things but something relevant to this would be good and also something that could switch valves etc from temp inputs? Any other shields you could recommend for practical or training purposes?

Finally, are there any places on the web you can download simple programs to get one started with the idea and concept and could modify from there.
Forgive my ignorance if it is a stupid proposition but it would be great if there were programs written which one could basicly copy and paste and start from a known good base and work and modify from there.

Thanks for your input with these things. I rarely understand what you write about them but it makes it no less interesting.  :0)
At very least you motivate me to want to educate myself more about them.
Title: Re: Control for heating with solar off grid no batteries
Post by: DamonHD on November 16, 2016, 01:25:10 AM
Is this any help for your reading list?

https://www.arduino.cc/

Note that there are MANY suppliers for this kit, name and no-name, and putting some versions together requires fewer than 10 components anyway, so if you can fab your own boards or solder stripboard then maybe you don't even need to buy boards beyond initial prototypes once you understand what you are doing.

My Arduino-based kit, eg in the smart radiator valves I'll be flogging later this week, with EEPROM and Flash and a couple of kbytes of RAM, uses a base draw of a few microwatts, up to hundreds including amortised costs of driving motors.  My Raspberry Pi (2) that helps manage my off-grid system and runs my Internet servers and is full Linux machine with 1GB of RAM, etc, uses generally under 1 watt.  Also very very good and cheap kit, but a world away in terms of applications:

https://www.raspberrypi.org/

Rgds

Damon
Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on November 16, 2016, 07:16:08 AM
I've been following this,even wanted to reply a few times,,,BUT work keeps getting in the way :-D.
To further help, there's even a helper program you can work with long before you purchase a unit.
Go to this website
https://www.arduino.cc/en/Main/Software

There's even a download for Linux (which is what I use at home). It's even portable, I run it from a 1Gig USB.

I like running it for programs before I load it up on the unit.

Hope this helps
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on November 16, 2016, 07:23:07 AM
I'm starting a thread for these general questions about getting started with UNO.
Title: Re: Control for heating with solar off grid no batteries
Post by: Mary B on November 16, 2016, 04:10:09 PM
We had this go round on the corn burner forum(sadly gone). Guys claimed putting a coil of copper in the corn stove gained heat without using more fuel to maintain the room hot air temp... even after showing them the physics formulas they still claimed these huge heat gains...If you remove heat from the fire to heat water then less heat is now available to heat the air in the heat exchanger! Only ones that that actually reclaimed heat were in the exhaust path and that created condensation and corrosion issues when burning corn!
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on November 16, 2016, 06:42:17 PM

Thanks everyone for the reading suggestions and heads up.
I get it now. And also that I am incredibly thick at times as well.  No secret there.

Anyway now I'll have to look in what to learn. So far it seems there are 3 basic levels, Rasberry pi, uno and nano. Maybe I'll start with the uno even if it is overkill and costs a few bucks more. I'll look at a kit with a couple of spare boards. They seem to be under 6 bux each on fleabay.

I think this will be my xmas present. Give me something to play with and learn.
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on November 16, 2016, 06:51:43 PM
Guys claimed putting a coil of copper in the corn stove gained heat without using more fuel to maintain the room hot air temp... even after showing them the physics formulas they still claimed these huge heat gains...

I have seen this type of thinking in many things particularly on the net. People get an idea in their head and nothing you can say, demonstrate or do will change their minds. They will even admit the physics are right but still claim some magic happening taking place that makes their admitted impossibility real.
I have seen some real doozy discussions over HOH /browns gas, fuel Pellets you put in your tank, free energy  and other nonsense which people are singularly minded ignorant to all evidence it is rubbish. Not only are they convinced of the fantasy, they are stupefied why anyone else should even question, let alone disparage it.

It can be quite scary sometimes how one track minded people can be on the most ridiculous beliefs when there is so much proof what they are espousing cannot physically be possible. 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on November 17, 2016, 09:16:25 AM
And think of a solar panel, draw current from it and it cools down.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 18, 2016, 05:04:06 AM
Read  " Getting started with  UNO "  found out that pin 13,  blinking light on mine was not programed.  Followed the instructions that you gave  ( must of got lucky ) it changed just like you said.
 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on November 21, 2016, 06:45:39 AM
Been doing some slumming on ebay and found these four channel opto-isolators cheap.

http://www.ebay.com/itm/191549940263?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

These would make a much easier build.  They use a 5.1K pullup resistor for drive.  t would be easy to parallel another resistor under the board or parallel two channels to get higher drive.  There are not any suitable FET modules at this time for water heating, but hard wiring a couple FET is pretty easy. he IRF520 ones have too low a voltage and the IRF540 ones have no heat sinking and the copper  traces are too small for the current.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 21, 2016, 08:48:28 AM
Just ordered the  4 channel opto-isolater modules.

Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on November 27, 2016, 01:34:40 PM
[quote author=OperaHouse

These would make a much easier build.  They use a 5.1K pullup resistor for drive.  t would be easy to parallel another resistor under the board or parallel two channels to get higher drive.  There are not any suitable FET modules at this time for water heating, but hard wiring a couple FET is pretty easy. he IRF520 ones have too low a voltage and the IRF540 ones have no heat sinking and the copper  traces are too small for the current.

I ordered the  four channel opto-isolators that OperaHouse  found they are coming from
Hong Kong hope to have them in a couple weeks. This will be great to see them work. I
will let you know when they arrive.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on December 01, 2016, 03:27:16 PM
While waiting on parts to get here,  have any of you guys put together a system to circulate
hot water ?  What kind of a pump is best,  rad to pump the water through ?
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on December 18, 2016, 04:51:16 AM
I would like to thank OperaHouse  and you other ones for the help received on my project.
Have run into some health problems, maybe a bit of time before get back at it.

Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on December 18, 2016, 05:55:19 AM

I was reading over this thread again today.
I would really like to build one of these but it's just way too far over my head. Seems like the posts here are like 1 in 3 out of the full discussion. :0)
No way I can figure it out without a connection diagram and parts list.
 Been looking to see if I can find something with them for about 4 hours today but can't find anything except ripoff priced commercial units.
I'm really surprised there aren't a load of people wanting to do this. I think a few have had the idea and been put off. I must have read 50 threads where people asked and then got people whining about not efficient and suggesting other things instead of just answering the question asked.
Hell of a lot easier to run wires to a standard heater than fool around with pipes and plumbing and other things for abortion or tube type heaters and a lot cheaper with power too.

Ah well, Maybe there is a cheap Chinese board I can find. No luck so far. 
Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on December 19, 2016, 08:51:00 AM
george65;
I can be daunting to say the least. Getting back into writing programs for me is crazy hard.
I have to overcome my own short comings just to stay focused.
I've learned the hard on track with what I'm working on , not go play with a another one.
THAT can be the problem with an device that is so useful and cheap.

Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on December 24, 2016, 01:29:26 PM
  Merry Christmas to everyone

  The very best in 2017
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on December 24, 2016, 03:07:35 PM
Hope the new year finds you in good health and ready to continue with the project.  Have you added more space heaters to the array?
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on December 26, 2016, 09:06:28 AM
The space heaters are still the same two  750 watt  240 volt.   Have had a lot of snow and
overcast with no sun in December.  Maybe in January with the days getting longer it will be better.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on January 19, 2017, 04:56:47 AM
Got home from the hospital.  Hope to get this working.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on January 19, 2017, 08:11:40 AM
Welcome back. Thinking of posting to you this morning.  Don't know if you have read the electrodacus stuff.  Need to get you up and running before he does.  Like to compare your future results with his theoretical, both of you are in Canada.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on February 08, 2017, 06:43:57 AM
Would like to get this working, don't know just where I have gone wrong. Have been very
thick and not able to get a grasp on this like other things through out life.  Open to any ideas
or suggestions.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on February 08, 2017, 07:55:17 AM
I'm working on a new water heater program now.  Let me know what you have for loads now so I can configure it for one or more resistive loads.   Need wattage and volt rating.  What is the open circuit voltage you measure from your array.   I've found a supplier near my camp.  Looks like I will be adding another 1,000W of Canadian Solar this summer.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on February 10, 2017, 06:58:23 AM
Open circuit voltage in winter 170 's ,  have had a lot of overcast weather this winter starting to get some sunshine now,  next sunny day I will check the voltage and report it.
The load now is 1500 watt 240 volt baseboard heater on 6 panels.   
1000 watt 240 volt baseboard heater on the other six panels.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on February 10, 2017, 08:29:41 AM
That should be cooking a little.  I'm heading out of town and won't be able to do anything till Monday.  I'll edit up the new program for that voltage and email it to you.  This new program will track without external sensors.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 03, 2017, 06:04:28 AM
Had bit of a set back.  Thanks for the new software.  Hope to get at this in a few days.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 22, 2017, 04:57:49 AM
Need some help with the mosfets.  I used the diagram on page 1 reply#6 to wire the opto
and mosfets,  they carry the load and will not drop it. Disconnecting the wire to the gate
makes no difference.  The mosfets are  irpf250npbf  opto  4n26 . I am using  2 mosfets and
1 opto  there is power going to the gate. Maybe I need different ones or have not followed instructions ?
Title: Re: Control for heating with solar off grid no batteries
Post by: Mary B on March 22, 2017, 05:11:14 PM
Do you have voltage on the gate with it disconnected? If so you may have a bad FET.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 23, 2017, 04:51:10 AM
I will check that and get back.  Thanks
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on March 23, 2017, 07:04:52 AM
A FET can be damaged by a static charge to the gate. Puncture occurs when voltage on the
gate exceeds 20V. Even a minimal puncture can cause the device to fail a long time after
that has occurred.  It is a good idea to place a resistor from the gate to the source before
building the rest of the circuitry.  This will prevent damage from a floating gate either
in construction or an inadvertent disconnect. A failed FET almost always has a short from
the gate to the source. A floating gate can cause the FET to partially turn on causing
excessive heat and then failure.

So, it might be a good idea to have a pulldown resistor on each gate so if one FET is
removed or common is lost, the other one is still protected. A 1.5K resistor on each gate
would work.  That program is from another project I was working on and I changed the A/D
input and output pins.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 29, 2017, 04:39:47 AM
Very Happy day yesterday I got the uno working.  The day was perfect for testing, heavy
overcast to bright sunshine back and forth several times.  Just have one pin operating at the
 moment but will hook up the other one.
Title: Re: Control for heating with solar off grid no batteries
Post by: DamonHD on March 29, 2017, 06:35:40 AM
Well done!  Hurrah!

Rgds

Damon
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 29, 2017, 07:43:16 AM
Thank you. I hope to have a better understanding for the next ones.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on March 29, 2017, 08:36:19 AM
So, does it actually seem to hold the voltage at power point?  Are the FET running cool.  How big is the load?  Did you do anything to adjust it?
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on March 29, 2017, 09:15:31 AM
Yes the voltage says at power point.  The load varied a lot through those conditions yesterday.  At the end of the day when I checked the load voltage was 18  the panels130.  Just have one fet operating off pin #3 it is hooked to a 750 watt  240 volt baseboard heater and the fet  is only warm.  Going to hook up another heater that is the same to operate off pin #11 with its own fet.  Have not done any adjusting yet,  could use some help with that.
I am going to take one of the panels out of series and put it back in parallel. That will drop
the voltage  by almost 40 volt. Will the code have to be changed ?
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on April 01, 2017, 09:14:48 AM
 Installed a second opto-isolator and fet.   Got the second baseboard heater hooked up which
is controlled from pin #11 on the UNO.  Today is perfect for observing the performance heavy
cloud cover to bright sunshine changing frequently. Drive #1 , #2 vary from both on full power to partial  power on just drive #1.  Very happy to see this is working.  Want to let you guys that have been following this know.
Title: Re: Control for heating with solar off grid no batteries
Post by: DamonHD on April 01, 2017, 11:03:52 AM
Thanks for the update: it's good to know when things work, as well as when they don't!

Rgds

Damon
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on April 01, 2017, 11:11:41 AM
Good job, you'll be doing a youtube video next. I'll need to do a 4 heater version next. It is tax time and the desk is cleared off for that for a while. How many adjustment pots do you have in the system now?  If you hav an old analog dc meter, it can be used to make the adjustment. Just tune for higher voltage. Software update will come soon. Buy more fets.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on April 02, 2017, 04:59:43 AM
Will not be doing a youtube video.  It has been quite a trip for me getting this far.  I am starting to get a bit of  a idea of how and why this operates.  There are two adjustment pots
in the system now.  I have a old analog meter that can be used.  No rush on new software
just when it happens.  ( still in amazement watching the load on the drive  change on this one )  My plan was to have two systems,  six panels on each  one.  Should I be thinking different ?  Have more fets on the way.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on May 08, 2017, 04:15:29 PM
Just an update  to let you know that the unit is working.  The load is controlled so the solar panels maintains  power point voltage.  The fets only get slightly warm. A very slight change
of brightness to the panels and the load changes instantly.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on May 09, 2017, 12:21:32 PM
Sounds good. I'll be getting back into it shortly.Currently laying out a general purpose
board with a small capacitor bank and up to six FET. This will be be the base for a one
or two element MPPT heater, heater and MPT buck converter, linear current booster for
running a pump motor without a battery, and whatever I dream up in the future.  This will
make it easier for others to build these projects.  Then I will have to start cleaning up
and standardizing the code.
Title: Re: Control for heating with solar off grid no batteries
Post by: george65 on May 10, 2017, 11:25:22 PM

If you could put up the code and the board schematic it would be a great help to a lot more people than just the code itself.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on June 03, 2017, 06:25:16 AM
Update changed the wiring on the panels to lower the voltage.  The open circuit voltage is now 135 volt. Will have to adjust the code.
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on June 03, 2017, 07:09:23 PM
The software should adjust to that. There might be a problem if it drops somewhere below 60V as it may think the panels are not generating enough power yet.

The real problem I that you might have is that your loads are insufficient for the power you can generate.  Lower voltage complicates that even more.  Perhaps you are talking about adding some extra PWM outputs to the system.  I've just been waiting for when you want to take this further.  I'm en route to the camp now and will be getting deep into a new water heating project.  My father just died and I have some things to take care of first.
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on June 04, 2017, 03:01:41 PM
Thanks for getting back and the information. My thoughts are with you on the passing of your father.
I figured it was the time of the year to return to the camp.
When I changed the wiring of the panels to lower the voltage I just added in a additional plug in. Now to change back just switch the wire to the other plug.
Got a question.  Was running the OCV at  170's wrong or harmful ? Since I changed it back to 135
OCV  do not get near the heat that I did.
Look forward to hearing what should be done
Title: Re: Control for heating with solar off grid no batteries
Post by: ontfarmer on June 14, 2017, 03:35:30 PM
Been thinking about OperaHouse he said he was en route to the camp.  Haven't seen him online or
any postings for quite a while ? 
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on June 15, 2017, 10:10:12 AM
I'm alive, the board has been quiet.  My radio water meter stopped working this winter. They only last a couple years because it only gets used 4 months a year.  Water usage provides a little charging.  They use lithium batteries and they don't like it below freezing. They wanted access and told them I'd be back in June. So, they turned off water at street and broke something. Yard is all torn up.  Once back couldn't just let them in as I had bundles of wire hanging by the meter. Had to rewire everything. If town ever figured out I am off grid the house would be condemned.  So been busy and have to come down from the hills to get internet access. I did manage to blow up an inverter doing something stupid. Think that was my last spare.  I have at least two to fix.

Microsoft did an update and my computer hasn't worked right since.  Anyone else having problems?  I have to pull out the battery each time just to get it to start up and don't like the the desktop.  Time to be doing a backup.
Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on June 15, 2017, 01:26:15 PM
OperHouse;
Depends on which version of Windoes you have . 10>> I stay away from, way too many horror stories from IT people. Windows 8.0 & 8.1 NOT even going to bother. There's two here at work and they know I barely care if they work. W7 , there are some updates that break it badly. IF you can get into the area of restore points you can even undo the updates, just pick a date when you know for sure it worked ok, then tell it to restore to that point.
You shouldn't lose any documents , I'm not lost any on ~ 25 desktops.

XP, there's a new update due to the randsomware attacks, but it seems to not bother any of the other stuff.

Hope this helps

Bruce S
Title: Re: Control for heating with solar off grid no batteries
Post by: OperaHouse on June 17, 2017, 10:06:59 AM
Win 7.   If someone told me this story, I would tell them they are nuts.  Computer starts up fine if I use only battery power.  If the wall wart is plugged in the screen just stays black, the power on LED does come on.  Remove wall wart and battery, reinsert battery and it will power up.  Then you can plug in the wall wart.
Title: Re: Control for heating with solar off grid no batteries
Post by: Bruce S on June 22, 2017, 01:56:03 PM
Operahouse;
Sorry for the late reply. 30th wedding anniversary time :-).

This certainly points to a Micro$oft update of sorts.
Since you can get it running, you might go into control panel, select the updates ( make sure and turn on "show installed updates"). Turn off automatic updates if it's turned on. Then delete  them until you're back a full 30 days , but do not allow it to reboot until you've deleted the last few ~ 3 possibly more. Be sure to remove any KB that has the last four numbers of 3977!! these deal with the motherboards and Micro$oft pushing it's secure boot. The UEFI is causing real issue for IT managers that use PXI boot managers to restore troubled computers.

Cheers
Bruce S