Codesys 2.3 Wago 750-881 Modbus setup suggestions for fancoil control

jorbe

Member
Join Date
Apr 2023
Location
Norway
Posts
1
Hi,
I have never used modbus communication in Codesys 2.3, any tips and tricks are much appreciated.

The system is a Wago 750-881 that controls HVAC.

The building has 5 fancoils with a room thermostat with RS485 to read temperature and control:
Fan speed
Cooling ON
Heat ON
Set temperature
ON/OFF
etc.
For this task i have bought a 750-652 modbus card.

The rom thermostat is a ''generic'' alibaba thermostat sold under many different names:
ALTOC VTM10 Norwegian....

Is there anyone that knows about any libraries or functions from wago/oscat etc that already have this functionality or something similar that i could use for this application.

I started to try and do this the hard way and found the modb_l05-V2 library from Wago, but i can't figure out how to do the mapping of the adreses.
I am clueless of the way forward, and if i have to create a function block for each slave.
In the guides and videos found only i mostly find mapping and setup of modbus in codesys 2.3 over ethernet.
 
It can be difficult, in a modbus request there is a prefix i.e. 0 coils, 1 discrete inputs, 3 input registers, 4 holding registers, depending on the prefix it will request/write to an address space between 0 to 65535, so for example you request one register from holding registers the actual register will be 400001 but your data will request holding register 0, a further complication is that there are two modes 0 indexing & 1 indexing 0 indexing relates to register 400000 & 1 indexing relates to 400001, you need to read this document or many others that are out there. There are other complications as MB is a simplistic 16 bit system so floats will be 2 16 bit words, however, these may also need byte swapping. As you have a MB card I assume you will only need to populate certain bytes i.e. the slave number, function code, start address & number of 16 bit words to read or write etc. the other bits like CRC check etc. should be done by the card. here is a link to a description of MB

https://www.ni.com/en-gb/shop/seaml...sory-system/the-modbus-protocol-in-depth.html
 
The biggest problem in Modbus is determining whether each end of the Modbus connection uses 1-based or 0-based addressing.

I would take three steps before trying to connect the Wago Modbus card to the thermostat:

  1. Connect a PC with Modbus Client software to the thermostat, assuming the thermostat is a Modbus Server.
    1. Often the manufacturer of a Modbus-capable device will supply Modbus Client software for a PC, and that software can communicate with the device.
    2. Searching The Google for "modbus client windows free" should provide some simple options
    3. Making this configuration work will ensure you know how to connect to the thermostat, and that the thermostat is working.
    4. In addition, some Modbus Client packages will allow you to log and review the raw Modbus protocol, which may simplify any debugging
      1. Especially regarding 1-based vs. 0-based addressing.
  2. The Wago 750-653 Modbus card with a PC running Modbus Server software.
    1. Again, minimal Modbus servers are available via a search of The Google.
    2. Again, logging and reviewing the raw Modbus protocol will make debugging easier.
  3. Find and read the documentation for the thermostat Modbus device, especially regarding the memory map, and the pinouts of any connection if it uses Modbus RTU (serial line).
Finally, trust what you learn from items 1 and 2 above (actual tests that show how something works), but always hold in suspicion what you see in 3 (the published manual).

I'll post a background summary of Modbus shortly.
 
Last edited:
Expanding on what @parky said, Modbus is at its core a wire protocol to map memory between a server and clients.

The Modbus specification and related documents are available here: https://www.modbus.org/specs.php.

The particular type of wire used (TCP/IP; RS-485; RS-232) will determine how the clients and server are connected, and how many clients and servers can be on the wired "network."

The protocol definition, including dialects and details for different wire types, are available at the link above. See also Note 1 below.

The memory map refers to memory, or data, locations on (in) the server. The Modbus memory model recognizes four regions, or types, of memory

  • Discrete Inputs: 1 bit per address; read only; examples are the states of proximity sensors or level alarms
    • Note that when there is a client protocol request to read Discrete Input data, the bits will be packed into 16-bit integers
  • Coils (Discrete Outputs): 1 bit per address; read and write; examples are Cooling ON/OFF or Heating ON/OFF
  • Input Registers: one 16-bit integer per address; read only; examples are current temperature or device firmware revision.
  • Holding Registers: one 16-bit per address; read and write; examples are temperature setpoint or a calibration constant.
See also Notes 1 and 2 below.

The clients use the Modbus protocol to issue requests to a server read data from, or write data to, memory locations within the data regions (defined above) on the server. Such requests will identify the server with a 1-byte, 8-bit, ID with a value between 1 and 247. The server typically returns a response to the request.

Note 1) The Modbus wire protocol details are fixed, but how any one client's software presents an interface or instruction to that protocol can vary widely between different manufacturers, specifically

  • Whether the memory addresses in the client interface or instruction are 0-based or 1-based
  • How the client interface or instruction specifies the combination of operation and data region for a request. See Note 3 below
    • operation:
      • reading data from the server device memory;
      • writing data to the server device memory.
    • data region (type):
      • Discrete Inputs;
      • Coils;
      • Input Registers;
      • Holding Register.
Note 2) The physical location of the different memory types (regions) in a Modbus server device's memory is arranged at the sole discretion of the device manufacturer. The memory regions could be contiguous with (adjacentt to) each other, discontiguous, or overlapping. The only relevant document is the published memory map of the available inputs, outputs and registers.

Note 3) Within the Modbus protocol, a client request the the combination of operation and data region via a single function code e.g.

  • Function Code 0x01 and 0x15: these codes both access the same discrete 1-bit "Coils" region of memory of a server device, but
    • Function Code 0x01 is for reading coils, i.e. the client will receive Coils' data from the server device:
    • Function Code 0x15 is for writing coils, i.e. the client will send Coils' data to the server device.
A alternate approach of many clients is to specify the operation and data region (type) separately. Specifying the operation (read or write) is straightforward. However, the most common convention to specify which data region to access is to prepend a numerical prefix to the address. So configuring a client to read the first Holding Register might require specifying two separate items to create a request:

  1. Configure to Read
  2. Configure an "Address" of 400000 (or 400001)
Where that leading 4 is not actually part of the Modbus address, but is instead a common, but non-Modbus, convention prefix to point to the Holding Register region out of the four data regions.

And as if that is not confusing enough, note that

  • to read Holding Registers the Modbus protocol will use Function Code 0x03 (so function code to read "address| "4"xxxxx.
  • to read Input Registers the Modbus protocol will use Function Code 0x04, and the prefix convention for Input Registers is 3.
 

Similar Topics

Codesys Ethernet IP Scanner - Won't connect to a Wago 750-353. The Ethernet device and the Ethernet IP Scanner are both running. but then I go...
Replies
2
Views
1,668
Hello, Maybe it is just a simple problem, but I cannot solve it. I have a Wago 750-881 connected to a Beier HMI through IP TCP, the connection is...
Replies
0
Views
894
Hello, I have recently started learning how to program PLCs using CoDeSys v 2.3 and a Wago 750-871 controller. Thanks to a couple of forum...
Replies
9
Views
3,521
I am using Codesys and have an offline copy of the PLC program. I am trying to login to a Wago 750-881 that supposedly has the same program...
Replies
1
Views
4,498
Hi id like to connect my wago controller with mitsubishi hmi and im using codesys 2.3 and gx designer 3. Id like to know how i know what register...
Replies
5
Views
4,664
Back
Top Bottom