# Micro-Satellite Systems Design, Integration, and Flight
## 3 ChipSat RTOS and RF Development
### Packet Formulation
#### 3.4.3 Error Correction  
The Alpha mission's ChipSats employ forward error correction (FEC) techniques (nonlinearly related to SNR) [37] in their transmission to meet requirement 4.0 (see Table 4). FEC is a usual method in radio transmissions that adds extra bits to the signal to enhance robustness. FEC helps reinforce the signal so that it does not need to be retransmitted, and thus makes communication more dependable. For ChipSats, each 8-bit transmission is first encoded using a generator matrix. The generator matrix is a matrix of size 8 by 16 that multiplies the 8-bit signal to generate an encoded 16-bit output. The equation below shows the relationship, where \(m\) is the original signal, \(G\) is the generator matrix, and \(c\) is the resulting 16-bit output. \[c=mG \tag{1}\]  
The generator matrix was constructed by joining an 8 by 8 cross-correlation matrix, \(P\), with an 8 by 8 identity matrix, \(I\). Matrix \(G\) thus keeps a copy of the original data and a cross-correlated version. Equation (2) shows the equation that appends the generator matrix. \[G=[P\mid I_{K}] \tag{2}\]  
Figure 19: Data packet formulation. Equation (3) below shows the generator matrix that Alpha uses. Dr. [PERSON] created this matrix (Manchester 13). \[\left[ \begin{array}{cccccccccccccccc}1&0&0&1&1&1&1&0&1&0&0&0&0&0&0&0\\ 0&1&0&0&1&1&1&0&0&1&0&0&0&0&0&0\\ 1&1&0&0&1&1&0&1&0&0&1&0&0&0&0&0\\ 0&1&1&0&0&1&1&1&0&0&0&1&0&0&0&0\\ 0&0&1&1&0&0&1&1&0&0&0&0&1&0&0&0\\ 1&1&1&1&0&0&1&0&0&0&0&0&0&1&0&0\\ 0&1&1&1&1&0&0&0&0&0&0&0&0&1&0\\ 1&1&0&1&0&1&1&1&0&0&0&0&0&0&0&1\end{array} \right] \tag{3}\]  
The data have a hamming distance of five after applying FEC. It can tolerate dive lost receptions or up to two-bit errors without affecting data integrity. Each 8-bit data block from the packet is multiplied by the generator matrix at the start of the TX task. To speed up the computation, only the left half of the generator matrix was used, because the right half just adds the original matrix (although the right half of \(G\) is an identity). Binary matrix operations were used instead of regular matrix multiplication for coding FEC into the flight code because the data is in binary. Binary matrix multiplication follows the same procedure as regular matrix multiplication. Each of the values in the columns of \(G\) is multiplied by the corresponding value in the data vector, and the values are summed to produce a scalar value in the output vector. Binary multiplication uses the \"binary and\" operator, which is \"&\" in \(C\). It only produces a binary 1 when both factors are 1, so only the entries in \(G\) with a 1 are relevant. For the first column, those are entries 7, 5, 2, and 0. Like matrix multiplication, the resulting values are added to produce a scalar value. The values are first shifted right to the same position, using the double greater-than symbol in \(C\), followed by the number of shifts (e.g., \"\(>\)\(>\)4\" means right four positions). The values are put in the zero-index position, so they are in the same column. Then, a \"binary or\" is used to sum them. In \(C\), the \"binary or\" operator is the \"\(\cdots\)\". Finally, the value is shifted left to move it from the zero position back to the original position. The left-bit shift also uses two cartots but points left (double less-than symbol). See Figure 20 below for the binary multiplication code. The left half of the FEC-encoded data is obtained by performing these operations. The code used to calculate the \"\(p\)\" vector is shown in Figure 20. The right half of the FEC encode is the same as the original data, so the left half and right half are joined to make the final 16-bit vector. See Figure 21.  
After adding the data, the FEC-encoded message can also add preamble identifiers. The message length increased by two times, so the signal-to-noise ratio also went up by two with FEC. The packet length now is two times bigger, from 18 8-bit sequences to 36 8-bit sequences. Figure 21: Appended FEC. Figure 20: Binary matrix multiplication of the LHS G matrix with the data.