There are several function blocks common to both M340 and M580 which allow you to read,write and store process values.
There is sample documentation showing how these function blocks would be deployed. There is also an LD section attached with a Word document showing the logic.
The LD section was created using Control Expert (formerly Unity Pro)
R-122018