Control Programming with Samsara Automation
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 on the device without dependencies on external connectivity.
Navigating through Samsara Automation:
When in the Industrial section, select Automation. The page may look different depending on how many programs you have deployed.
If you have not written a program yet, this page will be empty and look like this. Simply select the blue Create Structured Text Program button in the center of the screen or the +New Program button in the top right corner.
If you have an existing program from the previous version of Samsara Automation, select Back to standard automation below the bolded Automation title. Here you will be able to access the previous version of Samsara Automation to retrieve old programs. To migrate the program to the latest version of Samsara Automation, please visit Migrating Control Programs
If you have written programs using the latest version of Automation, you will see all Deployed Programs and the gateway they are assigned to. At the bottom of the screen you will see all Program Templates.
To view this page organized by devices, select View By next to the search programs bar. When you select this it will change to View by Devices.
To Stop a Program, click the stop button in the top right corner of the tile. You must have View by Device selected to see the stop button.
To access the Program Summary page, select the program.
Here you will find all previous revisions of this program, a list of all local variables, and the ability to stop and start the program.
Samsara Control Interface
The Samsara Control Interface is broken down into two main sections. The left hand side is where all programming logic will be handled. The right hand side is where all variable mapping will be handled.
On the left hand side:
To name a program, enter a name in the top left corner of the screen where you see Enter New Program Name.
Naming the program is NOT required but will help avoid the confusion of having multiple unnamed programs.
Below the name of the program is an empty interface where code will be written. The image above shows the Samsara Structured Text Interface. To program, simply start writing code. No program or config block is required.
Code will be actively checked for errors as can be seen here. In this image, the IF statement is missing a “then”
Hovering over the line will expose the error
To zoom in or out, hover over the three dots in the bottom right corner and you will see a + and - appear. Select the + to zoom in, and the - to zoom out.
On the right hand side
Under Devices, select a gateway from the drop down to assign the program to a gateway.
Once a program is selected, click add to confirm your selection.
Multiple devices can be added and selected.
In the top right corner of the above image, notice there is a selector, this is how you will choose which variable mapping you would like to view. You may also click on the name of the gateway to toggle between the two gateways.
Each type of program variable has a specific purpose which will be explicitly outlined below. It is important to know that MAPPED VARIABLES DO NOT NEED TO BE DECLARED IN THE PROGRAM. This will cause a variable to be declared twice and will likely cause a compilation error.
A program variable can be thought of as an alias for its corresponding variable. Each program variable is a generic name that is then mapped to a local variable or existing data input or data output (The data inputs/outputs mapped to gateway channels will follow existing configuration).
Program Variable - A generic variable or alias assigned to a corresponding data input, data output, or local variable that can be used in the Structured Text code.
Local Variable - A variable that is directly tied to a gateway and can be written to or read from.
Remote Variable - A variable that is acquired by a different gateway and used in the control program. This variable will be highlighted gold in the variable mapping section.
Data Input - Any input that is collected via gateway channel, third party pin, or calculated via data input formulas.
Data output - Any output that is used to write to a gateway channel output or third party pin.
There are three types of program variables
- Read/Write - Local variables can be written and read by the IG. They can also be accessed elsewhere in the Samsara platform using corresponding data inputs and data outputs. These are the most dynamic variables given their flexibility.
- Read Only - Data input variables can only be read by the IG and must be created outside of the control interface. All scaling specified during the creation of a data input will be applied within the program.
- Write Only - Data output variables can only be written by the IG and must be created outside of the control interface.
All variable mapping will be handled by the table seen below. The program variables will remain the same even if the program is applied to a new or different gateway. The only part that will change will be the mapped local, data input, and data output variables.
A variable map will begin to look like this as it is filled in, select Add row below the program variable to add an additional row.
To create a new local variable from within the control interface select Create New Local Variable or add row and simply begin typing on under the existing local variables. (Seen below)
After selecting Create Option, the following window will appear
Select Submit to confirm creation.
Local Variable Management:
Local Variables exist on the hardware itself and therefore must be handled differently. You may notice that even after deleting a local variable’s corresponding data input, it is still available when mapping variables. This section will discuss how to remove or edit existing local variables.
To locate the Local Variables, navigate to the gateways page, select the three dots on the right side and select inputs.
Then select Local Variables
From here, scroll down to view all local variables for that gateway.
To edit a local variable, select the pencil next to the corresponding local variable you’d like to edit. You will then see this window appear.
Select Submit to confirm any changes.
To delete a local variable, select the trash button next to the corresponding local variable. You will be asked to confirm the action. Select OK and the local variable will be deleted.
Deploying & Program Management
Saving a program can be done by selecting save in the bottom left corner. When you click save, the program the control interface will store the old revision in the revision history and make the latest program the first to be accessible.
Compiling a program is automatically handled by the control interface. As noted above, all errors will be underlined in red and an explanation can be found by hovering over the error. The program is actively checked for errors and compiled while you type.
Deploying a program can be done by selecting Deploy in the bottom right corner. If there are errors, the deploy button will be greyed out until all errors are resolved. Errors can range from incorrect syntax to missing variable mapping. When you click deploy the program will attempt to compile, if successful it will deploy the program to the IG.
To find previous revisions of the program (a version that was previously saved or deployed) navigate to the top right corner of the screen and select the down arrow
If a program is currently running, it may look more like this
After selecting the down arrow, you will see previously deployed or saved versions.
To view more past revisions, select the three dots to the right of the arrow, and select View Summary Page. Additional revisions will be found at the bottom of the page.
Alternatively, if you’d like to duplicate or delete the program, that can be done here.
Duplicating a Program is useful when two programs are similar but not identical. You can use an existing template, duplicate it and make the required changes while preserving the original template.
All templates can then be found on the Samsara Automation home page.