Project

General

Profile

Simulate LED toggle

Objectives

This document highlight the how to simulate LED using Simulink.

Required software

  • Matlab
  • Simulink

Simulink model

Step 01
Open Matlab. Change the current folder to the directory where you want to create the model. Click Simulink.

Step 02
Click Blank Model. Save the new model in any name you want without space to avoid any errors as '******.slx'

Step 03
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.
This Simulink blockset library allow you to create model that can be used only for simulation , it can not be uploaded to a microcontroller from MATLAB Simulink.
The Simulink blocks used,
  • Pulse Generator
  • Scope

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.

Step 05

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 .

Description

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,

Result

This shows the two blinking colors blink at 1 Hz frequency.


Simulink model

Click to download the lamp_blink.slx model file.

Previous:Waijung 2 installation
Next:Make Simulink model work with hardware using Waijung 2

Also available in: PDF HTML TXT