0

I want to read a Analog Input via Modbus TCP from a WAGO AI. The input I am trying to read is connected via a WAGO 753-483 Module. The Ethernet Connection is working via a WAGO Ethernet Controller 750-881. From the documentation I believe that the Voltage should be in input register 29 however the voltage is not switching between ~10V and nearly 0 (which indicates a state that I want to read in). According to my documentation the last two bytes are the High-Byte Data (10) and Low-Byte Data (11).

When I use this tool and when I request Read Discrete Inputs - FC2, FC3 and FC4 I get:

enter image description here

The function has to be inserted code, which limits the use of libraries. I have given the following variables with the addresses:

 byte Read_AI[12]= {0,0,0,0,0,6,1,4,0,29,0,0};       //read Holding register of address 29??
 byte Cell_02_write[12]= {0,0,0,0,0,6,1,6,0,1,0,0};        //write value at address 1

A given function to write a voltage of a analog output would be:

gConnectionSocket = TcpOpen(clientIpAddress,33333); //open socket

void sendCellData(double CellV, byte CellWrite[])
{
  register_val_voltage = (CellV*32767)/10;              //value for register [ x = (CellVoltage * 32767)/10 ] 
  LowByte = register_val_voltage & 0xFF;                
  HighByte = (register_val_voltage >> 8) & 0xFF;        
  CellWrite[10]=HighByte;
  CellWrite[11]=LowByte;
  TcpSend(gConnectionSocket,CellWrite,elcount(CellWrite)); //TcpSend(TCP-Socketname, Modbusprotokoll as Array, Array-size) 
  write("Voltage Data sent"); 
 
  return; 
}

How can I read the information of the Analog Input from Read_AI?

I hope someone can help me and I know this is very limited information as I don't have a lot knowledge in Modbus-TCP.

Markus
  • 51
  • 6
  • 1
    `Cell_02_write` is writing to holding register (function 06) 2. `Read_AI` is a request to read input register (function 04) 30; so to read what you have written you will need to change this to use function `03` (Read Holding Registers) - input registers are read only. Take a look at the [modbus specs](https://www.modbus.org/specs.php) and the results of a search for "c# modbustcp" and have a go at implementing this (happy to help if you run into issues but can't write the code for you). – Brits Aug 30 '22 at 19:51
  • So it should be `byte Read_AI[12]= {0,0,0,0,0,6,1,3,0,29,0,0};` right? – Markus Aug 31 '22 at 07:02
  • It's not really clear from your question; I had assumed you wanted to know what read command you would need to send to read the info written by `Cell_02_write` but am now unsure. Please edit your question and provide full details re what you are trying to read (full model number of the Wago AI unit, state what input you want to read and ideally provide a link to modbus docs for the device). – Brits Aug 31 '22 at 22:46
  • So I would need `byte Request_AI[12]= {0,0,0,0,0,6,1,4,0,29,0,0};` (function code 4) to request read the input register and then `byte Read_AI[12]= {0,0,0,0,0,6,1,3,0,29,0,0};` to actually read the register and get the value? – Markus Sep 06 '22 at 09:27
  • To read what value? (I can say that the `0,0` at the end is wrong - you are requesting 0 registers). Without clarification as to what you are trying to read it's not possible to help. – Brits Sep 06 '22 at 20:01
  • I try to read in the voltage from a WAGO 753-483 Module (https://www.wago.com/ch-de/io-systeme/2-kanal-analogeingang/p/753-483#downloads). The voltage ist switching between ~10V and nearly 0 (which indicates a state that i want to read in). Adress of the module should be 29. According to my documentation the last two bytes are the High-Byte Data (10) and Low-Byte Data (11). – Markus Sep 07 '22 at 08:51
  • That is the physical module but you will be communicating via something [like this](https://www.wago.com/global/i-o-systems/fieldbus-coupler-ethernet/p/750-342) (and any Modbus documentation will be in those docs). I think you are trying to do too much at once (and cannot provide sufficient info to allow help) - I would suggest starting with something like [this tool](http://en.radzio.dxp.pl/modbus-master-simulator/) and confirming that the data you need is available (and which register it is accessible via). Please edit the question when providing extra info (I will try to do this for you). – Brits Sep 07 '22 at 19:54
  • @Brits Yes, I use the WAGO Ethernet Controller 750-881. I had a look at the Modbus Master Simulator but I think [this tool](http://easymodbustcp.net/en/) is better. This is what I get when I request Read Discrete Inputs - FC2, FC3 and FC4 (see edit question) – Markus Sep 08 '22 at 08:03
  • 1
    OK - using whichever tool you prefer, read the range of registers where you think the data is stored (feel free to request 20 registers at once). Then apply voltage to the input and read again - hopefully there will be an obvious change. Note that you might not understand what the data means because I suspect it will be encoded over two registers ([this site](https://www.scadacore.com/tools/programming-calculators/online-hex-converter/) is useful). Be aware that I know nothing about these specific units and they may need configuring before the data is even available. – Brits Sep 08 '22 at 08:21
  • I can read in the expected value now! For the Request `Tx: 00 1C 00 00 00 06 01 03 00 01 00 01` I get `Rx: 00 1C 00 00 00 05 01 03 02 31 0A` as a answer which equals to a voltage of ~11V (the right value). But I can't read it in CANoe yet, I need to figure this out now/will make a new question for this. Thanks a lot! – Markus Sep 09 '22 at 08:54

0 Answers0