Simulate LED toggle¶
This document highlight the how to simulate LED using Simulink.
Open Matlab. Change the current folder to the directory where you want to create the model. Click Simulink.
Click Blank Model. Save the new model in any name you want without space to avoid any errors as '******.slx'
Open Library Browser .
- After Waijung 2 installation the Waijung 2 blockset will be available in the Library Browser. You can use the library browser to import Waijung 2 blocks to your workspace.
- Step 01
Click open library button to view the library.
- Step 02
Click Source.tab and select the Pulse generator block and press CTRL + I to add the block to the model.
- Step 03
Click Sinks.tab and select the Scope block and press CTRL + I to add the block to the model.
- Step 04
Click Dashboard.tab and select the Lamp indicator and press CTRL + I to add the block to the model.
The Simulink blocks used,
- Pulse Generator
Pulse Generator is used to generate a pulse which will be displayed in scope. These blocks are connected to send the signal. Connect the diagram as shown below,
once connected edit the parameters as follows,
Lamp indicator is used from SImulink blockeset library under dashboard section. The signal sent between the two blocks is linked to the lamp as shown in the below picture. For more details about Building, Simulating and connecting a Simple Simulink Model
Add the state as shown in the picture, additional state can be added by clicking on the + button in Block Parameters: Lamp. The color can be adjusted by simply double clicking the color.
Now go to Simulation Tab on the left top corner in the window, then adjust the stop time = inf so that it keep on blinking until the stopped button is pressed. Finally press the play button .
The function of this model is to blink led at 1 Hz frequency. The above model is simulated using Simulink blockset and the pulse generator is used to generate an frequency of 1 Hz. That scopes provide methods for displaying simulation data. In this example the pulse is displayed in the scope as shown below,
This shows the two blinking colors blink at 1 Hz frequency.
Click to download the lamp_blink.slx model file.