send value's of 1 byte to a modbus device

In the editor you can see word, dword and float values, but in some apps like a CoDeSys it is possible to configure a smaller variables like 1 byte.

In the Modbus table of PLC with CoDeSys and any other Modbus-compatible PLC all the data stored in the universal table. This table includes bytes, and when you need to get a 16-bit, you just get 2 slots of this table. So, if you have a 16-bit variable in iRidium and need to read it, you just get 2 bytes and parse it to 1 byte + 1 byte by the next way:

CoDeSys:     | FF | FF |  - two separated registers (addresses)
iRidium got: | FF FF | - only one register (address).

iRidium automaticly converting this data from HEX to DEC, so we get | 255 | 255 |
We have to parse this data back to HEX, divide the low and high byte and convert it back to DEC.

Example:

IR.AddListener(IR.EVENT_TAG_CHANGE,IR.GetDevice("Modbus TCP"),function(item,value) // listener of tag changes for ModBus TCP 
{   
	if (item == "Feedback 1") //set the name of register which should be parsed
		{ 
		// It was DEC value made of 2 bytes in the string format
		var dec2byte = "27542"; 
		// convert it to number, and then in string of 16-bit 
		var hex2byte = parseInt(dec2byte).toString(16); 
		// get the first byte from the string 
		var hexfirst = hex2byte.charAt(0) + hex2byte.charAt(1); 
		// get the second byte drom the string
		var hexsecond = hex2byte.charAt(2) + hex2byte.charAt(3); 
		// get the DEC number from the HEX bytes in string  
		decfirst = parseInt(hexfirst, 16); decsecond = parseInt(hexsecond, 16);  
		IR.Log(decfirst); // first byte
		IR.Log(decsecond); // second byte
});



How to disconnect or reconnect to another Modbus controller

http://wiki2.iridiummobile.net/Multi-design. There you can find the instructions on how to upload several projects on 1 control device. But you can also use the other way: just combine control of several systems in one project. iRidium allows you to add different drivers for connection with different equipment in 1 project and you can display these drivers on different pages of the project. If it is necessary to deactivate some unused systems, you can do it using the SetParameters function (please see the previous e-mail from us). 

You do not need a Device Pro license for the SetParameters function, just a Device license will be enough. You will need a Device Pro license ONLY if you plan to use ready script modules with feedback (Sonos, XBMC, ....)

If you select the Multi-design function then you will need a separate license for each project. If you choose the other option - several drivers in one project - then you can use one license (a standard Device: if you use just one type of equipment or a Full license: if you use different types).

If you need to change IP without closing the project, then it can be done only using scripts. It is easily done - you will have just standard buttons an you can even make an input field (read more).

Modbus Slave, Server mode

This feature implemented. You can use driver "Modbus TCP Server" to make Master-Slave communication between iRidium Clients.

@ModbusServer.irpz
@ModbusClient.irpz

Разделение регистра на биты, запись битов в регистр

Holding и Input регистры можно разделить на отдельные биты для использования в интерфейсе:

IR.AddListener(IR.EVENT_TAG_CHANGE,IR.GetDevice("Modbus TCP"),function(name,value)
{
   switch (name) {
      case "Address 1": 
         var NewValue = parseInt(value.toString());
         var bit1 = (NewValue >> 0) & 0x1;
         var bit2 = (NewValue >> 1) & 0x1;
      break;
      case "Address 2":
         var NewValue = parseInt(value.toString());
         var bit2 = (NewValue >> 1) & 0x1;
         var bit6 = (NewValue >> 7) & 0x1;       
      break;
   }
});
Узнайте больше об iRidium Script:
http://wiki2.iridiummobile.ru/index.php/IRidium_Script_API (RU)

Готовые примеры чтения и записи отдельных битов:
separate bits - read.irpz
separate bits - rw.irpz

Modbus Data Scaling

How to scale incoming values, for or example:
Value 236 degrees, should be shown on screen as 23,6 degrees.
So de value has to be divided by 10, or a function that can shift the decimal point to the left
 
You can do it with help of Script in GUI Editor
http://wiki2.iridiummobile.ru/?title=IRidium_Driver_SDK
http://wiki2.iridiummobile.ru/?title=Drivers_API

Create a new script, initializes devices and make a function for division. The function for division is:

IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("Modbus TCP"), function(name,value){   
   if(name == "nameOFchannel") {
        IR.GetItem("Page 1").GetItem("Item 1").Text = (value*0.1).toFixed(1).toString();    
   }
});

All the sample and script is in the attachment (it will work with Modbus controller or simulation tool)
 
MathExample.irpz


Сервис поддержки клиентов работает на платформе UserEcho