Tutorial: Autogen

  • Goal: Generate Autogen code based on Simulink model.

  • Complexity: 3 / 5

  • Estimated Time: 40 min

This tutorial goes over:

  • Organization of your repository to store code generated from Simulink

  • Creation of a Simulink simulation model to generate C code

  • Control implementation using the AMDC hardware

Tutorial Requirements

  1. Working AMDC hardware

  2. Completion of the “Voltage Source Inverter” tutorial

  3. Read “Firmware Development Using Simulink Code Generation” article to understand an overview of Autogen

File Organization

The first step is to organize your repository. Create a new autogen folder and vsi folder in your repository, as shown below:

research-repo/
├── firmware/
│   ├── AMDC-Firmware/           <= [Existing] AMDC-Firmware as submodule
│   └── project-firmware/
│       └── usr/                 <= [Existing] Your private user C code
│           └── controller/      <= [Existing] Your private user app
│               └── autogen/     <= [New] Create this folder
└── modeling/
    └── simulink/
        └── vsi/                 <= [New] Create this folder

Running the AMDC

We are now ready to run the new control code! Try running the control task by typing ctrl init. You should obtain the same results as in the “Voltage Source Inverter” tutorial.

Conclusion

Congratulations!

You have now built an updated user app with code generated from Simulink for the voltage source inverter. These techniques can be extended for many other control problems, e.g., current regulation, motion control, or even more advanced controllers. By modifying the Simulink model and continuously generating C code, you can effectively develop new control algorithms.