## 2 Assessment of the SPWM Angles
### Mathematical Definition of the Triangular Signal  
In the unipolar SPWM technique, a triangular signal must be compared with a sinusoidal signal to obtain the required angles to form the output pulses. This comparison can be made analogically or digitally; devices are designed for both modes. However, digital evaluation presents the advantage of reconfiguring in real time the parameters of the SPWM, and it is not necessary to generate the triangular and sinusoidal signals, so it is easy to implement the algorithm in a microcontroller or microcomputer like a Raspberry Pi. Before calculating the required pulses, the triangular signals must be defined mathematically. These signals are represented as two straight lines: one with a positive slope named \"\(y\)\" and one with a negative slope named \"\(y\)\", and both lines are shown in Figure 2.  
As shown in Figure 2, an important aspect is that these lines form a symmetrical triangle, preferably isosceles, with an amplitude \(A_{t}\), and the pulse width of the signal \(p_{t}\) is symmetrical on both sides of the triangle. In addition, the positive and negative lines forming the triangular signal must have the same slope, thus ensuring perfect symmetry. In this context, the midpoint of the pulse width \(p_{t}\) will be located at \(\frac{t_{p}}{2}\), which would be the midpoint of our signal. Once the amplitude \(A_{t}\) and the pulse width \(t_{p}\) of the triangular signal are defined, we can obtain the slope equation, since straight lines form these signals. The slope is calculated as the ratio of the opposite leg to the adjacent leg in the triangle formed. Since the opposite leg is \(\dfrac{t_{p}}{2}\), the slope equation is expressed as  
\[m=\dfrac{A_{t}}{\frac{t_{p}}{2}}=\dfrac{2A_{t}}{t_{p}} \tag{8}\]  
where \(m\) represents the slope of the positive line; to express the positive line (\(y\)) as a function of time \(t\), we can use the following equation:  
\[y=mt=\dfrac{2A_{t}}{t_{p}}t \tag{9}\]  
Continuing with the negative line, the slope is negative and is expressed as  
\[m=\dfrac{A_{t}}{\frac{-t_{p}}{2}}=-\dfrac{2A_{t}}{t_{p}} \tag{10}\]  
From the typical expression of one straight line, by clearing \(b\) to obtain the ordinate to the origin, we obtain the equation for the negative line (\(y^{\prime}\)):  
\[y^{\prime}=mt+b=-\dfrac{2A_{t}}{t_{p}}+2A_{t}=2A_{t}\bigg{(}1-\dfrac{t}{t_{p}} \bigg{)} \tag{11}\]  
These mathematical expressions represent the positive and negative lines of the triangular signal. However, these equations are only valid for one triangular pulse. Additional equations that consider repeating patterns over time are necessary to deal with a number \"\(n_{t}\)\" of pulses, as shown in Figure 3.  
The equations must be simplified to obtain the expressions for the \(n_{t}\) triangle, starting from \(n_{t}=0\). We start at a time multiple of the triangle pulse width called \(n_{t}t_{p}\) where \(n_{t}\) represents the \(n_{th}\) pulse of a time \(t_{p}\). The end of this \(n_{t}\) pulse is calculated by summing the pulse width \(t_{p}\), resulting in  
\[\text{end of pulse}=t_{p}(n_{t}+1) \tag{12}\]  
Figure 2: Triangular signal lines; the positive line is named “\(y\)” and negative line is named “\(y\)”. It is important to remember the importance of obtaining the midpoint of the triangular pulse, which is expressed as  
\[\text{midpoint}=t_{p}\bigg{(}n_{t}+\frac{1}{2}\bigg{)} \tag{13}\]  
Once these points are obtained, we define the amplitude \(A_{t}\), which remains constant, and the slope, which does not vary.