# Simulation

## Simulation

![Double precision simulation](/files/-LTdkfTUSq4awO3E5i7j)

1. Download the simulation files [here](https://github.com/rdelpoux/INSA_TP_CommandeTempsReel_MCC/raw/master/LABMatlabFiles/01_Simulation/Simulation.zip). These files are Matlab/Simulink files for the simulation of the control law proposed section [DC motor modeling and control loop design](https://rtdc.ctrl-elec.fr/control-loop-design).
2. For the realtime application the controlleur needs to be sampled. The inner electrical control loop will be sampled à 20kHz (PWM frequency). The outer mechanical control loop will be sampled at 500Hz. For this purpose, use the Sampling block commented in the simulation. Apply the sampled control to the downloaded model and compare with the continous control.
3. The DSpic support 16bits fixed point variables. The control needs to be converted to use 16bits fixed point variable only. Here use the quantization block. Compare the this control with the two previous one.

## Comparison between model and simulation

Here the objective is to compare the difference between the modeling and motor real measurement.

![Model vs Logs](/files/-LTdoeS4oZOcQcZwsTuN)

1. Download the model [here](https://github.com/rdelpoux/INSA_TP_CommandeTempsReel_MCC/raw/master/LABMatlabFiles/05_Log_Validation/LogVsSimu.zip)
2. Using the simulink file MCLV2\_dsPIC33EP256MC506\_internalOpAmp\_DataLog\_R2017a.mdl record real data from motor measurement.
3. Compare the simulation with the real measurment using the simulink file Simu\_Model\_vs\_Logs\_R2017a.mdl


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rtdc.ctrl-elec.fr/simulation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
