Test Example: Sine Wave Generator
Introduction
Model creation in CASP is basically a three step process.
· Create a new project and set basic configuration such as target selection, simulation settings, serial programmer port selection, setting up simulation panel sub-windows etc. with a few button clicks.
· Based on your logic, search blocks from block viewer, insert them in the model, configure the block parameters and connect them.
· Build and Run the model to either start simulation panel or program the target with the generated binary.
This example project demonstrates the above steps and shows how to do the following
· Create a new project and add workspace files
· Select Target Hardware
· Create Model
· Configure simulation panel
· Setup simulation parameters
· Run simulation in real time
Model Details
· A signal generator with user specified wave shape is modelled and its output waveform is plotted.
· Amplitude of signal generator is configured to be controlled at run time.
Steps followed to create the project
Step 1: Create New Project
· Start CASP program by clicking on relevant desktop icon or from operating system start menu.
· Open
CASP documentation from CASP main menu icon
.
· Create a new project as explained in CASP Documentation > Modelling > Creating New Project.
· Add a new workspace file as explained in CASP Documentation > Modelling > Adding Workspace File.
Step 2: Select Target Hardware
· Click
Setup Simulation button
from
CASP main menu. From ‘Target HW > General’ set ‘Target Architecture’ to
‘Native’ and ‘Target Platform/Hardware’ as relevant to the operating system.
For example, on Windows platform it is ‘Desktop_MinGW’ as shown below.

· Leave rest of the parameters to default. Click ‘Save’ and close the window.
Step 3: Creating Model
· Create a model with a ‘Signal Generator’ and ‘Time Plotter’ and connect them as explained in CASP Documentation > Modelling > Creating Model.

· Set signal generator parameters such as wave shape, amplitude, frequency and phase as desired.

· Set block name of ‘Time Plotter’ block as ‘plotter’.

· Now, let’s try to change output amplitude of signal generator during run time. To achieve this, configure signal generator block parameter Basic->External Control->External Amplitude Control to ‘Yes’. Observe that an additional input port ‘a’ appears at bottom of signal generator block.
· Add Slider block from block library to the model and connect it to input port ‘a’ of signal generator block. Name the block as ‘amp_ctrl’. Configure the slider block parameters as shown below

Step 4: Configure Simulation Panel
· This
step is required to display output of the ‘plotter’ block added in above step.
Select ‘Configure Simulation Panel’ icon
from CASP main menu.
· Add ‘Group’ and two sub-windows. Set one sub-window type to ‘Plot Display’ and other to ‘Control/Meter’ as explained in CASP Documentation > Project Simulation & Execution > Configuring Simulation Panel.
· After configuring simulation panel add ‘plotter‘ block to simulation panel Group1->SubWindow1 and ‘amp_ctrl’ block to Group1->SubWindow2.

· Configure initial value of slider block to 0.5 by right clicking on the slider block and selecting ‘Edit Initial Condition’.
Step 5: Setup Simulation Parameters
· Click
Setup Simulation button
again
from CASP main menu. Set simulation speed factor to ‘1’ and leave rest to
defaults. Click ‘Save’ and close the window.

Step 6: Run Simulation
· Press Build/Run button from Home->Simulation menu item. CASP builds and compiles the model and opens separate simulation panel window. In the simulation panel window press ‘Run Simulation’ button to run simulation. The output of simulation is shown below.

· Above simulation will run in real time. User can change the amplitude by varying the slider value.