Use a user written subroutine to define a thermostat
Practice defining a thermostat using an alternative method such as including a DLL file generated from a user-written subroutine to the power supply model.
Explore a user-written subroutine
Locate the USER1.f subroutine in the user_subroutine\USER1 folder. You will use the USER1 subroutine to simulate a thermostat with a time varying heat load on the diode. The thermostat turns on when the temperature is lower than 45 °C, and shuts down once it reaches 50 °C. The heat load reaches 5 W after 10 seconds. The subroutine uses a generic entity that contains the following modeling data: the heater and sensor elements, the cut off and cut in temperatures, the heat load, and the heating time.
Compile user-written subroutine (Optional)
If you have a FORTRAN compiler on Windows, you can generate the DLL file form USER1.f using the createUserDll.cmd script.
Open the Simulation file
Open the model Simulation file and reset the dialog box settings.
- Choose and open part_files\user_subroutine\powersupply_sim.sim.
- Choose and on the Dialog and Precision page, reset the dialog box memory.
Define generic entity
Create a generic entity to define modeling data that the subroutine uses.
Define advanced parameter
Create an advanced parameter to activate the user DLL scheme for user-written subroutine.
- From the type list, select Advanced Parameter.
- In the Name group, enter User DLL.
-
In the Parameter Definition group, click Catalog
.
- From the Item list, expand the nodes and select the ACTIVATE USER DLL SCHEME node.
- Click OK on both dialog boxes.
Solve the solution
- In the Simulation Navigator, right-click the Solution 1 node and choose Solve.
- Click OK.
- Wait for the solve to end, before proceeding.
- In the Review Results dialog box, click No.
- Close the Information window.
- In the Analysis Job Monitor dialog box, click Cancel.
Review results
Plot the temperature history of a node to show the behavior of the thermostat over time.



