IDE v2.3.0 and later
====== First project with a Unipi unit ====== Every initial startup guide includes blinking LEDs or switching relays, and this tutorial is not an exception. Using this guide, we will create the simplest project possible with the intent to switch digital output in 5s interval. ;;# Patron \\ Neuron \\ Gate \\ Axon ;;# The following tutorial includes all basic configurations needed to create the core of a Mervis IDE project and to deploy it to Patron, Neuron, Gate, or Axon controller. All following tutorials use this one as their cornerstone. The last chapter of this manual is a well-known flashing diode, i.e. the program in FUPLA blocks switching the digital output. Prerequisites: - PLC Unipi [[https://www.unipi.technology/patron-c44|Patron]] / [[https://www.unipi.technology/neuron-c2|Neuron]] / [[https://www.unipi.technology/gate-c50|Gate]] / Axon - [[https://www.unipi.technology/power-supply-for-din-rail-24v-dc-0-63a-p18|24 V⎓ power supply]] - Downloaded Mervis OS archive for [[en:files:software:os-images:00-start#patron_mervis_os|Patron]], [[en:files:software:os-images:00-start#neuron_mervis_os|Neuron]], [[en:files:software:os-images:00-start#gate|Gate]], or [[en:files:software:os-images:00-start#axon_mervis_os|Axon]] - a computer with [[en:files:software:mervis:00-start#get_the_latest_stable_version|Mervis IDE]] installed {{ :files:img_breakline_2.png?nolink |}} For this tutorial it is NECESSARY to: - [[en:sw:01-mervis:01-mervis-ide|be acquainted with the Mervis IDE]] - [[en:sw:01-mervis:connecting-to-unipi-hidden|connect the PLC to your computer]] - Only for **Patron** PLCs: [[en:sw:01-mervis:running-on-patron-hidden|upload Mervis OS into an Patron controller]] - Only for **Neuron** PLCs: [[en:sw:01-mervis:running-on-neuron-hidden#mervis_na_unipi_neuron_11|deploy Mervis OS to an SD card]] - Only for **Gate** PLCs: [[en:sw:01-mervis:running-on-gate-hidden|upload Mervis OS into an Unipi Gate device]] - Only for **Axon** PLCs: [[en:sw:01-mervis:running-on-axon-hidden|upload Mervis OS into an Axon controller]] - plug in the power supply (wait at least for a minute before the PLC's OS boots up ===== Creating a project ===== In Mervis, a single project (eg. a set of configurations, programs and HMI interfaces) is known as a **Solution**. To create a new **solution** click on **File -> New solution** (Ctrl+N), or click on the {{:files:solution_new.png?nolink|}} icon on the upper ribbon. {{ :en:sw:01-mervis:01_creating-new-project_en.png?direct |}} In the **New solution** dialogue window you need to enter the solution's **name** and the **location** it will be saved into. Fill both fields as required and confirm by clicking on **OK**. {{ :en:sw:01-mervis:02_creating-new-project_en.png?direct |}} The second thing you need to specify when creating a solution is **Mode selection**. The mode determines the behaviour of the Mervis IDE during its use; **Simple Mode** pre-defines the whole core of the solution, i.e. defines basic programs, generates mapping of variables, etc. At the same time, however, this option will limit the selection of the programming method only to **Function Block Diagram (FBD)**. Simple mode is therefore especially suitable for beginners. For more experienced users, there is a **Full mode** from which you can switch to the Simple mode, but this step is irreversible. Full Mode does not create the initial project structure and the entire basic configuration is up to you. That said, it might be convenient (with the exception of some special cases) to create the solution's core automatically in a **Simple Mode** and only then to switch to **Full Mode**. {{ :en:sw:01-mervis:03_creating-new-project_en.png?direct |}} ===== Attaching to the controller ===== Next step in creating a **Solution** is to connect to the running Unipi controller. In the **Left panel** on **Solution** tab, right click on the **PLC** and then click on the **Attach PLC**. {{ :en:sw:01-mervis:04_creating-new-project_en.png?direct |}} The **Attach Controller** dialogue will appear, in which we can specify, how the Mervis IDE should connect to the controller. If the PLC is in the same LAN network, you can use the **UDP Broadcast** and then click on **Next >**. {{ :en:sw:01-mervis:05_creating-new-project_en.png?direct |}} You will now be prompted to enter a username and password (SSCP access) to connect to the controller. The default setting is: **admin / rw**. Now leave and click **Next >**. {{ :en:sw:01-mervis:06_creating-new-project_en.png?direct |}} Next window will show a progress bar as the Mervis IDE is looking for controllers on all network cards your computer has. {{ :en:sw:01-mervis:07_creating-new-project_en.png?direct |}} After the searching is finished, you will be presented with the list of all detected controllers. The target controller has its name displayed in the **Platform** tab. This tutorial used Neuron S103 controller - in your case, choose whatever controller you are using and click on **Next >**. {{ :en:sw:01-mervis:08_creating-new-project_en.png?direct |}} In some cases, you will see a red triangle next to the **Runtime version**. This means the runtime is older than the IDE expects. To fix this problem, follow the [[en:sw:01-mervis:updating-a-runtime-hidden|Updating runtime (RT)]] tutorial. If you see a small skull next to the **Runtime version**, the controller's operating system is outdated and you need to upload a current version of Mervis OS. The guide for uploading Mervis OS for [[en:hw:007-patron:image|Patron]], [[en:hw:02-neuron:image|Neuron]], [[en:hw:025-gate:image|Gate]] or [[en:hw:01-axon:image|Axon]]. The last dialogue of the controller attaching process asks you about configuration download. The configuration holds basic settings of the Unipi controller, such as IP address, usernames and passwords, connections to Mervis DB and Mervis Proxy and so on. When assigning a new controller for the first time, we recommend that you always download the configuration. {{ :en:sw:01-mervis:09_creating-new-project_en.png?direct |}} The controller has now connected. Select the item **PLC** in the left panel, after selecting it the properties of the connected controller will be displayed in the right panel **Properties**. This property panel is crucial, since you are setting up the controller configuration there. The properties include, for example, network configuration, **security**, database connection, SSCP, proxy, etc. After double-clicking on **PLC**, the **PLC** tab will appear in the **main panel** again, where it is also possible to set e.g. user definitions for the web interface (HMI), program mapping and other settings. {{ :en:sw:01-mervis:10_creating-new-project_en.png?direct |}} ===== Securing the controller ===== {{page>controller-securing-hidden}} ===== Connecting the inputs/outputs ===== You now have assigned controller in the Mervis IDE. From a structural point of view, Unipi controllers consist of a computer module and printed circuit boards with inputs and outputs. Those are used by Mervis RT for primary communication via the **Modbus TCP** protocol. An exception is the Unipi Gate series, without inputs and outputs, but it is possible to read the status of the internal storage using Modbus TCP. The above mentioned Modbus TCP communication channel was added automatically with the controller assignment. Below this communication channel, you will also find an automatically inserted modbus table named according to the specific PLC model. {{ :en:sw:01-mervis:11_creating-new-project_en.png?direct |}} ===== Uploading a blank configuration ===== Now we move to the configuration. This part is especially important if you are just starting a new project with a controller or expansion modules that have been used in the past. That's because these devices may have a previous configuration that is independent of the uploaded solution, even the operating system, and may unexpectedly affect the operation of the entire solution. There is no need to worry, just right-click on the modbus table named after the assigned controller in the current clean project and select **Configure Unipi module**. This will load the default configuration. Detailed description of this procedure is in the article: [[en:sw:01-mervis:unipi-configure-module-hidden|]]. {{ :en:sw:01-mervis:12_creating-new-project_en.png?direct |}} ===== Switching to Full Mode ===== As you created the solution in **Simple Mode**, you do not have access to some Mervis IDE functions such as history logs. The advantage of creating a project in Simple mode is that you create the basic structure of the project, including the creation of the main program **main.program.fbd** and the assignment of this program to the PLC task, so it is not necessary to set everything manually. Another advantage is that all data points in device definitions (e.g. in modbus tables) have automatically generated global variables. This is especially useful when getting to know the Mervis IDE to make everything a little easier. With everything required configured, you can switch the solution to **Full Mode**. Right-click on **Solution Name** (first tab) in the **Solution** panel in **left menu**. In the context menu click on **Switch to Full Mode**. {{ :en:sw:01-mervis:13_creating-new-project_en.png?direct |}} A warning will tell you the action is irreversible. Confirm by **OK** to continue. {{ :en:sw:01-mervis:14_creating-new-project_en.png?direct |}} The result is you now have access to other functions. The most visible change occurred in the left panel - at its bottom, the **History log** item appeared. **Executable Projects** now also displays **generated.Mixed.st** file. This file contains variable definitions, in our case automatically generated by the Simple Mode. Don't delete, move or edit this file, its editing and creation are done automatically by Autogen. Autogen serves for automatic generation of variables from data points and can be applied to an entire device containing multiple data points, groups etc. [[autogen-hidden|More about Autogen here]]. {{ :en:sw:01-mervis:15_creating-new-project_en.png?direct |}} ===== Building and Deploying the solution (project) ===== ==== Solution building ==== Solution build compiles all executable projects, HMI interfaces, function libraries and HMI libraries into a single binary file used by the Mervis OS runtime. During the process, the system checks the validity of all configurations and will warn you if anything would prevent a successful compilation. To start the compilation go to the **upper ribbon** and click on **Build Solution**. {{ :en:sw:01-mervis:16_creating-new-project_en.png?direct |}} A **Selected Devices to Build** window will appear - a list of connected controllers the project can be compiled for. By default, the system selects all available controllers, terminals or web interfaces. Confirm your selection by clicking on **OK**. {{ :en:sw:01-mervis:17_creating-new-project_en.png?direct |}} This step will start the compilation itself. The **Results** tab on the **bottom panel** will display any messages displayed during the compilation. The compilation progress can be monitored in the **status bar**. If you performed all the instructions above correctly, the compilation should be completed successfully and the status bar should display **"Solution build succeeded"**. {{ :en:sw:01-mervis:18_creating-new-project_en.png?direct |}} ==== Deploying the solution ==== **Deploying a solution means:** compiling and then uploading the created binary file to the controller and running it in **Full run**. Click **Deploy Solution** on **upper ribbon** to deploy the solution. {{ :en:sw:01-mervis:19_creating-new-project_en.png?direct |}} As with the **solution build**, **Deploy Solution** will also display a list of controllers to deploy the solution to. Confirm your selection by clicking on **OK**. {{ :en:sw:01-mervis:20_creating-new-project_en.png?direct |}} The last step in deploying a solution is to set a new controller status. There are multiple options, but for the purposes of this tutorial, leave the default options and click **OK**. {{ :en:sw:01-mervis:21_creating-new-project_en.png?direct |}} ===== Switching a digital output ===== With the project good to go, we will now move to create your first control program. Its purpose will be to periodically switch the **DO_1.01** output. If this default project is created on a controller without digital outputs, you can also use a relay output, or create your own variable and simulate the output (e.g. for Unipi Gate). “Switch output” means that the output must be set to change values ''True'' and ''False'' repeatedly. The basic executable project was generated automatically in Simple Mode, thanks to which we now have the **main** program available for creating the logic. In the **left panel** double-click on **main.Program.fbd**. {{ :en:sw:01-mervis:22_creating-new-project_en.png?direct |}} A program window will appear in the **main window**. The FUPLA programming space is divided into **three sections** - the left side is reserved for **Inputs** with each grey box available for placing a single input variable. {{ :en:sw:01-mervis:23_creating-new-project_en.png?direct |}} The middle section is called **logic section** and will be used for the programming itself. {{ :en:sw:01-mervis:24_creating-new-project_en.png?direct |}} And finally, the right section is for placing **outputs**. As with the outputs, there is a number of grey boxes for placing output variables. {{ :en:sw:01-mervis:25_creating-new-project_en.png?direct |}} For the demonstration and testing purposes you can create a simple logic for switching the above-mentioned **DO_1.01** (or the alternatives). The entire logic will consist of predefined **function blocks (FB)** available in Mervis libraries. Each FB is designed for one specific function and consists of inputs, internal logic and outputs. The values on the inputs are processed by the internal logic and it then projects the result on the outputs, which can be connected to the inputs of other FBs or to the hardware outputs. Click on **FUPLA Box Explorer** - you can find it among tabs at the left panel's bottom edge. {{ :en:sw:01-mervis:26_creating-new-project_en.png?direct |}} The **left panel's** upper edge includes a search column for quick and easy search for blocks predefined by Mervis. {{ :en:sw:01-mervis:27_creating-new-project_en.png?direct |}} Let's find a pulse generator. Enter **pulse generator** into the search column. As the system searches through function blocks in real-time, the number of results will gradually decrease. After entering the entire name of the block, only a single result will remain - the **Pulse Generator (BD2)** block. Click on it, hold the mouse button and drag the block over to the **logic section**. Then place the block by releasing the button. {{ :en:sw:01-mervis:28_creating-new-project_en.png?direct |}} The **BD2 Pulse Generator** block contains simple logic - by default, the **Out** output periodically switches between ''True'' and ''False'' every second. Let's take a closer look at its inputs. **Enable** input and outputs **Out** and **OutN** are visible on the FB itself. However, if you double-click the block it will change its colour to yellow - an indication of selection. The **Properties** panel will then display a complete list of inputs and outputs. As you can see there are many more inputs than those visible in the main window, as most of the inputs/outputs are hidden by default. Visibility of the individual inputs/outputs can be toggled by the **Visible** property. As we need only the pulse generator's **Out** output, un-check the **Visible** box for all inputs/outputs except **Out**. Bear in mind Mervis IDE does not allow any unconnected inputs in the **logic section** and any attempt to build such a solution will fail. The last step is to set 5s interval for **Ttrue** and **Tfalse** - that will ensure the digital output will switch open/close every 5 seconds. //**Note:**: you can display additional info about any block by selecting it and pressing F1 to open the help page for the block.// {{ :en:sw:01-mervis:29_creating-new-project_en.png?direct |}} You now need to connect the pulse generator's output to **DO_1.01** input (or the alternatives). Right-click on **input section** to display a context menu, move the cursor over **Global Variables** and from the submenu choose **Insert existing variable**. {{ :en:sw:01-mervis:30_creating-new-project_en.png?direct |}} In the **Insert Existing Variable** dialog window, you will see a list of all available variables, inputs and outputs of the controller. If the list is almost empty (this does not apply to Unipi Gate), you do not have Autogen-defined variables available for your PLC. In this case, right-click on the device (modbus table) next to the Modbus TCP channel and select **Set autogen** in the context menu. However, if you followed given instructions, all the variables are generated automatically in the program in Simple mode. **Autogen** performs a one-time generation of variables based on available or selected input and output data points. This means that when adding a device, this list must be generated so that we can use the inputs and outputs of the device in the program. An alternative is to double-click the device to open it at the Modbus TCP channel and set the autogen for a specific data point (here **DO_1.01**) by right-clicking on the data point and then select **Set autogen** in the context menu. You can work with other devices in the same way. The **Insert Existing Variable** dialog window displays a long list of available variables. You can search for the required variable manually, or try to search for it by its name. In this manual, we will enter **DO_** in the search bar, as this is how all digital outputs on the Unipi controller are named. Almost every Unipi controller has 4 digital outputs. Digital outputs are always marked with the key string **DO_y.x**, where **Y** represents the number of the controller section and **X** the number of the specific output. Some output variables, including digital outputs, are marked at the end with the letter **R** or **W**, which indicates whether they are used to read the actual value or to entry. Select **DO_1.01_w** by a click and confirm with **OK**. {{ :en:sw:01-mervis:31_creating-new-project_en.png?direct |}} The output variable appears in the **output section** at the marked location. Now it is necessary to connect the output of the function block of the pulse generator with the variable **DO_1.01_w**. Move the cursor to the black dot next to the **Out** output name of the pulse generator block. A small box will appear containing information about the type of output. {{ :en:sw:01-mervis:32_creating-new-project_en.png?direct |}} Click on the **dot**, hold the mouse button and move the cursor to a similar black dot placed next to the **DO_1.01_w** output. A green line will appear between both outputs. After releasing the mouse button, the line will change to orange. {{ :en:sw:01-mervis:33_creating-new-project_en.png?direct |}} Now you can **Build Solution** - see [[#building_and_uploading_the_solution_project|Building and uploading the solution]]. If you did everything right, a **Build succeeded** message will appear in the **status bar**. **Warning** messages displayed in the **Results** tab can be safely ignored. If the build succeeded and you followed the instructions above correctly, you can **upload** the solution into the controller - see [[#building_and_uploading_the_solution_project|Building and uploading the solution]]. Upon deploying the solution the digital output **DO_1.01** will be switched every 5 seconds. ---- ;#; \\ Congratulations, your first project with a Unipi controller is now complete! ;#; ===== Related tutorials ===== * [[use-mervis-runtime-licence-hidden|]] * [[autogen-hidden|]] * [[attaching-1-wire-devices-hidden|]] * [[weintek-hmi-bacnet-mervis-hidden|]]