This chapter mainly completes the design and optimization of star sensor software algorithms, and conducts engineering design and verification to ensure that the star sensor software system meets the feasibility and reliability requirements of actual engineering.
The star sensor software system is divided into three parts: DSP driver software, CPLD driver software, and DSP application software. Among them, the DSP driver software mainly realizes the initialization of the star sensor system, the register configuration of CMOS image sensors, and the reading of image data. The CPLD driver software mainly implements star map data acquisition and storage, star map filtering preprocessing, and DSP two out of three program loading. DSP application software is the core part of the star sensor software system, mainly implementing algorithms such as star map segmentation, centroid positioning, star map recognition, star tracking, and attitude calculation.
This article proposes a star map recognition algorithm based on master-slave star pattern. The algorithm requires a small navigation star library, less recognition time, and reliable performance. The star tracking algorithm has been optimized, significantly reducing the algorithm time of the star sensor in tracking mode.
System initialization includes three parts: DSP program loading initialization, DSP internal module initialization, and DSP peripheral module initialization.
1) DSP program loading initialization
Due to the lack of program data storage capability within the smallest DSP system, the first step after powering on the system is to load the DSP program, which is actually guided by CPLD to load the program data from the three SPI FLASH chips into the DSP for operation.
2) Internal module initialization
Clock module initialization. The DSP clock system is very powerful, including various clock selection functions. The system is externally connected to an active crystal oscillator, and internally equipped with a phase-locked loop (PLL), frequency divider, and multiplier to provide suitable and stable working clock frequencies for various modules inside and outside the system. The clock tree of this DSP is shown in Figure 4-2. In this design, an external 24MHz active crystal oscillator is connected, and the internal frequency multiplier uses 18 times the frequency. The backend is divided by 2. The system maintains a working frequency of 216MHz internally, with EMIFA’s clock maintaining 133MHz and EMIFB’s clock maintaining 108MHz.
Interrupt module initialization. Interrupt is a basic function of hardware systems. DSP interacts with the internal or external upper computer instructions of the star sensor through interrupts, which is one of the important mechanisms to ensure that the star sensor can work in real-time. This DSP contains 98 interrupt sources, including software and hardware interrupts, with 12 mapped interrupt ports and 128 interrupt events, which can be mapped to level 12 interrupts. The priority setting can be completed in the DSP’s interrupt priority register. The mapping relationship of the interrupt system is shown in Figure 4-3. When the CPU receives an interrupt event, the DSP uses the interrupt function address mapping table to complete the mapping of the interrupt event port number and interrupt processing function. In the design, CPUINT ports 0 to 3 are reserved for the system, UART serial port interrupt events are mapped to CPUINT6 port, and GPIO interrupt events are mapped to CPUINT7 port.
Figure 4-3 Event to Interrupt Mapping of DSP
3) Peripheral module initialization
EMIFA and EMIFB module initialization. The EMIF controller has two modules, A and B, namely EMIFA and EMIFB. EMIFA is an interface between external memory devices and DSP, which can connect DSP with different types of memory. Usually, EMIFA can be connected to FPGA, making the FPGA platform a collaborative processor, high-speed data processor, and high-speed data transmission interface. EMIFB is the interface between DSP and SDRAM. In system design, DSP generally requires the use of the DSP/BIOS operating system, but programs will occupy a large amount of storage space. However, using EMIFB and SDRAM interfaces can facilitate program operation in high-speed SDRAM. In this design, the EMIFA interface is used to access the image cache SRAM. EMIFA provides 128M of address access space for each peripheral, which can be accessed through CPLD connection. However, the peripheral SRAM has a total of 21 bit address lines, while EMIFA only has 15 bit address lines. Therefore, when DSP accesses SRAM, it is necessary to provide high 6-bit address lines through CPLD. The EMIFB interface is used for external SDRAM, with a data bus width of 32 bits and an addressable space of 13 bit address lines. The data transmission speed can reach 133M.
UART and SPI module initialization. In this design, the star sensor is equipped with two serial communication interfaces, UART and SPI, where the UART interface is used for testing and the baud rate is set to 115200bps. The SPI interface is the interface for communication between the star sensor and the upper computer. The star sensor serves as a slave and the communication rate is designed to be 250KHz.
DSP needs to perform two operations on CMOS image sensors: chip power reset and register configuration. There are a total of 16 registers inside IBIS5, of which 12 are available for users to use. By configuring the registers, the exposure time of IBIS5, the selection of exposure mode (roller shutter or synchronous), and the window size can be controlled. Each register size is 16bits, with the high 4 bits being the register address and the low 12 bits being the corresponding register value. After the system is powered on, the DSP performs a SYS test on IBIS5_ The RESET pin provides a low level of more than 5 clock cycles, thereby clearing all 12 configurable registers internally and achieving reset operation on the IBIS5 chip. After the reset is completed, the DSP needs to configure the 12 registers inside the IBIS5 chip to make it in the expected working state. The functions of IBIS5 internal registers are shown in Table 4-1.
Table 4-1 Internal Registers of IBIS5
After completing the chip reset, start configuring the internal registers of IBIS5 in two ways: serial mode and parallel mode. For the selection of these two different working modes, the IF of the IBIS5 chip can be used_ MODE pin and SER_ Complete the setting of the MODE pin. The parallel mode utilizes a 16 bit wide parallel data line P_ DATArealizes the configuration of internal registers, and the serial mode uses the SPI serial clock line to sequentially write 16 bit data into the internal registers. Considering that the time required for configuring 12 registers in parallel mode is shorter than in serial mode, parallel mode was chosen in this design to initialize and configure the internal registers of IBIS5. During data transmission, P_ WRITE first needs to maintain a low level greater than 150ns, then a high level greater than 150ns, and finally a low level greater than 100ns. Completing the configuration of all registers only requires a minimum of 4.8us.
1) CMOS exposure timing logic
This CMOS image sensor has two exposure modes, namely roller shutter exposure mode and synchronous shutter exposure mode. Considering that in the roller shutter exposure mode, the pixel reading and resetting processes are interleaved, and all pixels are not photosensitive at the same time, it is easy to see the phenomenon of star tailing when shooting star maps. Therefore, the synchronous shutter exposure mode is selected for this design.
Synchronous shutter exposure mode refers to the exposure of all pixels on CMOS at the same time, which is read out row by row after the exposure is completed. It has the advantages of stable and accurate imaging.
The process of exposure is first provided by the DSP to CPLD with a photo enable signal start_ Cmd, notify CPLD to start taking photos. Upon receiving the enable signal start_ After cmd, CPLD will generate an exposure start signal ss_ Start, the start signal needs to maintain at least one sys_ At the high level of the clk clock cycle, the CMOS image sensor receives the start signal ss_ After start, it will be in the next sys_ The rising edge of the CLK clock starts counting until it reaches the preset exposure time. After reaching the exposure time, CPLD will send out the exposure termination signal ss_ Stop notifies the CMOS image sensor to stop exposure, ss_ The stop signal needs to maintain at least one sys_ High level of clk cycle, while CPLD generates exposure end state signal expo_ CTL, start image acquisition and storage.
2) CMOS image acquisition and storage timing logic
After CMOS exposure, CPLD will generate an expo_ The state signal is used as the starting signal for frame reading, and after generating this signal, CPLD will send a high-level y signal to CMOS that lasts for three clock cycles_ The start signal is used to notify the CMOS image sensor to read the captured image frame by frame. When y_ Start is at high battery level and requires CPLD to perform y on CMOS_ The clock pin sends a high level signal of one cycle as the starting signal for reading a row of data. When CMOS receives y_ The clock signal will delay for a certain period of time, which is called the line blanking time. At the same time, the CMOS feedback will provide CPLD with a pixel effective signal pixel_ Failed indicates that the pixel signal in the row is valid and can be read during the effective time of the row signal. At this time, the write enable signal of SRAM is valid and the pixel value can be stored in SRAM. After reading a row of pixels, proceed to initiate the reading clock y for the next row of data_ Clock starts reading the next row of data until last_ Line signal generation indicates that all frames of an image have been read, and an rd will be generated at this time_ The ready high-level signal informs the DSP that image data can be read from SRAM through the EMA port.
Star map filtering is the process of preprocessing the original star map, which involves a large amount of computation. Therefore, the underlying principles of the algorithm should not be too complex, otherwise it cannot meet the real-time requirements of the system. The commonly used filtering algorithms are 3 × 3 or 5 × 5 size median filtering, mean filtering, Gaussian filtering, etc. Among them, the median filtering algorithm sorts the data in the filtering template and takes the middle value of the data as the pixel value of the filtering center. This algorithm has a very good effect in eliminating isolated noise points. Both mean filtering and Gaussian filtering are linear smoothing filters. The mean filtering algorithm takes the average value of each pixel in an image area as the pixel value of the filtering center. This algorithm can smooth Gaussian noise on the image, but its filtering effect on salt and pepper noise is poor. The Gaussian filtering algorithm is an algorithm that weights and averages the values of pixel regions. It can be considered as a weighted mean filtering algorithm. The weight value is the weight value obtained after two-dimensional Gaussian discretization. This algorithm can effectively remove Gaussian noise, but its implementation in CPLD is more complex, involving many decimal operations, low execution efficiency, and the filtering template is too large, Not suitable for real-time calculation requirements of star sensors.
Star sensors usually work in outer space, where there is a large amount of interference from space radiation particles. If some protective measures are not taken, the program of star sensors is highly likely to undergo single event flipping under the radiation of space particles, resulting in operational errors. Therefore, in order to ensure the software reliability of the DSP, in this design, the program loading of the DSP is designed as a two out of three method, which stores identical programs in three SPI FLASH chips, leaving a certain degree of redundancy to ensure the reliability of the DSP program.
Star sensors generally include two operating modes: initial attitude acquisition mode and attitude tracking mode. In the initial attitude capture mode, it is generally necessary to identify the navigation stars in the entire sky area to establish the initial attitude. Usually, the initial attitude capture mode occurs when the star sensor is just powered on and the attitude tracking fails. Due to the time-consuming and complex process of identifying the navigation stars in the entire sky area in the initial attitude capture mode, once the star sensor successfully establishes the initial attitude, The star sensor immediately enters the attitude tracking phase. In attitude tracking mode, the star sensor needs to estimate the attitude of the star sensor in the next frame based on the star map information between adjacent frames. Under normal circumstances, star sensors are mostly in the attitude tracking stage, and the calculation and time consumption of star sensors in tracking mode are much smaller than those in the initial attitude acquisition stage. Therefore, attitude tracking mode is the main working mode of star sensors.
Figure 4-17 General workflow of star sensor
Figure 4-17 shows the workflow of the star sensor, with the specific steps as follows:
1) When the star sensor starts to work, it first enters the initial capture stage for star map acquisition;
2) Filter and preprocess the original star map through CPLD to remove interference noise on the original star map;
3) Through star map segmentation, the stars are separated from the background and from each other;
4) Calculate the precise coordinates of each navigation star in the field of view through the centroid positioning algorithm;
5) Perform star map recognition for the entire sky area, find the star sign of each navigation star in the field of view, and obtain its star information;
6) By calculating the satellite attitude, the attitude of the star sensor during the initial acquisition phase is obtained;
7) After obtaining the initial attitude of the star sensor, the star sensor immediately enters the tracking phase;
8) Collect star map images and perform star map filtering preprocessing;
9) Using local star map segmentation, centroid positioning, and star map recognition algorithms to obtain the star signs and information of the navigation stars in the field of view;
10) Calculate the current star sensor attitude and output the attitude. At the same time, proceed to step 8 and repeat the tracking process.
1) Star map segmentation
After denoising the original star map, it is necessary to separate the foreground and background. Here, we use the global threshold method to achieve the separation of star points from the background. That is, take several windows on the star map, calculate the mean of their grayscale distribution, and add this mean to 3-5 times the standard deviation of star map noise as the global background mean. After obtaining the threshold, we can traverse all pixels in the entire star map, When the grayscale value of a pixel is less than the threshold, set the pixel value to 0, otherwise retain the original pixel value; After separating the foreground and background, it is necessary to separate each star point from each other, that is, label each star point in the star map. Here, we use the 4-connected domain method to achieve the separation of stars and points.
2) Centroid positioning
Due to the fact that the accuracy of centroid positioning directly affects the accuracy of subsequent star map recognition, in order to obtain higher accuracy of star point positioning from star maps, defocusing is usually used in engineering to diffuse the imaging points of stars on the photosensitive surface of the sensor to multiple pixel units. Through theoretical derivation and experimental verification, it has been proven that ideal centroid positioning accuracy can be achieved when the diameter of the dispersion circle is 3-5 pixels.
When processing the subdivision positioning of point shaped light spots, there are two commonly used methods: grayscale based processing and edge based processing. Algorithms based on grayscale processing generally utilize the grayscale distribution information of light spots, such as standard centroid localization algorithms, square weighted centroid localization algorithms, centroid localization algorithms with thresholds, and surface fitting algorithms. Algorithms based on edge processing generally utilize the edge shape information of the light spot, such as edge circle fitting, Hough transform, etc. Generally speaking, algorithms based on grayscale processing are more suitable for smaller and uniformly distributed light spot targets, while algorithms based on edge processing are more suitable for large targets, which are not sensitive to specific grayscale values. In practical applications, the diameter of star spots is usually around 3 to 5, and the distribution presents a Gaussian distribution. Therefore, when processing star spots, it is advisable to use algorithms based on grayscale processing for centroid positioning of stars. This will introduce three commonly used centroid localization algorithms based on grayscale processing, including standard centroid localization algorithm, square weighted centroid localization algorithm, and centroid localization algorithm with threshold.
3) Star Map Recognition
As the component with the highest accuracy in attitude measurement of micro satellites, the star sensor’s internal star map recognition algorithm is particularly important. With the continuous development of microsatellites, there is an urgent need to propose a star map recognition algorithm suitable for microsatellite miniaturization. Its characteristic is that it can be implemented in embedded devices to meet the requirements of microsatellite miniaturization while ensuring the accuracy and speed of star map recognition.
The common star pattern recognition algorithms mainly include triangle algorithm, star pattern algorithm, and neural network algorithm. The biggest feature of the triangle algorithm is its simple implementation and reliable recognition accuracy. However, it requires the construction of a large triangle navigation star database, which means that for the star sensor, a larger memory needs to be configured to store known data. This will increase the size, power consumption, and cost of the star sensor, and also time-consuming in the star search matching stage. The star pattern algorithm is currently the most popular star pattern recognition algorithm, which applies the ideas of pattern recognition to star pattern recognition. By manually designing the star pattern vector and constructing a star pattern navigation star database that matches the star pattern vector, the star pattern vector in the field of view can be matched with the star pattern vector in the navigation star database to achieve the goal of star pattern recognition. The recognition accuracy and recognition speed of this method are relatively reliable, but the design method is relatively complex, and different star patterns require different navigation star databases to be constructed, which depends on the situation. Neural network algorithm is a popular star map recognition method recently, which achieves star map recognition by designing neural networks. However, currently this method only stays in the algorithm simulation and verification stage. Due to the large amount of computing and data resources required for its implementation, it is difficult to meet on small satellites, and further development is needed.
The tracking mode of the star sensor is the main working mode of the star sensor. The application scenario of the star sensor in this design is static working mode, and there will be no instantaneous movement under high dynamic conditions. Therefore, in the tracking mode, the algorithms in each stage of the initial capture mode can be inherited and optimized to reduce the time and spatial complexity of the algorithm in the tracking mode, ensuring the real-time performance of the star sensor. The following will provide a detailed introduction to the algorithm process in star sensor tracking mode.
1) Local Star Map Segmentation and Centroid Localization
The star map segmentation part is the main time-consuming part of the initial capture and tracking stages of the star sensor. Due to the traditional image segmentation algorithm requiring multiple traversals of the star map during specific calculations, it increases the algorithm’s time complexity and cannot meet the real-time requirements of the star sensor.
Local star map segmentation is based on the centroid position of the navigation star in the previous frame as the center, and the search radius is the distance between the two frames of navigation stars moving in the field of view, in order to locate and estimate the corresponding navigation star in the current frame.
Local centroid localization is the process of accurately calculating the coordinates of star points based on the results of the previous partial cut. The method follows the centroid localization algorithm with threshold in the initial capture stage.
2) Local centroid search and centroid calculation
By obtaining the precise coordinates of the navigation star from the previous step, the distance and direction of the navigation star’s movement between the two frames can be calculated, which can directly locate the estimated positions of other navigation stars in the current field of view within the previous frame’s field of view. At this point, the estimated positions are not very accurate, and further precise positioning is needed.
Based on the estimated coordinates of the center of mass of the star point, open 5 × A 5-pixel window for precise centroid coordinate positioning.
3) Local Star Map Recognition and Field of View Update
After calculating the navigation star coordinates in the previous frame’s field of view, it is also necessary to update the navigation star information in the current frame’s field of view to obtain the exact navigation star information in the current frame’s field of view. The specific updated information mainly consists of two parts: one is to delete the navigation star information that is moved out of view each time; The other is to re identify the newly moved star map into the field of view to ensure that all navigation star information in the field of view is in a known state.
Among the current mainstream star sensor attitude determination algorithms, there are mainly TRAID (Tri Axial Attitude Determination) algorithm, q method algorithm, QUEST (Quaternion Estimator) algorithm, FOAM (FastOptimalAttitudeMatrix) algorithm, and SVD (Singular Value Decomposition) algorithm. Among them, the TRIAD algorithm, QUEST algorithm, and SVD algorithm are widely used [54]. The TRIAD algorithm only requires two observation star vectors from different directions to complete pose determination, but its biggest drawback is low accuracy; The QUEST algorithm is a single point batch processing algorithm, characterized by its reliability and has been validated by many aerospace missions. However, it requires a large amount of computation and takes a long time. This scheme adopts the Singular Value Decomposition (SVD) attitude calculation method, which can effectively simplify the process of matrix inversion and utilize the dimensionality reduction characteristics of SVD to reduce the calculation of redundant space. The accuracy level is the same as that of similar loss function based algorithms.
The reliability design of the star sensor software system is an important guarantee for the star sensor to work stably in the space environment. By verifying it, it is ensured that the star sensor software system has certain reliability requirements. The reliability of the star sensor software system can be verified from the following four aspects:
1) Redundant design
2) Derating design
3) Robust design
4) Code specification
For the code of the star sensor software system, it is necessary to ensure that it is easy to read and understand during design, and sufficient annotations are required for the program lines. Corresponding files should be provided to explain the variables, arrays, structures, functions, procedures, and subroutines in the program, clearly describing their purpose, execution process, call relationships, etc., so that the software can be easily understood, corrected, modified, and improved.
Specifically, in integer numerical operations, the protection of a divisor of 0 is considered for division operations; Before the square root operation, the condition that the number of open roots is positive was considered. When performing floating-point operations, protection is provided for dividing absolute extreme decimals; Controlled the effective operation bits of numbers; b) In programming, all loops in the software are designed with normal and forced exit conditions to avoid the formation of dead loops in the program. Not using dynamic memory allocation to avoid memory leakage issues; c) During the code walkthrough phase, redundant objects in the program were cleared. Through the above analysis, a comprehensive verification was conducted on the reliability design of the star sensor software system, ensuring the stability of the star sensor software system’s operation.
Send us a message,we will answer your email shortly!