Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:sw:01-mervis:connecting-to-unipi-extension-hidden [2018/06/19 14:02]
martin_kudlacek [HW connection]
en:sw:01-mervis:connecting-to-unipi-extension-hidden [2021/08/05 12:30] (current)
avsetula
Line 1: Line 1:
-====== Connecting to UniPi extension ====== +====== Connecting to Unipi extension ====== 
-The UniPi extensions are convenient way how to extend the number of inputs and outputs at one locationor make accessible at another one. +<WRAP group> 
 +<WRAP half column 81%> 
 +The Unipi extensions are convenient way how to extend the number of inputs and outputs at one location or make accessible at another one. 
  
-The communication between controller and extension is via RS485 ports. The extension acts as a Modbus slave, which has an extended support in the Mervis. ​+The communication between controller and extension is via RS485 ports. The extension acts as a Modbus slave, which has extended support in the Mervis. ​ 
 +</​WRAP>​ 
 +<WRAP half column 15%> 
 +;;# 
 +<​html><​span class="​dev-tag dev-patron">​Patron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-neuron">​Neuron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-gate">​Gate</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-axon">​Axon</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-extens">​Extension</​span></​html>​ 
 +;;# 
 +</​WRAP>​ 
 +</​WRAP>​
  
 ===== HW connection ===== ===== HW connection =====
-You need only two cables to connect the UniPi extension to the controller. Just interconnect the RS485-A port on the controller to RS485-A port on the extension and RS485-B on the controller to RS485-B on the extension.+You need only two cables ​(e.g. JYSTY 2x0.8) ​to connect the Unipi extension to the controller. Just interconnect the RS485-A port on the controller to RS485-A port on the extension and RS485-B on the controller to RS485-B on the extension.
  
-{{ :en:​sw:​01-mervis:​connecting-the-unipi-extension-01-hw-connection.png?​direct ​|}}+{{:cs:​sw:​01-mervis:​connecting-the-unipi-extension-01-hw-connection.png|}}
  
-For communication ​to work, you have to have identical serial port parameters ​on both sides speed, data bits, stop bits and parity. ​ Also each extension unit has to have unique Modbus address. You can set those in two ways+===== Module addressing and communication parameters ​===== 
 +{{page>​en:​hw:​04-extensions-communication-hidden}}
  
-==== DIP switches ​==== +===== Using Unipi extension in the Mervis ===== 
-The DIP switches are small leverswhich can be pushed down, or pulled up. When the lever is pushed downthe function ​is enabled.+Let's assume you have a basic project in **Full mode**you are attached to the controlleryou have **Executable project** with one **FBD** program and this program ​is configured as a sole **Task** of the PLC. And you **Set Autogen** on the Unipi deviceYour workspace should look like this:
  
-On model xS10, xS30 and xS40, you can set the speed, parity and address by DIP switches. On the xS50, only the DIP switches for address are present on the unit.+{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-02-workspace.png?direct |}}
  
-The first DIP switch ​is called ​**RS485-END**. It is for connecting ​and disconnecting 120ohm resistor between RS485-A and RS485-B for proper termination of the RS485 bus. You will have to enable this option ​when the extension is last device on the bus. Typically, this applies to very long buses, over several 100s of meters.+As we stated previously, the communication with Unipi extension ​is via Modbus RTU. To create a channel by right-clicking on the PLC in the **Left panel** and selecting ​the **Add Channel** ​option.
  
-Second DIP switch is omitted, without any function.+{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-03-add-channel.png?direct |}}
  
-The third to sixth DIP switch is for setting addressWith these switchesyou can set address from 0 - 15 in binary format.+A new channel will appear under the PLC. Select it and in the **Properties panel** change the **Name** ​to something more descriptive,​ like **ModbusRTU**Alsochange the **Protocol** to **Modbus**.
  
-^ Address ^ DIP sw. 3 ^ DIP sw. 4 ^ DIP sw. 5 ^ DIP sw. 6 ^ +{{ :en:sw:​01-mervis:​connecting-the-unipi-extension-04-channel-name-and-protocol.png?​direct ​|}}
-| 0       | OFF       | OFF       | OFF       | OFF       | +
-| 1       | ON        | OFF       | OFF       | OFF       | +
-| 2       | OFF       | ON        | OFF       | OFF       | +
-| 3       | ON        | ON        | OFF       | OFF       | +
-| 4       | OFF       | OFF       | ON        | OFF       | +
-| 5       | ON        | OFF       | ON        | OFF       | +
-| 6       | OFF       | ON        | ON        | OFF       | +
-| 7       | ON        | ON        | ON        | OFF       | +
-| 8       | OFF       | OFF       | OFF       | ON        | +
-| 9       | ON        | OFF       | OFF       | ON        | +
-| 10      | OFF       | ON        | OFF       | ON        | +
-| 11      | ON        | ON        | OFF       | ON        | +
-| 12      | OFF       | OFF       | ON        | ON        | +
-| 13      | ON        | OFF       | ON        | ON        | +
-| 14      | OFF       | ON        | ON        | ON        | +
-| 15      | ON        | ON        | ON        | ON        ​|+
  
-==== Software settings ​==== +Leave the **Link Protocol** to **Serial**, but change the **Port Number** to the serial port on your PLC. Our testing Unipi Neuron L503 is equipped with two RS485 ports, and we will use the one on the 1st group. 
-The connection parameters can be set in SW. The HW settings ​takes precedenceso in order to SW to tsup+ 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-05-port-number.png?​direct |}} 
 + 
 +We will also change the **Baud Rate** (a.k.a speed) to 19200, as it is a default value for Unipi'​s extensions. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-06-baud-rate.png?​direct |}} 
 + 
 +Now we can add the device and we can do it in two ways. You are used to right-clicking on the channel name and then clicking on the **Add Library Device** and then selecting the proper device from the list. This will work, but with Unipi extensions, you can let the Mervis detect all the units on the bus automatically and add all of them at once.  
 + 
 +<WRAP center round tip 60%> 
 +When a new channel is added, the autodetection will not work until you deploy the solution, because the PLC doesn'​t know this channel yet. 
 +</​WRAP>​ 
 + 
 +To autodetect the devices, right-click on the channel name in **Left panel** and in the context menu click on the **Unipi - Modules autodetect**. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-07-autodetect.png?​direct |}} 
 + 
 +You will be probably presented with dialogue warning you, that the autodetection needs to be executed while the PLC is in the **Commissioning mode**. The Mervis will offer you to switch to this mode and after the detection, it will switch back to the previous model. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-08-switch-to-commisioning.png?​direct |}} 
 + 
 +Next dialogue will ask you for the range of Modbus ID's the autodetect will look for. You can leave the default 1-15. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-09-id-range.png?​direct |}} 
 + 
 +The detection has finished and you can see a list of Unipi extensions on your RS485 bus. You can tick the **Import** checkbox and import their definitions. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-10-import.png?​direct |}} 
 + 
 +And confirm the restore to the previous mode. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-11-restoring.png?​direct |}} 
 + 
 +A new device(s) will appear under the channel. You should rename them to something more descriptive,​ e.g. by their purpose or location. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-12-device-name.png?​direct |}} 
 + 
 +Also, run **Set Autogen** on the device to generate all the variables which the extension has. 
 + 
 +Turn on the **Debugging** and select the **Variable browser** tab in the **Main window**. Under the name, search for the name you gave the extension (in our case the **boilerRoom**). In the browser, you should now see only the variables for the extension and their current values. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-13-variable-browser.png?​direct |}} 
 + 
 +You can try changing the values of boilerRoom_ULED_1.01 and you should see the LED X1 on the extension turn ON and OFF. 
 + 
 +===== Reconfiguration of the Unipi extension ===== 
 +We already learned that you can set a subset of the communication parameters by HW DIP switches. Now we will learn, how to set those in Mervis. 
 + 
 +To set the parameters, you need to have a working ​connection ​with the extension. We already have this in our current project, so let's continue. 
 + 
 +The parameters ​are configured on the device itself. Select the extension in the **Left panel** and check the properties on the **Left panel**. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-14-extension-properties.png?​direct |}} 
 + 
 +In Mervis, we can set **address**,​ **baud rate** and **parity**. The **data bits** will always be **8** and **stop bits** will be **1**. So let's change the parameters to address = 12 and baudrate = 115200. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-15-changed-properties.png?​direct |}} 
 + 
 +To save these settings, ​you need to configure the module. Right-click on the extension ​in the **Left panel** and in the context menu, click on **Unipi - Configure module**. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-16-configure-module.png?​direct |}} 
 + 
 +You will probably be asked to switch ​to **Commissioning mode** as with the autodetection. After confirmation,​ you will see a progress bar of the configuration. After the configuration finishes, confirm the dialogue by clicking on **OK** 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-17-configuring.png?​direct |}} 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-18-configuration-finished.png?​direct |}} 
 + 
 +<WRAP center round tip 60%> 
 +We downloaded the configuration into the extension, but to apply the settings, you need to restart the extension as well. 
 +</​WRAP>​ 
 + 
 +Now that we changed the configuration of extension, we need to do changes in the project as well. Remember, that our ModbusRTU channel is configured to 19200bps. We need to change it to 115200bps to match the speed of the extension. You should know the drill: select the channel in **Left panel**, change the **Baud Rate** property in the **Properties panel** to **115200** and don't forget to **Deploy** the solution afterwards. 
 + 
 +If you run the **Unipi - Modules autodetect** again, you should find the extension on new address 12. You could import the new device, but then you would have two devices under the ModbusRTU channel. An easier way is to change the communication address in the current device'​s properties. Select the extension in the **Left panel** and in the **Properties panel** check the **Modbus Device Parameters**. 
 + 
 +{{ :​en:​sw:​01-mervis:​connecting-the-unipi-extension-19-changing-device-address.png?​direct |}} 
 + 
 +Change the **Device Address** to match the **Module SW Address**, **Deploy** the solution and start the **Debugging**. In the **Variable browser** you should see all the properties and their current value.