This is an old revision of the document!


Working with Autogen

One of the most important thing you need to know about MervisIDE is what is Autogen and how to work with it. In previous tutorial, we learned that Autogen is for accessing HW inputs and outputs from the program. We also discovered, how to Set Autogen on the whole device (PLC, Extension, Modbus device, 1-Wire sensor,…). Let's discuss it a bit more.

Setting Autogen on whole device is a nice feature for debugging. You tell the Mervis Runtime to poll all the inputs and outputs and you have them immediatelly accessible in your program and in the debugging mode. The downside of this is a hit on the performance of your program. You wouldn't notice it when you Set Autogen on the PLC, because the communication is quite fast, but polling unnecessary information from the Extensions over much slower RS485 bus can have an significant impact on the performance.

The other downside is that the Set Autogen will automatically generate the name of the variable. As you can check, the generated name consists of UniPi unit name and the name of the input/output. In our project we have attached the Neuron L503 and we want to use the digital input 3.7. The generated name is “Neuron L503_DI_3.07”.

You can quite happily use this variable in your program, even multiple times (the button can control many aspects of your project at once). One of the problems with this naming is that it is not descriptive. When you are working on the project, you will remember that DI 3.7 is connected to the “OK” button on the operator's panel, or to the wall switch in your bedroom. In half a year, you woudln't have to. Or the project will be handed over to somebody else. You can now probably understand, that using the default, generated names is not a good practice. Let's show another example.

Now imagine you want to rewire the button to another input, let's say DI 1.4. Maybe the original input is damaged, or you have other reasons, who knows? But in order to change the functionality in the program, you need to find all occurences of the “Neuron L503_DI_3.07”, delete it and put the new variable “Neuron L503_DI_1.04”. Easy to do with one, not as easy when you have multiple occurences across FBD programs, ST routines, HMIs, etc.

Last example is when you need to replace the PLC for other model. This happens typically when the project gets bigger then originally intended. And since the autogenerated variable contains the name of the PLC, once you change the PLC prototype, the program will be broken: