# Real-Time Simulator for Dynamic Systems on FPGA
## 4 Development of the Prototype and Results  
### Prototype Description  
The simulated model presented in this work follows the same test model presented in [1], aiming for continuity of reading. Thus, they developed a model of a longitudinal vehicle, shown in Figure 11. It was used as the basis of the model defined in [39]. In this model, the input parameters were the torque delivered to the wheels and the longitudinal inclination angle of the track. The output parameter was the speed of the vehicle.  
Figure 11: Scheme of the longitudinal model of the vehicle.  
Figure 10: Adjusting inputs circuit for the RK4.  
Figure 9: Fourth-order Runge–Kutta method circuit.  
The longitudinal model of the vehicle [39], shown in Figure 11, can be described for the following expression:  
\[M\frac{dv(t)}{dt}=f_{t}(t)-f_{a}(t), \tag{17}\]  
where \(M\) is the mass of the vehicle (in Kg), \(v(t)\) is the linear velocity of the vehicle (in m/s), \(f_{t}(t)\) is the traction force exerted by the vehicle (in N), and \(f_{a}(t)\) is the friction force (in N). The traction force can be expressed by  
\[f_{t}(t)=\frac{\tau_{m}(t)}{r}, \tag{18}\]  
where \(r\) is the radius of the wheels of the vehicle (in m) and \(\tau_{m}(t)\) is the torque (in Nm) generated by the motor, which can be expressed by  
\[\tau_{m}(t)=V_{e}(t)\tau_{m}^{max}, \tag{19}\]  
where \(\tau_{m}^{max}\) is the maximum torque (Nm) and \(V_{e}(t)\) is the first signal of continuous actuation.  
As shown in [39], the friction force, \(f_{a}(t)\), can be expressed by  
\[f_{a}(t)=f_{d}(t)+f_{r}(t)+f_{g}(t)\sin(\theta(t)), \tag{20}\]  
where \(f_{d}(t)\) is the aerodynamic friction force (in N), \(f_{r}(t)\) is the rolling resistance force (in N), \(f_{g}(t)\) is the force due to gravity (in N), and \(\theta(t)\) is the inclination angle of the plane on which the vehicle is located. The variable \(\theta(t)\) can be expressed by  
\[\theta(t)=V_{o}(t)\theta^{max}, \tag{21}\]  
where \(\theta^{max}\) is the maximum inclination angle, and \(V_{o}(t)\) is the second signal of continuous actuation.  
The aerodynamic friction is given by  
\[f_{d}(t)=\frac{1}{2}\rho C_{d}A_{fr}x^{2}(t), \tag{22}\]  
where \(\rho\) is the density of air, \(C_{d}\) is the aerodynamic drag coefficient, and \(A_{fr}\) is the frontal area of the vehicle (in m\({}^{2}\)). The rolling resistance force is given by  
\[f_{r}(t)=Mg\Big{(}C_{0}+C_{1}x^{2}(t)\Big{)}, \tag{23}\]  
where \(C_{0}\) and \(C_{1}\) are the rolling coefficients, and \(g\) is the acceleration due to gravity (in m/s\({}^{2}\)). Finally, the gravitational force is given by  
\[f_{g}(t)=Mg. \tag{24}\]  
The dynamic system presented in Equation (17) was simulated in real time, using methods to solve the ODEs (Euler, improved Euler, and third- and fourth-order Runge-Kutta), selected through the variable _MethodODE_. Equation (25) can be expressed by  
\[v(t)=\left\{\begin{array}{l}u(t)\text{ para }u(t)<v_{max}\\ v_{max}\text{ para }u(t)\geq v_{max}\end{array}\right., \tag{25}\]  
where \(v_{max}\) is the maximum velocity of the vehicle, and \(u(t)\) is given by  
\[u(t)=v_{0}+\int_{t_{0}}^{t}h_{vs}(s,v(s))ds,\,t>t_{0}\,\,\text{e }v_{0}\geq 0, \tag{26}\]where \(v_{0}\) is the initial condition of the velocity of the vehicle, and \(h_{vs}(s,v(s))\) can be expressed as  
\[h_{vs}(s,v(s))=\frac{1}{M}\Big{(}V_{e}(s)\frac{\tau_{m}^{max}}{r}-\frac{1}{2} \rho C_{d}A_{fr}v^{2}(s)-Mg\Big{(}C_{0}+C_{1}v^{2}(s)\Big{)}-Mg\sin(V_{o}(s) \theta^{max})\Big{)}. \tag{27}\]