The new Automation interface allows you to remotely edit, manage, or deploy PLC control programs from any web browser, wherever you are. This article outlines how to move control programs from the previous interface to the new interface. You can learn all about using the new Automation UI in this article.
In order to migrate control programs from the previous UI to the new UI, some logic will need to be rewritten. The differences include:
- Templatized programs, with the ability to map data sources to variable names
- Deploying the same program template to many devices
- Referencing local variables directly in programs
Migrating a Program
You will need a copy of the existing program to paste into the new control interface. You can do this by saving the script in a text file or simply opening up the old program in one tab, and the new interface in a separate tab. This will help make the copy and pasting process easier.
Prepare the template
- Create a new program template in the new Automation UI, give it a name, and select +Add the device that the original program was deployed to
- Copy the original program into the editor
Edit the Program Logic
Use Variable Mappings
The original program will have data input/output names used directly in the program text, so the first step is to replace these with variable mappings.
Rename variables in program text with generic names
- ie. Internal Tank Pressure can become simply pressure
- Define the generic names and the inputs/outputs they correspond to in the Variable Mapping section
Correctly specified mapped variable names will be highlighted in the color corresponding to the variable type
Use New Local Variables
Local variables are used directly in the program, unlike the previous interface where they were referenced via data inputs and outputs. In general, use a local variable for variables that need to remain consistent across program deploys and reboots, and/or be logged to the Samsara cloud.
- Remove references to old local variables (via data inputs or outputs) and create local variables instead
- Create variable mapping entries for each variable needed in the program
- Use mapped read/write variables in the program
- Correctly specified variables will be highlighted yellow in the program text
There are a number of enhancements to the new Automation UI that enable you to take out workarounds you may have previously used. Check for each of these in your program code:
- Extra NaN checks (using <>)
- Only remote variables (data inputs that appear yellow in the variable mapping section) need to be checked for NaN, all other variable types are guaranteed to report accurately
- All other NaN checks can be removed
- Writing to local variables on every scan
- Local variables will hold their value if not written to, meaning that it is unnecessary to write a value to them if it shouldn’t change
- Example: tankIsFilling is not written to if the tankLevel is in the valid range, so the tank continues to do whatever it was doing last scan
- Renaming data inputs/outputs using variables
- Using variable mapping, give data sources any name you want
- All variables can be used directly in the program, variable definitions are generated automatically
Redeploy to Many Devices
In some cases, the same logic can be applied across many deployments, and only the specific data sources need to be swapped out — the new Automation UI handles this through templatized programs.
If you have multiple programs that perform the same functional logic, consider consolidating them into a single template.
- Identify sites that require the use of the same logic, follow the steps above, and confirm that the new program works
- Add any other devices that can use the same program to the template
- Specify the variable mappings for each of the other devices
- Deploy the program to each device and monitor progress