From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

NI CompactRIO Dual Axis Sun Tracker Example Design

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Other

  • CompactRIO

Code and Documents

Attachment

Description

Overview

This NI CompactRIO example code startup kit is suitable for 2-axis solar cell (PV) solar tracking or solar thermal mirror tracking (heliostat). Features real-time sun position calculator algorithm, sine-cosine encoder feedback signal processing, PID motor control, and cell voltage monitoring. Also includes examples that draw sun charts using the sun position calculator algorithm.

Description

Sun tracking can increase the power output for PV solar power plants by about 25% to 40%, depending on the geographic location. (The high number is for desert areas like the Mojave desert where the sunlight is very direct and not very diffuse.) In Austin, Texas USA a single axis tracker will increases power output by 26% compared to a fixed angle system, while a dual axis tracker increases power by 32%. (That’s why single axis trackers are more common that dual axis trackers.) Single axis trackers follow the sun from East to West, while two axis trackers also track the sun altitude (up/down). In solar thermal collectors such as parabolic dish collectors, sun tracking is required and the power output is very sensitive to sun angle.  

Hardware and Software Requirements

Software

  • LabVIEW Professional 8.6.1, LabVIEW Real-Time 8.6.1, LabVIEW FPGA 8.6.1, NI-RIO 3.0, NI SoftMotion 3.0, LabVIEW Control Design & Simulation Module 8.6.1 
  • Fixed-Point Math Library for LabVIEW FPGA (link). Note: For versions higher than LabVIEW 8.6.1, these functions are included in LabVIEW FPGA so no download is necessary.

Hardware

  • NI cRIO-9074 CompactRIO Integrated System
  • Slot 1: NI 9215 Simultaneous Sampling, 16-bit Analog Input Module (analog signals for the azimuth and altitude sine-cosine encoders)
  • Slot 2: NI 9221 +/- 60 V, 12-bit Analog Input Module (solar cell open circuit voltage)
  • Slot 3: NI 9505 Motor Drive Module (azimuth control)
  • Slot 4: NI 9505 Motor Drive Module (altitude control)

Steps to Implement or Execute Code

LabVIEW Real-Time Application

The real-time application calculates the current sun position based on GPS location coordinates and the date/time and time zone. The sun position is then used as the set point for two proportional-integral-derivative (PID) control functions. One PID function controls the azimuth (east/west) position of the tracker, while another controls the altitude (up/down) position of the tracker. The actual altitude and azimuth position of the tracker is calculated in the FPGA. These values are the process variable inputs to the PID loops, which then output a pulse width modulation (PWM) duty cycle command that adjusts the amount of power given to the motors by the CompactRIO NI 9505 brushed DC motor drive modules. 

 

Note: This control approach is designed to position the PV cells to point directly into the sun. For mirror tracking (heliostat) applications, additional algorithms would be required to calculate the proper position set point to direct the sun light onto the collector.suntrackerrtbd.jpg

 

LABVIEW FPGA Application

The FPGA application begins with enabling the drive modules. Then a pulse width modulation (PWM) signal is generated for each of the motors based on the duty cycle command. This determines how much power is sent to the motors. There is also a direction control. When the user hits, the Stop button, the drives are disabled. FPGAs are fast, parallel and reliable. Data acquisition for the sine-cosine encoder sensors that runs at 200 kHz. LabVIEW FPGA  supports fixed point data for I/O nodes, so the values are in Volts rather than integer units. The sine-cosine position sensor decoder algorithm converts these peak level signals into the Azimuth and Altitude position signals in degrees. 

 suntrackerfpgafp.jpg

Sine-Cosine Position Sensor Decoding Algorithm (LabVIEW FPGA)

The FPGA-based position calculation algorithm converts the raw analog signals from a sine/cosine encoder into a angular position measurement in degrees. The algorithm converts the analog signals to position by performing a fixed-point arctangent function. Various signal processing techniques are used to make the algorithm robust to signal noise. This decoding algorithm could be used independently for any application that requires sine-cosine decoding. In this particular application, a custom Peak Trigger algorithm is used to detect the peak level of each signal, since the particular sine-cosine encoder used in this application produces pulses that strobe at a 500 Hz rate. If you are using a standard industrial sine-cosine encoder with a DC voltage output (rather than pulsed output) you can eliminate the peak level detection VI.  

 

Assembly Instructions

Assembly instructions are included for building an educational sun tracker based on a low cost commercially available telescope base. However, this hardware configuration is intended for exploring concepts, teaching and research but there are some limitations: Although ruggedized waterproof enclosures for CompactRIO are available, the system described in the assembly instructions is not weatherized for outdoor use. As it is implemented in this configuration, the microprocessor powering the sine-cosine encoders goes to sleep after 10 minutes-- modifications would be required for continuous long term tracking. This particular mechanical configuration is by no means intended for unattended use outdoors or commercial use.CompactRIO_Sun_Tracker.jpg

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.