- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-26 04:01 AM
How to read system variables via their Modbus address
Hi all,
I currently read the PLC serial number via the variable name. I'd like to do this by reading the Modbus address. How can I do this?
If you look at the attached images you'll see the code using the full variable name which works, but I can't seem to get the Modbus read on the line below it to be accepted no matter what I do, yet I've seen it online (sods law I can't find it again even if I search my history).
Can somebody tell me the correct syntax structure for reading the system variables?
- Labels:
-
Smart Design & Engineering
- Tags:
- english
Link copied. Please paste this link to share this article on your social media post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-28 01:05 PM
I'm assuming you are talking about an M241 PLC? Based on another entry in the help, it might not be %SW, but %MW. %MW60050 is i_byIPAddress, a read-only System Variable. Try %MW60002.
That said, there is a note in the help which says 60000 to 60034 are "not accessible through the application":
Compare against this, which specifies %MW, and is also a system read-only variable:
Have a play based on that and see what you get. Also try reading both of those registers directly via Modbus tester and see if they are available externally (assuming 60002 = %MW60002 = 460002 or 460003).
It is also possible it is neither %MW or %SW, and may just be the straight Modbus address where 6x is the 'Extended Registers' range that some devices support (but I have never used or seen used).
Link copied. Please paste this link to share this article on your social media post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-28 11:10 PM
Hi @MatthewM,
Many thanks for replying, much appreciated.
The PLC is an M251.
I can definitely read 60002 if I read by 'Var Name', so where it says ''Not accessible through the application'' I wonder if this means only the Modbus reads via %SW and/or %MW are not allowed for that variable.
I will try addressing the Modbus registers directly though as you suggest and report back.
Link copied. Please paste this link to share this article on your social media post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-07-01 10:32 PM
To read system variables using their Modbus address instead of their names, you need to use the correct syntax in your PLC programming. Instead of referring to the variable by its name, you should use the Modbus address directly. Make sure the Modbus read command is formatted correctly for your PLC system. Sometimes, the syntax can be tricky, so double-check your code for any errors in how you're specifying the Modbus address. If you've seen examples online before but can't find them now, try checking your browsing history for reference. This approach should help you read system variables via Modbus effectively.
Link copied. Please paste this link to share this article on your social media post.

