Solar Power Charting Tool

The world is an innovative place.  Although we still rely heavily on fossil fuels, renewable energy sources are becoming a more and more viable solution with increasing efficiency breakthroughs in solar, wind, and fuel cell technologies.  Hopefully we will see a major transition to these cleaner and natural resources in our lifetimes.

Solar energy takes on two forms.  One form uses the suns radiation to generate heat that can heat hot water for your home.  Someday perhaps, the suns rays can even be used to heat water hot enough to produce steam to move generators to produce electricity.  Also solar energy can generate electricity directly through a principle Einstein discovered called the photoelectric effect.  Basically, the way the photoelectric effect works is if light is shined on a semiconductors or metal  electrons will flow in the metal.  If the frequency of the light shined on the substance is greater than what is called the threshold frequency of the substance, then electrons are emitted from the substance.  After the threshold is reached, the rate of the emission of electrons (current flow) is proportional to the intensity of light shined on the substance.  Certain metals make better electron emitters than other metals at certain frequencies of light. For example silicon and selenium are substances used to make solar cells because of their energy efficiency in sunlight. 


Figure 1 - Photovoltaic Solar Energy Farm in Australia

The cell we will use for our solar tracking experiment is made from crystalline silicon and has a maximum voltage rating of .55V and a maximum current rating of 300 ma.  The cell can be picked up in your local Radio Shack for about $5.  Although the cell doesn't produce much power, this experiment can certainly be scaled to handle higher wattages.

Measuring the Solar Power

Power is the measure of energy per unit time.  It can be calculated by multiplying voltage by current at the output of the solar cell.  Because our GP-3 Board can only measure voltage, we'll need to create what is called a current-to-voltage converter circuit.  This circuit takes current from the photovoltaic cell and runs it through a couple of operational amplifiers to produce a corresponding voltage  (1V corresponds to about 10 milliamps).  

Figure 2 shows the circuit constructed for measuring current from the solar cell.  The operational amplifier (also known as a differential amplifier)  is a great circuit for sensing or measuring just about anything because it keeps the voltage at one input at a reference point determined by the other input.   The first opamp is the current-to-voltage converter.  It takes the current from the photovoltaic cell and converts it to a voltage determined by the 100 ohm feedback resistor.  Unfortunately the voltage produced at the output of the first opamp is negative (which the A/D channel on our GP-3 board can't measure).  We need to flip the polarity of this voltage using a second op amp set up to invert the voltage sign.   This positive voltage is then fed into pin 10 of our GP-3 board, which is actually channel #0 of our A/D (Analog to Digital) converter.


Figure 2 - Current-To-Voltage Converter to Measure Current from the Solar Cell

Charting the Sun with .NET

The charting program consists of a User Control that plots data points on an XY Plotter.  (See my previous article, An XY Plotter User Control in GDI+),  a timer control, and the ActiveX control that talks to the GP-3 board.  The program also has buttons that allow you to start and stop charting and a calibration check box to allow you to speed up data collection  to test the program.  Normally sampling takes place once every minute.  In calibration mode sampling is once every second.  Figure 3 shows the solar charting form in calibration mode.  The output you see was caused by varying the position of the solar cell:


Figure 3 - Charting solar power in calibration mode.

To chart the suns power, it is more practical to take data every 1 minute or every 5 minutes because the sun doesn't change intensity that drastically every second. So when you are through in calibration mode, switch back to normal mode by clicking the checkbox again and hit the Clear button.  Place your solar cell outside (make sure your serial cable reaches far enough!)  and hit the start button to check the power potential in your area. 

The code for capturing data is shown in Listing 1.  The program reads A/D Channel #0 on the GP-3 board every time it enters the timer's event handler.  The handler also adjusts the A/D reading to a voltage and converts the voltage back to a current using ohms law (current = voltage/resistance).  The current is then multiplied by the voltage of the solar cell (.5V) to get a power measurement.

Listing 1 - Measuring Power with the GP-3 and Displaying it in the Windows Form

  1. private void timer1_Tick(object sender, System.EventArgs e)  
  2. {  
  3.     // take a reading every minute  
  4.     long tmp1 = this.axGP3IO2.a2d(0);  
  5.     // convert the a/d reading from a voltage to a current  
  6.     // using ohms law (remember also that the a/d produced a 10 bit number (0-1024) representing  
  7.     // a voltage from (0-5) volts  
  8.     float current1 = ((float)tmp1 * 5.0f / 1024.0f) / 110;  
  9.     // voltage is about 1/2 a volt in the solar cell  
  10.     float voltage1 = 0.50f;  
  11.     // compute power using current X voltage  
  12.     float power = current1 * voltage1 * 1000;  
  13.     // also we need the time of day for the X axis  
  14.     float time = (float)DateTime.Now.Hour + (float)DateTime.Now.Minute / 60.0f;  
  15.     // check for calibration mode  
  16.     if (checkBox1.Checked) // see if we are in calibration mode  
  17.     {  
  18.         // in calibration mode, simulate the time increase of 12 minutes  
  19.         // every second  
  20.         SimulatedHour = SimulatedHour + .20f;  
  21.         time = SimulatedHour;  
  22.         // stop the timer after 24 simulated hours  
  23.         if (SimulatedHour > 24)  
  24.             timer1.Stop();  
  25.     }  
  26.     else  
  27.     {  
  28.         // stop the charting after 24 hours.  
  29.         if (DateTime.Now.Ticks - StartClock > (24 * 3600 * 1000))  
  30.         {  
  31.             timer1.Stop();  
  32.         }  
  33.     }  
  34.     // add a point to the xy plot user control  
  35.     xyGraphControl1.AddPoint(time, power);  


One easy improvement that could also be added to this project is to sum the total power produced over the course of a day.  This way you would have a number that is represented in mW-hours which in essence is a total energy measurement for that day.

If you want to try this experiment yourself you can get a hold of the gp-3 board at the AWC website. The cost of the kit is $39.95.  The other parts for the experiment (the op-amps, resistors, and solar cell) can all be purchased at Radio Shack. 

Solar power is definitely viable  in our near future. If  you want to see some cool stuff being done with solar power check out the SERC website.  They have developed a solar/fuel cell car, and are experimenting with using solar energy to create storable, clean hydrogen fuel.  Also check out the National Renewable Energy Laboratory Website for more information on renewable energy.

Previous Articles using .NET and the GP-3 Board

A Virtual Storage Oscilloscope in .NET
A Virtual VoltMeter in .NET