Design of sun tracking system based on microcontroller

Collect and like, your attention is the motivation for my creation

Article directory

    • summary
  • 1. Main contents of the research
  • 2. Design of system hardware
    • 2.1 Selection of tracking control scheme
    • 2.1.1 Selection of tracking system coordinate system
    • 2.1.2 Selection of tracking methods and tracking systems
    • 2.2 Overall system design and related hardware introduction
  • 3. Software design
    • 3.1 Introduction to I2C serial communication and its software design
    • 3.1.1 I2C bus design
    • code
  • 4. Circuit diagram
  • 5. Conclusion
  • 6. Article Table of Contents

Summary

Solar energy is an inexhaustible clean energy source. As the world’s energy situation becomes increasingly severe, solar thermal power generation, as an important renewable energy power generation method, has been favored by governments around the world. The tracking control of the concentrator is a key technology in the solar thermal power generation system. The use of the tracking system can greatly improve the heat acceptance rate of the solar concentrator, thereby improving the power generation efficiency of the system. This paper designs a set of 8051 microcontroller system for solar concentrator tracking control.
According to the relative motion rules of the sun and the earth and the motion orbit of the sun relative to the earth in the equatorial coordinate system and the horizon coordinate system, and based on the application value, an open-loop tracking control strategy using a stepper motor as the driving mechanism is proposed, and A corresponding control system was designed. According to the requirements of the control system, this article selected the AT89C51RC microcontroller as the core component and completed the peripheral hardware circuit design and corresponding software design of the microcontroller. The article introduces the important components in the system hardware circuit and the functions they implement in detail, and designs the corresponding hardware interface circuit, which mainly includes the reset circuit, I2C serial communication circuit and stepper motor drive circuit, and details it in the form of a software flow chart. The software design ideas of this article are explained.
Keywords: solar thermal power generation; solar tracking; microcontroller; open-loop tracking

1. Main contents of the research

Since the position of the sun relative to the concentrator is changing all the time, this requires the concentrator to constantly change its orientation and keep the sun on the main optical axis of the solar concentrator in real time, that is, always aligned with the sun, so as to limit the The receiving area captures as much solar radiation energy as possible. To keep the sun always on the main optical axis of the concentrator, a tracking system is necessary. This paper will design and develop a tracking control system for solar thermal power generation.
The main contents of the paper design include hardware design and software design.
Hardware parts:
① Reset circuit.
② I2C communication circuit, including the connection of peripheral bus, keyboard display chip and calendar clock chip.
③ Stepper motor module circuit, including reverse driver and stepper motor driver connections.
④ Draw the overall circuit diagram of the system.
Software systems include:
① The overall system design flow chart and its procedures.
② I2C communication module software design, including I2C bus connection diagram, initialization flow chart, button processing flow chart and time adjustment flow chart and program.
③ Stepper motor software design, including calculation module flow chart and stepper motor module flow chart.

2. System hardware design

2.1 Selection of tracking control scheme

2.1.1 Selection of tracking system coordinate system

In a solar thermal power generation system, the bracket must not only support the concentrator, but also support a multi-ton engine placed at the focus of the concentrator. If a polar coordinate system is used, although the tracking method is simple, the weight of the condenser does not pass through the polar axis, and the design of the polar support device is difficult. Therefore, this design does not use the polar coordinate system.
For larger systems, the horizon coordinate system is often used in engineering. A special advantage of using a horizon coordinate system is that the gravity plane is kept in the vertical plane through the collector. This minimizes gravity deviations on the collector surface and simplifies the engineering design of the collector and its supports to a minimum. limit, the torque on the collector’s shaft and bearings is also minimized. Therefore, the support structure of the collector using the horizon coordinate system is relatively simple.

2.1.2 Selection of tracking methods and tracking systems

Tracking control methods are divided into three types: closed-loop tracking, open-loop tracking and hybrid tracking control.
The main difference between closed-loop tracking and open-loop tracking control methods is the presence or absence of feedback information. Hybrid tracking control method is a tracking control method that combines closed-loop tracking and open-loop tracking, and is a hybrid tracking control method. The hybrid tracking method has the advantages of the closed-loop tracking method as well as the advantages of the open-loop method. If high-performance sensors are used for photoelectric tracking modules, the cost of the tracking system will undoubtedly be greatly increased, which is something we do not want to see in industrial production; if ordinary sensors are used, the tracking system will have the disadvantage of slow response. , poor accuracy, low stability, and closed-loop tracking cannot be applied to cloudy weather. Based on the local longitude and latitude, date and time, an open-loop control method is used, and the position of the collector at the next moment is obtained through mathematical calculation of the solar orbit. This allows the collector to be driven electrically to keep the sun always on the main optical axis of the collector. Track the sun in orbit, no matter the weather. As a result, there is also a disadvantage that as time goes by, the cumulative error of the system will have an increasing impact, and the tracking effect will decrease significantly.
Because the stepper motor only has periodic errors and no cumulative errors, when the stepper motor is not overloaded, its speed and stopping position only depend on the frequency and number of pulses of the pulse signal, and are not affected by load changes. Influence. Therefore, using a stepper motor as the actuator of the tracking system can effectively control the cumulative error of the system.
The control method of this paper adopts open-loop program control, and performs two-dimensional tracking of the sun’s altitude angle and azimuth angle respectively. The actuator uses a stepper motor.

2.2 Overall system design and related hardware introduction

The system diagram is shown in Figure 2-l. The microcontroller is the core of the control system. The keyboard display chip manages the keyboard and display as a driver for keyboard command input and related data display. The calendar clock chip provides an accurate clock for the system. Time Standard; The stepper motor driver indirectly controls the stepper motor. Relevant hardware interface circuits mainly include reset circuits, I2C communication circuits and stepper motor module circuits. This article will explain the selected microcontroller and main hardware circuits.

Figure 2-1 System diagram
Comprehensively considering the functional requirements of this system for the microcontroller, this article selects the AT89C51RC microcontroller from the American ATMEL Company. The microcontroller has the following characteristics:
AT89C51RC is a new type of microcontroller developed on the basis of AT89C52. Its main features are:
●The chip contains 32KB of Flash program memory, and the erase and write cycle is 1000 times;
●On-chip data memory contains 512 bytes of RAM;
●With programmable 32-line I/O port (P0, P1, P2 and P3);
●Has 3 programmable timers TO, T1 and T2;
●The interrupt system is an interrupt structure with 8 interrupt sources, 6 interrupt vectors, and 2-level interrupt priority;
●Has a full-duplex UART serial port;
●Low power consumption working modes are idle mode and power-down mode;
●Has dual data pointers DPTR0 and DPTRl;
●With 3-level program lock bit;
●With hardware watchdog timer WDT;
●AT89C5 1 RC working power supply is 4.0-5.5V;
●The maximum operating frequency of AT89C5lRC is 33MHz;
●With power-off flag POF.
The pin arrangement of the AT89C51RC microcontroller PDIP package is shown in Figure 2-2.

Figure 2-2 AT89C51RC pin diagram

3. Software design

3.1 Introduction to I2C serial communication and its software design

3.1.1 I2C bus design

The I2C bus is a simple, bidirectional two-wire synchronous serial bus. It only requires a serial clock line and a serial data line, so that signals can be transmitted between devices connected to the bus. The main characteristics of this bus are as follows:
(1) The bus has only two lines: serial clock line and serial data line;
(2) Each device connected to the bus can be addressed by software with a unique address and establish a simple master-slave relationship; the master device can serve as both a transmitter and a receiver;
(3) It is a true multi-master bus with competition detection and arbitration circuits, which allows multiple hosts to send data at the same time without destroying the data information on the bus;
(4) Synchronous clock allows devices to communicate at different baud rates through the bus;
(5) Synchronous clock can be used as a handshake method to stop and restart serial port transmission;
(6) Integrated circuit devices connected to the same bus are only limited by the maximum bus capacitance of 400PF.
The I2C bus greatly reduces the difficulty of system design. It does not require the design of a bus interface because the bus interface has been integrated on-chip, thus greatly shortening the design time. In this way, adding or deleting certain chips from the bus has a negative impact on other chips. Chips have no impact, or they are relatively independent.
The I2C bus can not only be directly connected to a microcontroller with an I2C bus interface, but can also be connected to various types of peripheral devices such as memory, calendar/clock, I/O, keyboard, and display. If we choose a microcontroller without an I2C bus, we can use an I2C bus interface expansion device to expand the I2C bus interface, or use a software program to simulate the timing of the I2C bus to complete the interface function. The bus connection diagram of this paper is shown in Figure 3-2.

Figure 3-2 Bus connection diagram
The I2C bus is a synchronous transmission bus, and the signals on the data line are completely synchronized with the clock. Data transmission uses the master device (master control) to address the slave device (controlled) in a master-slave manner, starts the bus, generates a clock, transmits data and ends the data transmission. The devices of the I2C bus are divided into master devices and slave devices. The function of the master device is to initiate data transfer on the bus and generate clock pulses to allow data transfer to the addressed device. The device being addressed is called a slave, so any device in the design can become a slave, but only a microcontroller can become a master. Master-slave device duality appears, and the function of the device and the direction of data transmission determine whether to work in receiving or sending data mode.
The bus exchanges data according to a certain communication protocol. When data exchange begins, the device as the master must obtain master control through bus competition and initiate a data exchange. Each device in the system has a unique address, and each device determines the data recipient through addressing. The I2C bus can connect multiple microcontrollers, but according to regulations, two master controllers cannot exist at the same time, so the device that controls the bus first becomes the master device. If there are several microcontrollers in a system that attempt to control the bus to become the master device at the same time, the master control device can only be determined through the bus competition protocol. The one that successfully competes becomes the master device, and other devices exit and become slave devices. Data can only be transferred between master and slave devices. After the completion, the master and slave devices will release the bus and exit the role of master and slave devices.
During the I2C bus data transmission process, a start and end signal is defined whose waveform is shown in Figure 3-3. When the bus is idle, both the data line and the clock line remain high; when the data line transitions from high to low and the clock line is high, it is the start signal (S); when the data line transitions from low to high and the clock line When it is high level, it is a stop signal§. When any device generates a start signal when the bus is idle, it begins to control the bus and becomes the master device. At this time, the bus is considered busy, and other devices can no longer generate start signals. After the master device finishes transmitting data, it generates an end signal and exits the role of the master device. After a certain period of time, the bus is considered idle.

Figure 3-3 Start and stop of I2C bus
I2C bus data transmission adopts clock pulse bit-by-bit serial transmission. During the low level period of the clock line, the high and low levels of the data line can change; during the high level period, the data on the data line must remain stable. In order for the receiver to sample and accept, otherwise the data on the SDA line will become the control signal mentioned above, and the timing is shown in Figure 3-4.

Figure 3-4 Bit transfer on the I2C bus
There is no limit to the amount of data the transmitter can send to the receiver between the start condition and the stop condition. There is a flag bit after each 8-bit byte. The transmitter generates a high-level flag bit, and the master device generates an additional flag clock pulse. The slave receiver must generate a flag bit after receiving each byte, and the master receiver must generate a flag bit after receiving each byte transmitted from the slave transmitter. The SDA line should remain low during the flag clock pulse (start-up and hold times should be considered). The transmitter should go low when the slave device receives the last byte, causing the receiver to generate a flag bit, at which time the master device can generate a stop condition. In recent years, the I2C bus has become a new bus standard widely used in the field of microelectronics communication control due to its advantages such as simple control method, fewer interface lines, small device packaging form, and high communication rate.

Program code

Main program:
#include "reg52.h"
#include "VI2C_C5 I.H" //Include VI2C package
#include "zlg7290.h"
#include "fgangel.h"
#include "motorun.h"
#include "manregstep.h"
#include<math.h>
#define PCF8563 0xA2
#define WRADDR 0x00
#define RDADDR 0x02
#define settime l
#define setdata 2
#define setlongitude 3
#define tran 4
#define up 5
#define down 6
#define left 7
#define OK 8
#define uint unsigned int
#define uchar unsigned char
sbit KEY_ INT=P3^2;
sbit RST=P1^2;
unsigned char disp_buf[8]={0,0,0,0,0,0,0,0};
unsigned char KEY;
float *fg;
bit switch date=0;
bit longtpn;
struct longitude
{
uint longtitudehour;,
uchar longtitudemin;
uchar longtitudesec;
};
 struct time
{
uchar hour;
uchar min;
uchar see;
}idata lconvtime;
struct longitude idata Lloc={116, 28, 0};
unsigned char loncontime(struct longitude idata*Lstal,struct longitude idata*LLloc);
··································
if(KEY==setdata) //is setdam?
{
IRcvStr(PCF8563, RDADDR, rd, Ox7); //Read the current hour, minute and second
display_date(rd + 3);
disp butl2]2disp_buf[2] &0x7f;
disp_butf[4]=disp_butl4] & amp;0x7f;
while(1)
{
disp_buf[i]=disp_buf[i]10x40; //E1 digit flashes first
ZLG7290_SendBuf(&disp_butl0], i + 1);
if(KEY_INT-==0)
{
KEY=ZLG7290_GetKey0;
if(KEY==up)//Add l
{
disp_buf[i]=disp_butIi] + 1;
if((disp_buf[i] & amp;OxOf)= 10)
{
disp_butIi]2disp_butli] &0x40;
}
}
if(KEY==down)
{
disp_buf[i]=disp_buf[i]-l;
if((disp_buf[i] & amp;OxOf)==OxOF)
{
disp_butIi]=0x49;
}
}
If(KEY'==left)
{
disp_buf[i]=disp__buf[i] & amp;0XBF; //stop flash
i=i + l;
if(i>5)
{
ZLG7290_sendBuf( & amp;disp_buf[0],8);
i=0;
}
}
if(KEY==ok)//confirm
{
disp_butli]=disp_butf[i] & amp;0XBF; //stop flash
ZLG7290_SendBuf( & amp;disp_buf[i],1);
tdl[0]=disp_buf[1]*1 6 + (disp_butl0] & amp;0XOF);
tdl[1]=dispbuf[3]*16 + disp_butl2];
tdl[2]=disp_buf[5]*16 + disp_buf[4];
ISendStr(PCF8563,WRADDR + 5,tdl,0x1);
ISendStr(PCF8563,WRADDR + 7, &tdl[1],ox2);
 i=0:
break;
}
}
}
}
···································
if(KEY=setlongitude)//is longitude?
{
display_longimde(Lloc);
while(1)
{
disp_buf[i]=disp buif[i] 0x40; //second flash first
ZLG7290_ SendBuf( & amp;disp_buf[0],i + 1);
if(KEY_INT==0)
{
KEY=ZLG7290_GetKeY0;
if(KEY==up)//Add l
{
disp_buf[i]=disp_butli] + l;
if((disp_buf[i] & amp;0x0f)==10)
{
disp bur[i]=disp_buf[i] &0x40;
}
}
if(KEY=down)
{
disp_bul[i]=disp butli]-l;
if((disp_buflil & amp;OxOf)==OxOF)
{
disp_buf[i]=0x49;
}
}
if(KEY=left)
{
disp_but[i]=disp_buf[i] & amp;0XBF; //stop flash
i=i + l;
if(i>6)
{
ZLG7290_SendBuf( & amp;disp_buf[0],8);
i=0:
}
}
if(KEY=ok)//Confirm
{
Disp_buf[i]=disp_buf[i] & amp;0XBF; //Stop flash
Lloc. Iongtitudesec=disp_butf[l]*10 + disp_buf[0];
Lloc. 1ongtitudemin=disp_butf[3]*10 + disp_buf[2];
Lloc. longtitudehour=disp_buf[6]*100 + disp_buf[5]*10 + disp_buf[4];
 i=0:
break;
}
}
}
}
//Set latitude
···································
if(KEY=etlatitude)//is set latimde?
{
display_latitude(1atitude);
while(1)
{
disp_buf[i]=disp_buf[i] 0x40; //second flash first
ZLG7290_SendBuf( & amp;disp_butl0],i + 1);
If(KEY_INT==0)
{
KEY =ZLG7290_GetKeY0;
if(KEY==up)//Add l
{
disp_butf[i]=disp_buf[i] + l;
if((disp_buf[i] & amp;0xof)=l0)
{
disp_buf[i]=disp_buf[i] &0x40;
}
}
if(KEY==down)
{
disp_buf[i]=disp_butf[i] + 1;
if((disp_buf[i] & amp;OxOf)=20x0F)
{
disp_buf[i]=0x49;
}
}
If(KEY=left)
{
disp_buf[i]=disp_buf[i] &OXBF; //stop flash
i=i + l;
if(i>5)
{
ZLG7290_SendBuf( & amp;disp_buf[0],8);
i=O;
}
}
If(KEY==6)//Confirm
{
disp_buf[i]=disp_butIi] & amp;0XBF; //stop flash
latitude[2]=disp_buf[1]*10 + disp_buf[0];
latitude[1]=disp_butl3]*10 + disp_but[2];
latitude[0]=disp_buf[5]*10 + disp_butl4];
i=0;
break;
}
}
}
}
·Time adjustment subroutine
···································
if(KEY= =settime) //is settime?
{
IRcvStr(PCF8563,RDADDR,rd,0x3); //Read the current hour, minute and second
display_timeset(rd);
while(1)
{
disp_buf[i]=disp_buf[i]0x40; //Seconds flash first
ZLG7290_SendBuf(&disp_butl0], i + 1);
 if(KEY_INT= =0)
{
KEY=ZLG7290_GetKeY();
If(KEY= =up)//Add 1
{
disp_buf[i]=disp_butf[i] + 1;
if((disp_but[i] & amp;0x0f)= = 10)
{
disp_buf[i]=disp_buf[i] &0x40;
}
}
If(KEY= =down)
{
disp_buf[i]=disp_butIi]-1;
if((disp_buf[i] &0x0f)= =0x0F)
{
disp_bufIi]=0x49;
}
}
If(KEY==left)
{
disp_buf[i]=disp_buf[i] & amp;0XBF; //stop flash
i=i + l:
if(i>7)
{
ZLG7290_SendBuf( & amp;disp_buf[0],8);
i=0;
}
}
if(KEY==ok)//confirm
{
disp_buf[i]=disp_buf[i] & amp;0XBF; //stop flash
ZLG7290_SendBuf(& amp;disp_buf[i], 1);
 tdl[0]=disp_buf[1]*16 + (disp_butl0] & amp;0XOF);
tdl[1]=disp_butf[4]*16 + disp_buf[3];
tdl[2]=disp_buf[7]*16 + disp_buf[6];
ISendStr(PCF8563, WRADDR + 2, td l, 0x3);
i=0;
break;
}
}
}
}
}


4. Circuit diagram

5. Conclusion

This research mainly completed the following work:
This design developed a hardware control circuit with AT89C51RC as the core. The hardware interface circuit mainly includes a reset circuit, an I2C serial communication circuit and a stepper motor drive circuit. At the same time, the software part was designed. The control system composed of the above software and hardware, Two-dimensional tracking of the sun in the horizon coordinate system is realized.
Some prospects for the research direction of this topic:
1. Although using a stepper motor to drive the concentrator to rotate can effectively control the cumulative error, it also has problems such as high power consumption and easy loss of steps when the load increases (such as in windy weather). The tracking method that uses DC motors as power machinery and eliminates system cumulative errors through a combination of open-loop and closed-loop control methods is more promising. However, the cost of photoelectric sensors with fast response speed and high accuracy is high, and the cost control of the tracking system relies on low cost. , Research and development of high-performance photoelectric sensors.
2. Considering the harsh actual application environment of solar tracking control systems (mostly desert areas), it is imperative to improve the anti-interference performance of the control circuit. With the development of electronic technology, improving the performance of components and chips and the modularity of system components are the general trends in the development of the control field.

6. Article directory

Table of contents
Summary I
Abstract II
1 Introduction 1
1.1 Background and significance of the topic 1
1.1.1 Solar thermal power generation technology is the most promising renewable energy power generation method 1
1.1.2 Prospects of several major solar thermal power generation methods 2
1.2 my country’s solar energy resources 3
1.3 Current situation at home and abroad 4
1.4 Main contents of the design of this paper 5
2 Design of system hardware 6
2.1 Selection of tracking control scheme 6
2.1.1 Selection of tracking system coordinate system 6
2.1.2 Selection of tracking methods and tracking systems 6
2.2 Overall system design and related hardware introduction 7
2.2.1 Hardware design of reset circuit 9
2.2.2 I2C communication module 10
2.2.3 Stepper motor module 14
2.3 Summary of this chapter 15
3 Software Design 17
3.1 Introduction to I2C serial communication and its software design 19
3.1.1 I2C bus design 19
3.2.2 Design of I2C bus connection devices 21
3.2 Software design of stepper motor module 27
3.3 Summary of this chapter 27
4 Conclusion 30
Reference 31
Acknowledgments 32
Appendix 33
Appendix 1: Schematic 33
Appendix 2: Procedure 34