There are two versions of this tutorial, you can follow one if you have access to hardware (LIGO ADCs/DACs/Timing Cards) and the other if you don't. Both tutorials will be linked in the below page. Even if you do have I/O cards, it might be useful to start with the no I/O tutorial if you are very new to the system, as it goes into more detail on some of the basics.
There are two versions of this tutorial, you can follow one if you have access to hardware (LIGO ADCs/DACs/Timing Cards) and the other if you don't. Both tutorials will be linked in the below page. Even if you do have I/O cards, it might be useful to start with the no I/O tutorial if you are very new to the system, as it goes into more detail on some of the basics.
## Setup
## Setup
### Prerequisites
### Prerequisites
You will need an installation of MATLAB/Simulink(`MATLAB 2019a`) and an install of the package `advligorts-rcg`. You will already have this from the [CyMAC Setup](Debian-11-cymac-Installation-Guide) guide you followed earlier. If you have MATLAB installed on another system than your CyMAC, you can clone the advligorts repository directly onto that machine as it also contains the needed simulink files.
You will need an installation of MATLAB/Simulink(`MATLAB 2019a`) and an install of the package `advligorts-rcg`. You will already have this from the [CyMAC Setup](Debian-CyMAC-Installation-Guide) guide you followed earlier. If you have MATLAB installed on another system than your CyMAC, you can clone the advligorts repository directly onto that machine as it also contains the needed simulink files.
### Path Setup
### Path Setup
After opening Matlab, some changes should be made to the Matlab path so that it can find the required CDS parts. You need to add the `simLink/` directory and sub-directories to the Matlab path. This path is normally installed to `/usr/share/advligorts/src/src/epics/simLink/` , and can also be found (on your CyMAC) with the command:
After opening Matlab, some changes should be made to the Matlab path so that it can find the required CDS parts. You need to add the `simLink/` directory and sub-directories to the Matlab path. This path is normally installed to `/usr/share/advligorts/src/src/epics/simLink/` , and can also be found (on your CyMAC) with the command:
Adding this path allows Matlab to find the CDS_PARTS menu, as well as all the CDS parts provided by `advligorts`.
Adding this path allows Matlab to find the CDS_PARTS menu, as well as all the CDS parts provided by `advligorts`.
### CDS_PARTS
### CDS_PARTS
Parts are provided to the model designer through the use of a CDS_PARTS library that contains all the usable parts that can be selected from. Parts can be copied from the library into your models `.mdl` file. Open the `CDS_PARTS.mdl` file with Matlab.
Parts are provided to the model designer through the use of a CDS_PARTS library that contains all the usable parts that can be selected from. Parts can be copied from the library into your models `.mdl` file. Open the `CDS_PARTS.mdl` file with Matlab.
Each of the grey boxes contain parts separated into categories, and can be opened by double clicking on them. OSC(Oscillator)/Phase section pictured below.
Each of the grey boxes contain parts separated into categories, and can be opened by double clicking on them. OSC(Oscillator)/Phase section pictured below.
Parts can be copied into your model by right clicking on the part and selecting copy, or with `ctrl-c`. The `DOC Text` blocks can be double clicked to open a text file containing information on the use of that part. A lot of parts have assumptions, and complex internal behavior, so it is suggested that you fully read the documentation before using the block.
Parts can be copied into your model by right clicking on the part and selecting copy, or with `ctrl-c`. The `DOC Text` blocks can be double clicked to open a text file containing information on the use of that part. A lot of parts have assumptions, and complex internal behavior, so it is suggested that you fully read the documentation before using the block.
## No Hardware IOP Setup
## No Hardware IOP Setup
## Creating a New User Model
## Creating a New User Model
The easiest way to create a new model is to copy and rename another model. In the `test/` directory of the advligorts repository there are some example models we can use for this purpose.
The easiest way to create a new model is to copy and rename another model. In the `test/` directory of the advligorts repository there are some example models we can use for this purpose.
You can then navigate to the directory where you would like to store your model. `/home/$USER/models/` in most of these examples and paste/rename the model file.
You can then navigate to the directory where you would like to store your model. `/home/$USER/models/` in most of these examples and paste/rename the model file.
> :warning: When renaming the model file, the first two characters must match the system `$ifo`. This defaults to `x1` unless you changed it during your installation.
> :warning: When renaming the model file, the first two characters must match the system `$ifo`. This defaults to `x1` unless you changed it during your installation.
After renaming you can open the model with Matlab, and you should see something similar to the model pictured below:
After renaming you can open the model with Matlab, and you should see something similar to the model pictured below:
Follow this section if you are trying to build a real time model on a system where you don't have any hardware to use. If you have hardware, and want to design a model that uses it, jump down to the [hardware based model](#hw-header)
Follow this section if you are trying to build a real time model on a system where you don't have any hardware to use. If you have hardware, and want to design a model that uses it, jump down to the [hardware based model](#hw-header)
While we don't have any hardware, we still need an ADC in our model so it will build. We can leave the default ADC/filters/DAC that were present in the model we copied. But we should remove the `TST` subsystem from the original model.
While we don't have any hardware, we still need an ADC in our model so it will build. We can leave the default ADC/filters/DAC that were present in the model we copied. But we should remove the `TST` subsystem from the original model.