# Create a design project¶

In the following procedure, we will create functional blocks and scripts (a waveform generator that is connected to an amplifier) and assemble these into a design project folder.

Note

A completed version of this design can be found within the folder “systemlab_design\systemlab_examples\electrical\gaussian_pulse_generator"

Part 1: Create new functional blocks and layout the design

1. Launch a new application of SystemLab|Design by double left-clicking on the SystemLab-Design.exe executable file.

2. To create a new functional block, right-click anywhere on the Project design space and select Add functional block. [A default functional block unit will be added to the project scene (Fig 1)].

3. To start editing the functional block, hover over the item and double left-click to open the Functional block properties dialog.

Fig 1: Add a functional block to the project design space

1. To add ports, select the Ports Manager tab, and then click on the Add port(s) button.

Fig 2: Functional block properties - Add port(s) action button

1. From the Add port(s) edit dialog, type ‘Pulse Sig’ into the Port name field, select Cardinal point: East, Direction: Out and Signal type: Electrical.

2. Click on the Apply button to perform the port addition [you will see the port details appear within the Ports Manager table] and then click Save to finalize the changes.

Important

If the Add port(s) dialog is closed without saving, the changes will not be saved to the functional block data model.

Fig 3: Functional block properties - Add port(s) dialog

1. Enter ‘Pulse Gen (Gaussian)’ in the field Functional block name/ID and ‘Pulse_Gaussian’ in the Script module name field [see Fig 3 right-side image].

2. Select OK to save the changes/close the Functional block properties for Pulse Gen (Gaussian).

3. Right-click on the project design space and select Add functional block.

4. Open the Functional block properties for the new functional block, go to the Ports Manager tab, select Add port(s) and create two new ports as follows:

1. Port name: ‘Input’, Cardinal point: West, Direction: In, Signal type: Electrical (remember to click Apply before proceeding to enter the data for the 2nd port).

2. Port name: ‘Gain Out’, Cardinal point: East, Direction: Out, Signal type: Electrical.

Fig 4: Add port(s) dialog for ‘Amplifier’

1. Select Apply, followed by Save, to finalize the port changes.

Fig 5: Functional block properties settings for Amplifier

1. Enter ‘Amplifier’ into the Functional block name/ID field and ‘Electrical_Amplifier_Pulse_Gen’ into the Script module name field (see Fig 5).

2. Select OK to save/close the Functional block properties dialog.

3. To create a port link for the design project, perform the following steps:

1. Hover your mouse over the blue (rectangular) output port of the Pulse Gen (Gaussian) functional block.

2. Once you see a cross-hair icon appear, left-click/hold your mouse and move the mouse cursor towards the input port of the Amplifier functional block.

3. Once directly over the Input port, release the mouse click [the completed connection (solid line) should appear as shown in Fig 6].

Fig 6: Creating signal links between ports

Part 3: Create a project folder

1. Before saving the project, go to the systemlab_design main folder and create a new folder called ‘gaussian_pulse_generator’.

Important

If the path which defines the location of a Python script contains empty spaces, the file may not be directly accessible to the script editor. It is thus recommended to remove any blank spaces in your project path definitions (this is why we have added underscores to our new project folder).

1. Go to the Project settings for our design and enter into the Project name field the name ‘Gaussian Pulse Gen’.

2. Within the File path (project) field enter the following file path: .\gaussian_pulse_generator\

3. Select OK to save and close the Project settings dialog.

4. Click on the Save icon to save the project file to the new location.

Important

Make sure to end the File path (project) field with a back slash. If there is no back slash, the design file will be saved to the root directory where the SystemLab|Design executable is located. The “.” before the design folder represents the project file path for the software application folder. The actual path is displayed in the Project file path panel (located also on the bottom Status bar)

Note

Check the status bar (bottom of the application window) to confirm that the file was correctly saved. It will read as File saved to: .\gaussian_pulse_generator\

Fig 7: Defining the File path for the Pulse Generator project

Part 3: Create functional block scripts

1. Open a session of SciTE by selecting Edit/Open Python code/script editor from the Menu bar.

2. From the SciTE dialog, select File/Open.

3. Go to the folder systemlab_design/syslab_fb_scripts and open the Python module called Script template V2 20-Dec-19.py.

1. Below “import config”, add the following line: [This action imports the SciPy application package for signal processing]

from scipy import signal

2. Under the CALCULATIONS section, enter the following five lines of code:

carrier = 0
sig_type = 'Electrical'
time_array = np.linspace(0, time, n)
sig_array = signal.gausspulse(time_array, fc=10)
noise_array = np.zeros(n)


How the signal arrays are built…

In the code above we have defined a time line based on the Project settings ‘time_window’ (duration of simulation in sec) and the number of samples (n) defined for the simulation (‘num_samples’). These parameters are retrieved under the ‘PROJECT SETTINGS’ section of the functional block script (see Fig 8). As this functional block is a source (there are no input ports), we need to internally build the time array from these parameters.

The Gaussian pulse generator is based on the Scipy function (signal.gausspulse) for a Gaussian modulated sinusoid. The parameter fc, defines the center frequency for the pulse. The time_array defines the time-points (x-axis) to be used to build the Gaussian pulse. Details on this feature can be found at: scipy.signal.gausspulse

Fig 8: Portion of functional block script for Pulse_Gaussian (SciTE editor)

1. Under the “RETURN (Output Signals, Parameters, Results)” section, uncomment the lines of code immediately below the “ELECTRICAL” header (delete the hash tag symbol on the two lines to uncomment) as follows:

#ELECTRCAL
electrical_out = [1, sig_type, carrier, fs, time_array, sig_array, noise_array]
return ([electrical_out], script_parameters, script_results)


Important

Make sure that the indentation matches the image of the script code as shown in Fig 9 below! The spaces are shown within the code as small black dots. In Python, between indentations, there are normally 4-8 spaces (in the example here we are using a 4-space convention).

In Fig 9 (below) we have defined a return signal (electrical_out) which defines the output electrical data list that will be allocated to port ID 1. It is important to match the port ID defined in the script with the destination port ID that is defined in the functional block properties (the port ID can be verified by hovering over the destination output port with the design layout).

Fig 9: Portion of functional block script for Pulse_Gaussian (SciTE editor)

1. Save the script module as ‘Pulse_Gaussian.py’ within our project folder gaussian_pulse_generator.

2. Open the Settings dialog (from the Tool bar).

3. Under the Simulation settings tab, set the Sample rate to 200 and the Simulation time to 1 sec.

4. Click on the Apply button.

The Sample period, Total samples, and Samples/sym fields will be re-calculated to match the new simulation settings. Also, the Sample rate and Simulation time will be reformatted into exponential format (2.0000E+02 and 1.0000E+00).

1. Select the OK button to close the Settings dialog.

2. Click on the Start button in the Menu bar.

The simulation status dialog will indicate that there was an error processing the Amplifier block (this is expected as we have not yet defined the script for the amplifier) however we should be able to confirm that the Pulse Gen (Gaussian) block ran successfully.

1. To verify that we have a Gaussian pulse signal, hover over the output port of the Pulse Gen (Gaussian) functional block and double left-click your mouse to open the Electrical signal data analyzer dialog.

From the Time data tab (which plots electrical signal & noise arrays as a function of the sampled time) we can see that the Gaussian pulse was successfully built by the script routine.

1. To verify the frequency domain signal, select the Frequency data tab.

As designed, the center frequency of the spectral profile of the Gaussian pulse is confirmed to be 10 Hz!

1. Return to the SciTE editor dialog for the script module Pulse_Gaussian, select File/Save As, and save the script under the new name ‘Electrical_Amplifier_Pulse_Gen’.

2. Update the new script as follows:

Under the “INPUT PARAMETERS” section, add the line:

gain_db = float(parameters_input[0][1])


Under the “INPUT SIGNALS” section, add the lines:

time_in = input_signal_data[0][4]
sig_in = input_signal_data[0][5]


Under the “CALCULATIONS” section, replace the existing lines of code with the following:

carrier = 0
sig_type_out = 'Electrical'
sig_array = sig_in*np.power(10, gain_db/20)
noise_array = np.zeros(n)

1. Save all changes made to the script Electrical_Amplifier_Pulse_Gen.py and open the Functional block settings dialog for the Amplifier functional block.

2. Add to the first row of the Input parameters table the following settings:

1. Parameter name: Gain, Value: 3, and Units: dB.

1. Select OK to save and close the Functional block settings dialog.

2. Click on the Start button in the Tool bar to re-run the simulation.

The simulation status dialog will indicate that there was an error processing the Amplifier block. An alarm was raised indicating that we have tried to allocate output signal data to an input port.

1. To fix this issue, return to the SciTE editor window for the script Electrical_Amplifer_Pulse_Gen.py and, under the “RETURN (Output Signals, Parameters, Results)” section, change the port ID field from 1 to 2:

electrical_out = [2, sig_type, carrier, fs, time_array, sig_array, noise_array]


Part 4: Run the final simulation

1. Click on the Start button in the Tool bar to re-run the simulation. [The simulation should now have completed with no issues!]

2. To verify that we have applied a gain to the input signal, hover over the output port (filled blue box) of the Amplifier functional block and double left-click your mouse to open the Electrical signal data analyzer dialog.

3. Within the Signal type group (located in the left panel of the Time data tab), change the y-axis unit from Mag to Watts. [The peak signal level should read 2 Watts].

1. Verify the input signal by hovering over the input port of the Amplifier functional block, double left-clicking and within the Signal type group, changing the y-axis unit from Mag to Watts.

The peak signal for the input pulse should read 1 Watt, thus confirming the 3 dB power gain setting for the Amplifier functional block.

This completes the tutorial for Creating the first design project!