Irradiance Meter

screen_teaser

A friend of mine is evaluating solar panel technology for a large-scale home project.  An irradiance meter is a handy tool to help evaluate various options.  This irradiance meter is a fusion of pieces that came together to make a simple solution possible.

A Handspring Visor PDA provides a slick user interface and logging capability.

 

The Sensor

The heart of this project is the TSL230R Light-to-Frequency converter, which may still be available at some Radio Shack locations.  This chip features an "electronic iris" to facilitate measurements over a wide range of intensities.  The photo sensor may be enabled in 3 stages to measure from near darkness (the glow of a computer monitor) to full-intensity sunlight.  The output of the sensor is a pulse stream whose frequency is proportional to irradiance.

Amicus Compiler

The Amicus compiler's PULSEIN command makes it easy to read the pulse frequency so it seemed like the ideal choice.  The 18F25K20 requires 1.8 - 3.6 volts for operation; the sensor is rated for 2.7 - 5.5 volts, so this is a nice match.

TAP-28 Board

The TAP-28 board can use the 18F25K20 required by Amicus, so it's an excellent low-cost means of implementing the circuit.  The sensor requires 3 port pins for full operation - one for the pulse output and 2 to control the electronic iris.  Two additional port pins could be used to control the frequency divider stage, but this isn't needed to achieve full range of the sensor and it may be fixed.  The I2C/SPI connector on the TAP-28 board has 4 port pins, power and ground, so it's a perfect place to interface the sensor to the TAP-28.

Microchip 8-Pin SOIC/MSOP/TSSOP/DIP Evaluation Board

The temperature sensor is in an 8-pin DIP package with little support circuitry required so many construction methods are suitable.  The SOIC8EV prototype board from Microchip proved to be an ideal solution. It features SMT pads for pull-up, pull-down and series resistors and bypass caps for each pin, a large pad for each pin where a clip lead can be easily attached and a location for a 6 pin header to mate with the I2C/SPI connector on the TAP-28 board.  At a cost of $10/5 boards from Microchip, there's little cost penalty for this easy implementation.

Microchip_8_pin_board

 

Output Device

Opportunity knocked in the form of a newly new Handspring Visor PDA at the local thrift store.  A terminal-emulator operating on the PDA provides a great user interface and logging capability.

Ptelnet is a terminal emulator for use with the Palm operating system which the Handspring Visor uses.  It works quite nicely for I/O to the PIC18F25K20, and includes logging features. 

 

Building A System

The TSL230R Circuit

The TSL230R takes almost no support circuitry, so it's ideal for construction on the Microchip prototyping board.  The circuit requires a couple pull-up resistors to set the frequency scaling - I used resistors rather than a direct connection so that alternate settings could be tried just by shorting the pins to ground with a clip lead.  The only other component needed is a bypass capacitor of 0.1 μF.

TSL230R_schematic

The circuit is arranged to connect to the I2C/SPI connector (with 4 port pins available) on the TAP-28 board.  The "electronic iris" controls how much of the sensor is active, so the sensitivity may be set by the micro controller.  The scaling is fixed at divide by 100 to bring the signal down to a range that's easy to measure.

I built the circuit on the Microchip 8 pin prototype board.  This board has a 6 pin header location, with connections to the power and ground plane.  The signals to S0 and S1 required trace cuts and jumps.  Connections between the TSL230R pins and power and ground were made with 0-ohm resistors.

TSL230_board

board-sm

There are a couple extra jumpers on the above board...use care to identify the traces to cut!

 

The Assembly

The irradiance meter is mounted in a cheap plastic box.  The TAP-28 board will be dedicated to this task, so the implementation is somewhat different than usual.  Two switches are used for the meter, a toggle switch to select the mode and a push button switch to trigger readings.  Instead of switches on the board, the remote switches are connected to the pads on the board.

The LEDs, which indicate the iris setting, are visible through the plastic enclosure.  I also including a DS18B20 temperature probe (from Sure Electronics).  The pinout of this sensor is different than the 3 pin connectors on the TAP-28 board, so a short adapter cable is used to sort them out.  The One-Wire protocol used by the DS18B20 requires a pullup resistor to V+.  This was installed at the daughterboard pads and can be seen to the left of the crystal in the photo below.

configured_tap-28-sm

 

The sensor board uses 3 port pins on the I2C/SPI connector.  A header connector with long pins was used so that the sensor extends through a hole in the box cover.  The photo below shows the sensor supported by a couple of neoprene blocks to give it rigidity.

light_sensor_on_board_-_sm

 

The schematic of the assembly is shown below.  The TAP-28 is shown as an module - the circuit on the board is pretty standard and is described elsewhere.  It uses an 18F25K20 as required by the Amicus compiler and uses a 12 MHz crystal - the micro is operating at 48 MHz with the 4x PLL.  LEDs 1, 2 & 3 indicate which iris setting has been selected.

A pair of AA batteries power the system.  The 18F25K20, the TSL230R and the DS18B20 all operate well over the range of battery voltage.  The biggest current draw is an LED indicating the iris setting.  Rather than leaving an LED on all the time, I could flash it, or turn it on briefly when it changes but until the system is proven, I like having the iris setting always visible.

Irradiance_Meter_System_-_rev

 

Handspring Visor PDA

While I was developing the irradiance meter, I used a UART-USB bridge to monitor the output.  If the meter is to be used with a laptop computer, this would work well.

I could have used an LCD 16x2 character display, but this didn't seem like an ideal solution.  The ability to see more measurements and the ability to see the display in full sunlight were desirable.

I came across a Handspring Visor at the local thrift store.  Some quick research revealed that a nice terminal emulator is available, and that the Handspring has a serial interface.  The Handspring was still available when I returned to the thrift store, so I had a potentially nice output device.  The Handspring supports wired serial as well as the IrDa (infrared data transmission) protocol.  Turns out that this protocol is quite complex and is usually implemented using a specialized encoder/decoder chip.  A wired connection appeared to be the best option.

A Google search found the pinout of the Handspring.  The Handspring has a 3.3 volt serial interface - perfect for the 18F25K20 chip!  The cradle supplied with the Handspring was a USB cradle.  Since I didn't have a connector to fit the Handspring, adapting the cradle was the best bet.

handspring_pinout

 

Disassembling the cradle, I noticed the circuit board has a number of test point pads.  Beeping them out against the needed connections showed that all of the pins were available.  Thank you some design engineer someplace!  Note that this is a USB cradle.  Serial cradles are available, but they will convert the desirable 3.3v levels to RS-232 levels which is exactly what we don't want.  I don't know if there are different versions of cradles, so check connections carefully if you use this idea.

handspring_board_-_sm

resized

Function

 

Handspring

Connector

Cradle 

Pad

Color

 

TAP-28

UART Pin

Handspring Rxd 1 TP2 Green 4
GND 4 ** Black 3
Vdock* 7

TP3

Red 2
Handspring TxD 8 TP5 White 5


* Connects to card bay only.  Not used in this case.

** Pad at lower right corner of the board. 

Note: ptelnet operates on most Palm PDAs, including Palm Tungsten units which feature an awesome color screen, SD-card support and even more features.  The downside of the Tungsten models is that the conversion from low-voltage serial to RS-232 levels is internal to the unit.  Using one of these with a micro-controller requires converting RS-232 levels back to low voltage.  The battery life is also significantly shorter.  The USB docking cradle for the Palm Tungsten T or Tungsten T3 is similar to that of the Handspring and has test pads for the needed signals.

The Handspring can transfer data to a PC for analysis, plotting and so on.  Support for the Handspring has been discontinued in Windows Vista, but the Palm Desktop software works great on XP machines.  There are some reported work-arounds for Vista but I have not investigated them.

 

The Software

The software for the irradiance monitor was written using the Amicus compiler.  The PulseIn command to calculate the frequency of the TLS230R pulse stream made it easy calculate the light level.  Floats were used to calculate the light level but the number of operations in a single line is limited, so it was necessary to break the equation down into several steps.

The data sheet shows a log-log graph of light level vs. frequency but unfortunately does not provide a simple equation for the relationship.  I believe I have correctly figured it out but I don't have any way to calibrate it.  It's order-of-magnitude correct based on solar irradiance reports.

     Ee = frequency / 1000 * 0.77 * (output scaling) * (sensitivity/100) where

Ee = irradiance in µW/cm²

The DS18B20 section was lifted straight out of Graham's Amicus example.

Ptelnet supports the ISO Latin1 character set and VT-100 terminal emulation so formatting commands and special characters are included to get a nice display on the Handspring screen.  These commands will probably be correct for most terminal emulators but may need to be changed for a particular output device.

Source Code
' Light Meter
  '
  '
  ' Based on the TAP-28 board with an 18F25k20, a 12 MHz crystal and
  ' 4x PLL. The light sensor is an lTS230R from Taos, installed on
  ' a breakout board from Microchip and connected to the I2C/SPI
  ' connector on the TAP-28.
 

' TS230R settings
  '
  ' Output Frequency Scaling
  ' S3 S2 Scaling (divide by)
  ' L L 1
  ' L H 2
  ' H L 10
  ' H H 100 <--hardwired in this implementation
  '
  ' Sensitivity
  ' S1 S0
  ' L L power down
  ' L H 1x
  ' H L 10x
  ' H H 100x
  '
  ' Port Connections
  ' S0 PortC.4
  ' S1 PortB.0
  ' Input PortC.3
  '
  ' Level Calculation
  '
  ' Ee = frequency / 1000 * 0.77 * (output scaling) * (sensitivity/100)
 

 
 
 
 
Declare Xtal 48
Declare Hserial_Baud 9600
 
 
Dim Period As Word
'Dim Freq As Float
  Dim Freq As Dword

Dim Irrad As Float
Dim Gain As Byte
Dim DataInterval As Word
Dim NewInterval As Word
Dim Elapsed As Word
Dim ElapsedTime As Dword
 
'Temperature Additions per Graham and Digital-DYI example
 

Dim SPTemperature As Word ' scratchpad temperature storage
  Dim Reserved0 As Byte ' scratchpad reserved variable
  Dim Reserved1 As Byte ' scratchpad reserved variable
  Dim Reserved2 As Byte ' scratchpad reserved variable
  Dim Reg_TH As Byte ' scratchpad TH register or User Byte 1
  Dim Reg_TL As Byte ' scratchpad TL register or User Byte 2
  Dim Reg_Config As Byte ' scratchpad configuration register
  Dim CRC As Byte ' scratchpad CRC register
 

Dim Temperature As Float ' temperature result
 

Dim LineCounter As Byte
 
Symbol S0 = PORTB.0
Symbol S1 = PORTC.4
Symbol LED1 = PORTA.5
Symbol LED2 = PORTB.3
Symbol LED3 = PORTC.0
Symbol LED4 = PORTB.2
Symbol ModeSwitch = PORTB.4
Symbol TriggerSwitch = PORTB.5
 
'Temperature Additions per Graham and Digital-DYI example
 

Symbol DQ = PORTC.2 ' one-wire data pin
 

 
GoTo main
 
GetTemp:
 
OWrite DQ, 1, [$CC, $44] ' start temperature conversion
 

While ORead DQ, 4 = 0 ' check for still busy converting
  Wend

 
OWrite DQ, 1, [$CC, $BE] ' read the temperature
  ORead DQ, 0, [SPTemperature.LowByte, SPTemperature.HighByte, Reg_TH,Reg_TL,Reg_Config,Reserved0,Reserved1,Reserved2,CRC]

 
' display scratchpad contents
  ' HRSOut "********************************************",13
  ' HRSOut "DS18B20 Scratchpad: "
  ' HRSOut Hex SPTemperature.LowByte, " ", Hex SPTemperature.HighByte, " ", Hex Reg_TH, " ", Hex Reg_TL, " "
  ' HRSOut Hex Reg_Config, " ", Hex Reserved0, " ", Hex Reserved1, " ", Hex Reserved2, Hex CRC, 13
 

Temperature = 0.0625 * SPTemperature ' convert to degrees C
  ' HRSOut 13, Dec Temperature, " C"
 

Temperature = 1.8 * Temperature + 32 ' calculate temperature in degrees F
  ' HRSOut ", ", Dec Temperature, " F",13
 

' DelayMS 1000 ' Display once a second
 

Return
 
ReadLight:
 
Period = PulsIn PORTC.3, 1 ' Measure pulse from light sensor
 

Freq = 1000000/Period 'read once to set gain level
 

If Freq < 20 Then
 
Select Gain
 
Case 1
 
Gain = 10
 
Case 10
 
Gain = 100
 
Case 100
 
'already at max sensitivity
 

EndSelect
 
GoSub SetGain
 
EndIf
 
If Freq > 5000 Then
 
Select Gain
 
Case 100
 
Gain = 10
 
Case 10
 
Gain = 1
 
Case 1
 
'already at min sensitivity
 

EndSelect
 
GoSub SetGain
 
EndIf
 
Period = PulsIn PORTC.3, 1 ' Measure output of light sensor
 

Freq = 1000000/Period 'read with corrct gain setting
 

' Irrad = Freq/1000 * 0.77 * 100 /Gain 'freq in Khz * 0.77 * freq scaling / gain
  Irrad = Freq/10 * 0.77 'freq in Khz * 0.77 * freq scaling / gain
  Irrad = Irrad /Gain *100 'freq in Khz * 0.77 * freq scaling / gain
  '* 100 = I don't know why
 

 
 
 
Return
 
 
 
SetGain:
Select Gain
Case 1
Low S1
High S0
Low LED1
High LED2
High LED3
Case 10
High S1
Low S0
High LED1
Low LED2
High LED3
Case 100
High S1
High S0
High LED1
High LED2
Low LED3
EndSelect
 
Return
 
 
main:
Declare Hserial_Clear = On
 
DataInterval = 2
NewInterval = 2
 
Elapsed = 0
ElapsedTime = 0
 
HRSOut 27,91,50,74 ,13,10'clear screen
  HRSOut "Amicus light Meter", 13, 10 ' Display title
  HRSOut "Ver 1.0 Jon Chandler", 13, 10, 13, 10 ' Display title & blank line
 

 
Low S1 'min sensitivity
  High S0

Gain = 1
GoSub SetGain
 
LineCounter = 0
 
While 1 = 1
 
 
 
If ModeSwitch = 0 Then 'log mode
 

If Elapsed >= DataInterval Then
 
GoSub ReadLight
 
GoSub GetTemp
 
ElapsedTime = ElapsedTime + DataInterval
If ElapsedTime > 2000000000 Then 'prevent overflow
  ElapsedTime = 0

EndIf
 
HRSOut Dec1 Irrad, " ",181,"W/cm",178,", ", Dec1 Temperature, 176,"F", " ", Dec ElapsedTime, 13, 10 ' Display the reading
 

Inc LineCounter
 
If LineCounter = 5 Then
HRSOut 13,10 'print black line
  LineCounter = 0

EndIf
'DelayMS 2000
  Elapsed = 0

 
EndIf
Elapsed = Elapsed +1
DelayMS 1000
 
If TriggerSwitch = 0 Then
HRSOut "Data Interval in Seconds: " ', 13, 10 ' prompt
  HSerIn [Dec NewInterval]

 
HSerOut ["Data Interval = ", Dec NewInterval , 13, 10, 13, 10 ] 'leave a blank line
 

DataInterval = NewInterval
ElapsedTime = 0
Elapsed = DataInterval 'force a read
  LineCounter = 0

 
EndIf
Else ' trigger mode
 

If TriggerSwitch = 0 Then
ElapsedTime = 0
 
GoSub ReadLight
 
GoSub GetTemp
HRSOut Dec1 Irrad, " ",181,"W/cm",178,", ", Dec1 Temperature, 176,"F", 13, 10 ' Display the reading
 

HRSOut 7 'beep on reading
 

Inc LineCounter
 
If LineCounter = 5 Then
HRSOut 13,10 'print black line
  LineCounter = 0

EndIf
 
DelayMS 1000
 
EndIf
EndIf
Wend

 

Operation

Solar panels are relatively expensive even today.  The question to be determined is how much solar panel efficiency can be improved using either fixed or adjustable reflectors.  Even with the expense of additional support structures and control mechanisms, reflectors may boost panel efficiency enough to make the system practical.

This photo shows one of two panels (of what could be a 40 panel system!) installed for evaluating reflector options.  The other panel is used as the control with no reflectors to judge the benefit of adding them.  Plywood with white reflective roofing paint is being used for the initial tests but several other high tech (and costly) options are being considered.  The irradiance meter will aid in testing and in adjusting reflectors for maximum effect.

in_use_sm

 

Using the irradiance meter is simple.  It has two modes of operation, continuous readings at a specified interval or readings only when a button is pressed.  In either case, the readings are displayed on the Handspring screen and may be logged for later analysis.  The Handspring screen displays irradiance, temperature and elapsed time.  If the readings are logged, data is broken into 4 kbyte chunks and stored with a time stamp so the actual time of each reading can be determined.

in_use_screen_-_sm

When in continuous mode, pressing the trigger button prompts for the desired interval on the Handspring screen.  This is entered using Grafitti on the touch screen.  Grafitti isn't too difficult to use, especially just for numbers.

grafitti

 

Conclusion

The ten-year-old technology of the Handspring really made this application practical and it's a great option to have for projects needing I/O.  The irradiance sensor is easy to use with the Amicus compiler, although it wouldn't be much more difficult to write Swordfish code to support it.

The PIC18F25K20 is a nice part to use where battery operation is needed.  A couple AA cells will supply power for a long period (even longer if I didn't insist on leaving an LED on!).  For this prototype system, I didn't include any battery monitoring but the two sensors and the PIC will operate over most of the useful range of the batteries.

Finally, the Microchip dev boards are a great find.  A reliable circuit for the TLS230R was built in short order.

Time will tell if the irradiance meter is helpful in the solar panel evaluation.  It is interesting that my desk lamp is about 300 µW/cm² while bright sun is over 100,000!

Rob, in the photo below, doesn't seem too impressed by any of this....

Rob_-_sm


Posted: 6 years 11 months ago by Anonymous #5507
Anonymous's Avatar
Rob may not be impressed, but I certainly am!

Using the Handspring Visor PDA as a remote terminal device is an ingenious idea - I can see you rolling out that gear to interface with future projects as well.

Was this your first "sizeable delve" into the Amicus IDE? What did you think of the programming approach?
Posted: 6 years 11 months ago by Anonymous #5508
Anonymous's Avatar
This was my first major project using Amicus. I like some of the commands that aren't native to Swordfish but at the same time some things seem klugy, like having to insert a "goto" at the start of the code to jump over the subroutines.

Swordfish and Proton/Amicus are quite similar in many ways, but the syntax often is slightly different, so the documentation gets a workout. The Amicus documentation is quite good fortunately.

We've already decided that a second DS18B20 is needed. The panel temperature is a concern but the key factor is the temperature rise over ambient.

My initial prototyping was done with a 20 MHz crystal on the TAP-28 board with 4x PLL, resulting in an overclocked PIC at 80 MHz. As the Amicus page reports, this seems to work great. But since this circuit is running off batteries with variable voltage and may be operating at elevated temperatures in bright sunlight, I used a 12 MHz crystal/48 MHz clock to stay within recommended operating conditions.

This is my third TAP-28 board operating "in the wild." Almost time to run another order.
Posted: 6 years 11 months ago by Anonymous #5509
Anonymous's Avatar
Here's a link to a Taos tech paper explaining various light measurements:

http://forums.parallax.com/forums/attach.aspx?a=21872

Forum Activity

Member Access