CASP Tutorial-7 Project
This tutorial demonstrates how to use existing Python code using user custom block.
Pre-Requisites
· Tutorial-2 should be completed.
· Python software has be properly installed on the PC and system environment variables shall be configured to include python paths.
· Set python library path in CASP as mentioned in CASP Documentation -> Python Support section.
Model
· In general user creates a wrapper block with suitable C++ code to interface with Python script.
· For demo purpose ‘Python Demo’ block from /blocks/UserBlocks directory is used. The python code in this demo does basic math operations based on user selection during block parameter configuration.
· A sinusoidal signal generator is used along with an offset signal source. Both signals are added in python code and result is displayed on plotter.
Step 1: Create New Project
· Follow steps mentioned in Tutorial-2.
Step 2: Select Target Hardware
· Follow steps mentioned in Tutorial-2.
Step 3: Creating Model
· Create a model as shown in below figure.
· Configure PyComm Demo block as shown in below figure
· Give names to slider and time plotter blocks.
· Set slider value range from 0 to 2 with step size of 0.1. Set initial condition of slider to 0 as explained in Tutorial-2.
· Configure simulation panel and map slider and plotter blocks to simulation panel sub-windows as explained in Tutorial-2.
Step 4: Setup Simulation Parameters
· Follow steps mentioned in Tutorial-2.
· Enable Python Support under Build tab.
Step 5: 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.