As instruções a seguir servem tanto para Modbus RTU (classe TModBusRTUDriver) quanto para Modbus TCP (classe TModBusTCPDriver). Para configurar um tag+protocolo Modbus você deve:

  1. Inserir uma porta de comunicação apropriada para o protocolo Modbus escolhido:
  2. Inserir o componente de protocolo escolhido.
  3. Conectar o protocolo com a porta, através da propriedade CommunicationPort;
  4. Inserir os tags manualmente ou através da ferramenta “Tag builder”
  5. Caso inserir os tags manualmente, configurar as propriedades conforme descrito a seguir;
  6. Conectar o tag ao driver de protocolo através da propriedade ProtocolDriver presente em cada tag.

 

Ambas classes suportam os seguinte tipos de tags:

  • TPLCTagNumberplctagnumber
  • TPLCBlockplcblock
  • TPLCStructplcstruct
  • TPLCStringplcstring

 

Para configurar um tag para usar o ModBus, é necessário configurar as seguintes propriedades do tag:

  • PLCStation: Endereço do equipamento modbus. Para Modbus TCP, esta propriedade tem seu valor fixado em 1, geralmente, depende da implementação do Modbus Server.
  • MemAddress: Endereço da entrada/saida/registrador que se deseja lêr/escrever. Os endereços começam de zero, sempre. Não use a notaçao de endereço 1xxxxx, 2xxxxx, 3xxxxx, 4xxxxx, pois ela não é suportada.
  • MemReadFuntion: Função que será usada para ler o tag. Veja tabela abaixo.
  • MemWriteFuntion: Função que será usada para escrever valores do tag. Veja tabela abaixo.

Para as propriedades MemReadFunction e MemWriteFunction são aceitos os seguintes valores de acordo com a área de memória desejada:

Área desejada MemReadFunction MemWriteFunction
Entradas digitais 2 0
Saidas digitais 1

5 (TPLCTagNumberplctagnumber)

15 (TPLCTagNumberplctagnumber TPLCBlockplcblock TPLCStructplcstruct TPLCStringplcstring)

Registradores 3

6 (TPLCTagNumberplctagnumber)

16 (TPLCTagNumberplctagnumber TPLCBlockplcblock TPLCStructplcstruct TPLCStringplcstring)

Entradas analógicas 4 0
Status equipamento 7 0

É necessário que você conheça as funções ModBus que seu equipamento suporta.

5 comentários em “Modbus RTU e TCP

  1. Popescu Dragos Responder

    Hi,
    I need to read digital inputs from an ICPDAS modbus module, M-7054, using standard 02 function “(0x02) Read discrete inputs”.
    The string to send into module is “adr_byte 0x02 start_input (2bytes) count (2bytes) CRC (2bytes)”. The response will be according to the standard.

    Please tell me how do I do this, using PascalScada Tags?
    I’m using 0.7.3 version.

    • Fabio Luis Girardi Autor do postResponder

      Hi!

      Few steps:

      1) Insert a TSerialPortDriver into your app and set up it with the same serial settings of your device and activate it.
      2) Insert a TModbusRTUDriver and set CommunicationPort Property to point to Serial Port created on the previous step.
      3) Insert a TPLCTagNumber and set:
      3.1) MemAddress to point to your Digital Input (address starts from zero – 0)
      3.2) MemReadFunction to 2 “(0x02) Read discrete inputs”
      3.3) PLCStation to point to your Modbus slave address;
      3.4) Set property ProtocolDriver to point to ModbusDriver created in step 2.
      3.5) Assure that TagType is pttDefault or pttBit;

      4) Put a THMILabel into your app/form and link it with the tag created at step 3.

      5) If everything is set accordingly, you will see the label showing values 0 or 1, depending on the state of your digital input. The digital input can vary depending on your Modbus device.

  2. jayakrishnan Responder

    Hi fabio

    i have installed the software and done some basic works like configuring modbus device etc, after that i was trying to display the datas in the chart but i was unable to bind the tags to the chart. Could you pls instruct me how to do this and following features like alarming and reporting or pls provide me a deatiled documentation of those above mentioned .

  3. jayakrishnan Responder

    Hi fabio,

    i have installed pascal scada and done some stuff like creating tags and configured a modbus tcp device. when i try to get data of the device to be displayed in the charts provided in the package i was not able to bind the tags to chart. Could you pls tell me how to bind the tags and also an explanation about some features like alarms, reporting etc. Pls provide me a deatiled documentation .

  4. Fabio Luis Girardi Autor do postResponder

    Hi Mr. JAYAKRISHNAN!

    There are missing features on PascalSCADA, due to I have tried to keep it working with Lazarus and Delphi:

    ** Alarm historic
    ** Historic
    ** Recipes
    ** User management stored in file/database;
    ** Tag chart connection.

    Since I cutted off the Delphi support, some things have better progress, since I don’t need anymore to think multiple IDE support. I have two things started, but not finished:

    ** Lazarus TAChart series datasource linked with PLC Tags (started, near to be finished)
    ** Database abstraction (I’m researching the better way to achieve this)

    So, for now, I’ll have to do your chartings using the components of TAChart with few lines of code, to add new values and delete old values.

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *