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