CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Feb 19, 2019 9:41 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Feb 06, 2019 11:06 pm 
Offline

Joined: Mon Oct 15, 2018 7:47 pm
Posts: 3
I am currently using a HMI/Codesys device to talk to multiple Modbus devices - all this works well, not that it makes any difference everything is in ST as this is all fairly new to me and I come from a software programming background.

I have a new set of devices I need to collect data from however they don't use standard addressing. Everything is in a holding register, from 0-65536. They don't conform to the holding registers being in the 40x range.

When adding a channel I can either enter the address in decimal and it gets converted or enter the hex value, however if I enter 1 for example using function 3 to read holding registers it assumes 40001 but for this device I actually want 00001.

Is this possible with the standard library? Is there any other library which can do it?

Thanks in advance!


Top
   
PostPosted: Thu Feb 07, 2019 1:30 pm 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 100
Wikipedia wrote:
In the traditional standard, numbers for those entities start with a digit, followed by a number of 4 digits in the range 1–9,999:
coils numbers start with 0 and span from 00001 to 09999,
discrete input numbers start with 1 and span from 10001 to 19999,
input register numbers start with 3 and span from 30001 to 39999,
holding register numbers start with 4 and span from 40001 to 49999.
This translates into addresses between 0 and 9,998 in data frames. For example, in order to read holding registers starting at number 40001, corresponding address in the data frame will be 0 with a function code of 3 (as seen above). For holding registers starting at number 40100, address will be 99. Etc.
This limits the number of addresses to 9,999 for each entity. A de facto referencing extends this to the maximum of 65,536.[13] It simply consists of adding one digit to the previous list:
coil numbers span from 000001 to 065536,
discrete input numbers span from 100001 to 165536,
input register numbers span from 300001 to 365536,
holding register numbers span from 400001 to 465536.


source : https://en.wikipedia.org/wiki/Modbus#Coil,_discrete_input,_input_register,_holding_register_numbers_and_addresses

EDIT : To make it clear, if a holding register address is told being 0001, then read it as read code 4 then address 1. But if it's told to be 40001, use read code 4 but address may vary depending the constructor (1 or 40001).


Top
   
PostPosted: Thu Feb 07, 2019 4:35 pm 
Offline

Joined: Mon Oct 15, 2018 7:47 pm
Posts: 3
Hi dFx thanks for the reply.

The 'problem' in theory is, the new device (which is arriving tomorrow so I can start some testing) holds everything in holding registers.

There are no coils, discrete coils or input registers.

So within the device everything from 0 to 65,536 is a holding register.

I have been informed however Codesys doesn't do anything to add the '4'.
So for example one controller I normally use follows the standard, holding registers are in the '4' section, so asking for register 1 function code 3, is the same as 40001.
However Codesys simply asks for register 1 with function code 3, it is the controller that returns the correct register. Because the new controller has everything in holding registers, when Codesys asks for register 1 with function code 3, it will get register 00001.

My confusion came because the HMI which can access tags prefixes the number with the 4 so would only allow access to 9,999 registers which would miss off 55,537 potential registers. I have been informed Codesys will not do this and nothing special needs to be done to make it work!?


Top
   
PostPosted: Thu Feb 07, 2019 4:58 pm 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 100
By default, memory maps are 65536 words long.
There are 4 maps, one for each 1x 2x 3x and 4x codes.
If everything is in 4x code memory map, then, just use the address provided in the supplier memory map, and it should be fine.
I Don't really get your concerns. Maybe it will vanish tomorow ;)


Top
   
PostPosted: Fri Feb 08, 2019 12:24 pm 
Offline

Joined: Mon Oct 15, 2018 7:47 pm
Posts: 3
dFx that is basically what I was told. This is from the controller manufacturer that set the alarm bells off:

Quote:
Controllers support the full modbus address range (0-65535 decimal, 0000-FFFF hexadecimal) therefore to address every register in the module, the Modbus Master system must also support this address range.
All modbus registers are classified as Holding Registers. They can only be read using modbus function code 3 (Read Multiple Registers).

Some modbus masters use a suffix to the address as a way of specifying the function code to use for the query.
For example 41,029 is used to instruct the master to query address 1029 using function code 3.
Some modbus masters also require you to add ‘1’ as previously described.
This means that in many cases the master can read only up to register 9999 (49999 is last register that will be read using function code 3).
These modbus masters are therefore limited and cannot read the full list of registers from the module.


As stated I am using a HMI which includes Codesys, the HMI allows tags and can read from modbus devices, however the programming software does prefix the '4' for holding registers.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited