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. The PLC contains a lot of informations, which are needed in special cases and you don't need them for normal operation. Also polling unnecessary information from the Extensions over slow RS485 bus will have 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 wouldn't have to. Or the project will be handed over to somebody else who will not have that knowledge and the project will be hard to read. You can now probably understand, that using the default, generated names is not a good practice.

For making fast and readable projects, the Mervis includes functionality for renaming the inputs/outputs to your liking. Let's create a simple project where we want to:

  • read current state of a button connected to the DI 1.1
  • copy the state of the button to the DO 1.1
  • count the number of presses and save it to the variable “number_of_presses”
  • if the number of presses are larger then 20, set the DO 1.4 to true

It is a good practice to start with the inputs and outputs, especially with the HW IOs. So double click on the prototype in the Left panel and head over to the list of IOs which will appear in the Main Window and search for the name “DI_1.01”:

To rename the input, fill the value in the column “Autogen Name” and confirm by clicking on 'V'. The DI_1.01 is for button, so let's rename it to “button”.

Now set the autogen for this datapoint. Right click on the datapoint and in the context menu click on the “Set Autogen” and confirm the dialog by clicking on OK.

Repeat this process for other two IOs. The DO_1.01 will be called a “button_indicator” and DO_1.04 will be called “button_error”.

As you will find out, the digital outputs (DOs) have two datapoints available: DO_X.Y_w and DO_X.Y_r. For now, use the DO_X.Y_w and we will explain the difference in future tutorials.

Now we can switch to the programming window and start placing the IOs to their respective columns. Right click on the input column and in the context menu click on “Global Variables” → “Insert Existing Variable”.

Dialog with all available variables will appear. The list should be very small and apart from some global constants you should see the three variables you have created.