Accessing and Programming the Samsara IG21 RTU with Structured Text (ST)
The IG21 is a fully functional, cloud-managed PLC that allows users to develop programs using industry standard IEC 61131-3 language. Programs are developed on a central dashboard, and run locally on the device. This allows flexibility in remote management and program auditing, while ensuring that all control functionally happens locally onsite without dependencies on external connectivity.
Structured Text is an IEC 61131-3 language for programmable logic controllers. It provides high level, textual programming that is easy and simple to use and deploy.
How and where to access PLC programs on the IG21:
When in the Industrial section, select Automation. Find the correct Gateway and select Details.
This will display the Deployed Program page. For a new setup, this page will be blank. Select Edit to create a new program on this device.
This page allows you to write programs in Structured Text, view past revisions, and compile and deploy code.
Samsara Structured Text Development Environment
The development environment includes the program list in the left pane, text editor in the right pane and controls in the upper right.
To save code, press the Save button in the upper right hand corner. The program will be saved for future use in the programs list.
Before deploying code, it is required to compile. Click compile in the upper right hand corner to check code for errors.
Once the code is compiled, select Deploy to run the program on the IG21.
Available inputs on the IG21
The IG21 has 4 Analog Inputs, 2 Analog Outputs, and 6 Digital Input/Outputs available for use.
These IOs are referenced as follows:
- %IW1 - %IW4 are the analog inputs
- %QW1 - %QW4 are the analog outputs
- %IX1 - %IX6 are the digital inputs
- %QX1 - %QX6 are the digital outputs
For IG61s - IOs can be referenced by the following:
Program and Configuration Statements
The ST language used by the IG21 must include a PROGRAM and CONFIGURATION statement. The PROGRAM statements, also known as main, includes variable and the logic of the program. The configuration unit is a requirement of the PLC and must be included in the program.
Notice that genericProgram in the CONFIGURATION statement will reflect the name of the PROGRAM statement.
For a broader tutorial on structured text, several books and resources are available. Online tutorials include: