Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Ask Me About Webinar: Data Center Assets - Modeling, Cooling, and CFD Simulation
Join our 30-minute expert session on July 10, 2025 (9:00 AM & 5:00 PM CET), to explore Digital Twins, cooling simulations, and IT infrastructure modeling. Learn how to boost resiliency and plan power capacity effectively. Register now to secure your spot!

M340 READ_VAR Fails with 16#0007 Error on Modbus TCP Gateway Communication

Modicon PAC Forum

A forum for topics related to the scope of Modicon PAC offers and ecosystem along the whole lifecycle: Modicon M580 and 340, EcoStruxure Control Expert, EcoStruxure Process Expert (Unity Pro) and more.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Industrial Automation
  • Modicon PAC Forum
  • M340 READ_VAR Fails with 16#0007 Error on Modbus TCP Gateway Communication
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
Trinxs1
Lt. Commander Trinxs1 Lt. Commander
10
YONGHO-KIM
Lieutenant YONGHO-KIM Lieutenant
9
ciupol
Lieutenant ciupol
9
RoozeeR
Lt. Commander RoozeeR Lt. Commander
8
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to Modicon PAC Forum
Solved
kelvinviroja93
Crewman kelvinviroja93
Crewman

Posted: ‎2025-07-23 10:31 AM . Last Modified: ‎2025-07-23 11:05 AM

0 Likes
7
551
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-23 10:31 AM . Last Modified: ‎2025-07-23 11:05 AM

M340 READ_VAR Fails with 16#0007 Error on Modbus TCP Gateway Communication

Hi all,

I'm using a BMEX342020 controller in my project, and I’m not using any physical I/O modules. The task is to read data from several Modbus RTU devices via Modbus TCP gateways.

I’ve used the READ_VAR block to fetch data from the slave devices. The configuration and addressing appear to be correct. However, I’m facing an intermittent issue:

  • Sometimes the READ_VAR block succeeds, and I get correct values.

  • Most of the time, it fails with error code 16#0007.

  • Meanwhile, if I use ModScan or similar tools from my PC with the same gateway and slave, the data is read successfully every time.

Here are some more details:

  • PLC: BMEX342020

  • Protocol: Modbus TCP to Modbus RTU (via gateways)

  • Modbus Gateways: Third-party, configured correctly (as verified with ModScan)

  • Using READ_VAR for polling multiple slave IDs

My questions:

  1. What exactly does error 16#0007 indicate in this context?

  2. Is there any timing or connection-related configuration I might be missing in the READ_VAR setup?

  3. Do I need to handle socket disconnections manually in this kind of setup?

  4. Could this be related to Modbus response timeout, or gateway holding the socket open?

Any insights or experiences from similar setups would be greatly appreciated.

Thanks in advance!

@Trinxs1 @ciupol @YONGHO-KIM @Hennie_Smith 

Attachments
M340 R1.zip
Labels
  • Labels:
  • 00. Read me first
  • 01. Modicon M340 PAC
  • 05. Networking & Communication
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
RoozeeR
Lt. Commander RoozeeR Lt. Commander
Lt. Commander

Posted: ‎2025-08-04 01:30 AM

0 Likes
0
307
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-08-04 01:30 AM

Hello,

I have checked your application and see some timing issues:

1: the READVAR timeout parameter .._GEST[3] is set to 6 (=600mSec), which is higher than the activation period of 350mSec. Please set the activation time to a value higher then the timeout value, or make use the READVAR activity bit to activate the next READVAR.

2: Each gateway has a Modbus timeout defined which is not visible in your application. This timeout should be lower than the timeout of your READVAR. Make sure that the timeout is long enough for each Modus slave to send an answer in time.

Using the current timeout values and activation timeout is causing problems which get worse in time.

Make sure the vales are in line:

  1. Normal worse case response rate of each Modbus device. (example 300 mSec)
  2. Gateway Modbus timeout should be higher than (1) (example 500 mS)
  3. READVAR timeout  should be higher than (2) (example 700 mS)
  4. Activation period as used in your application  should be higher than (3) (example 1000 mS)

When using the activity bit to activate the next READVAR the communication speed can be faster when the Modbus devices respond faster. Check the timings in this example but keep the order as 1-2-3.

R.Roozee
Sr Solution Architect (SAE Master)

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 7
Hennie_Smith
Lieutenant JG Hennie_Smith Lieutenant JG
Lieutenant JG

Posted: ‎2025-07-24 03:10 AM . Last Modified: ‎2025-07-24 03:17 AM

1 Like
0
549
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-24 03:10 AM . Last Modified: ‎2025-07-24 03:17 AM

Hi Kelvin,

There could be various factors but looking at your code I would propose trying:

 

1. On the network settings, change the Bandwidth to 'MASTERED' which will give the CPU more time to process communication.

Hennie_Smith_0-1753349745342.png

 

2. Depending on your BAUD rate to the Serial devices the Timeout of the GEST you set of the 300ms might be too short (especially if the BAUD rate is 9600), have you tried changing the timeout to 500ms?

 

3. In CALL_2 to CALL_6 also add the code to increment your scheduler counter if the activity bit change to 0 like you done for CALL_1. That said, in CALL_1 for the increment of the counter, rather only look at the falling edge of the activity bit and don't include the report status (remove GEST[2]=0). 

 

To answer your specific questions:

  1.  Most likely gateway not responding in time.

  2. No, connections is managed by the CPU, no configuration in programme

  3. No, this is managed by the CPU

  4. Yes which is why I propose setting the timeout to 500ms

 

To have a status bit if the comms to each slave is online you can use a TOF time with GEST[2]=0. Bit will be 1 if comms is healthy

 

Regards,

Hennie Smith

Reply

Link copied. Please paste this link to share this article on your social media post.

YONGHO-KIM
Lieutenant YONGHO-KIM Lieutenant
Lieutenant

Posted: ‎2025-07-24 05:53 PM

1 Like
0
533
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-24 05:53 PM

1) 16#07: Problem in Sending to the Destination
- Please refer to the image below for more details.

YONGHOKIM_0-1753404762781.png

 

2) Ensure Adequate Delay Between READ_VAR Requests
- If the PLC sends requests too frequently, communication errors may occur.
- See the example below for recommended timing.

YONGHOKIM_1-1753404801039.png

 

3) Check Slave Device Response Time and Timeout Settings
- Make sure the slave device is not responding too slowly.
- Also verify that the timeout setting is not too short.

 

4) Verify Gateway TCP Connection Settings
- Check the TCP connection keep-alive time and the maximum number of simultaneous connections supported by the gateway.

Reply

Link copied. Please paste this link to share this article on your social media post.

kelvinviroja93
Crewman kelvinviroja93
Crewman

Posted: ‎2025-07-28 10:20 PM

1 Like
0
457
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-28 10:20 PM

@Hennie_Smith @YONGHO-KIM 

Thank you so much for reply.

 

@Hennie_Smith I have implemented the Bandwidth traffic setting as per your suggestion.

 

@YONGHO-KIM I have programmed the data poll loop as per your example and its working nicely.

Sometimes "startcomms" bit stays 1. need an additional program that reset it if it stays up for some time. 

Reply

Link copied. Please paste this link to share this article on your social media post.

kelvinviroja93
Crewman kelvinviroja93
Crewman

Posted: ‎2025-07-30 02:21 AM

0 Likes
0
414
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-30 02:21 AM

Dear Sir,

@YONGHO-KIM @Hennie_Smith 

 

I have implemented your suggestions in the logic.

 

Now, PLC successfully getting data most of the time, but sometimes anyhow PLC still getting 16#0007 Error on random intervals on random devices. After the data exchange error, in next 1-2 minutes again it is getting healthy.

 

I have attached the screenshot of data and attached the PLC backup, can you please review and suggest the solution for it ?

Attachments
M340 R3.zip
Reply

Link copied. Please paste this link to share this article on your social media post.

Hennie_Smith
Lieutenant JG Hennie_Smith Lieutenant JG
Lieutenant JG

Posted: ‎2025-07-31 10:10 PM

0 Likes
1
384
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-07-31 10:10 PM

Good day,

 

Have you tried slowing the comms down to 500ms instead of 350ms. From the programme it seems you are reading the power meters via a serial to Ethernet gateway, if you poll the gateway to quick, it will not respond if it is still busy on the serial side. 

 

Is there a specific requirement why you need the power meter info faster than 500ms?

 

Regards,

Hennie Smith

Reply

Link copied. Please paste this link to share this article on your social media post.

kelvinviroja93
Crewman kelvinviroja93
Crewman

Posted: ‎2025-08-01 01:19 AM

In response to Hennie_Smith
0 Likes
0
378
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-08-01 01:19 AM

Sir,

I have tried various poll rate and timeout settings, but the result remains the same. At times, the system works flawlessly, but then it generates the 16#0007 error. After a while, it starts working correctly again.

For example, I used a 1-second timer–counter combination to enable each READVAR execution after every 1 second.

What I have observed is that when a READVAR generates the 16#0007 error, that specific READVAR seems unable to send a data request to the slave gateway afterward. In my assessment, this is 99.9% likely related to a PLC firmware issue.

I have also attempted to use the CANCEL function to neutralize the communication after each READVAR execution, but the behavior remains unchanged.

Reply

Link copied. Please paste this link to share this article on your social media post.

RoozeeR
Lt. Commander RoozeeR Lt. Commander
Lt. Commander

Posted: ‎2025-08-04 01:30 AM

0 Likes
0
308
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-08-04 01:30 AM

Hello,

I have checked your application and see some timing issues:

1: the READVAR timeout parameter .._GEST[3] is set to 6 (=600mSec), which is higher than the activation period of 350mSec. Please set the activation time to a value higher then the timeout value, or make use the READVAR activity bit to activate the next READVAR.

2: Each gateway has a Modbus timeout defined which is not visible in your application. This timeout should be lower than the timeout of your READVAR. Make sure that the timeout is long enough for each Modus slave to send an answer in time.

Using the current timeout values and activation timeout is causing problems which get worse in time.

Make sure the vales are in line:

  1. Normal worse case response rate of each Modbus device. (example 300 mSec)
  2. Gateway Modbus timeout should be higher than (1) (example 500 mS)
  3. READVAR timeout  should be higher than (2) (example 700 mS)
  4. Activation period as used in your application  should be higher than (3) (example 1000 mS)

When using the activity bit to activate the next READVAR the communication speed can be faster when the Modbus devices respond faster. Check the timings in this example but keep the order as 1-2-3.

R.Roozee
Sr Solution Architect (SAE Master)
Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

Welcome!

Welcome to your new personalized space.

of