Asdpoaropuwaodnasnd

Hello.

I have an Arduino UNO board and I want to connect it with a Simenes S1500 PLC via Profinet.

Welcome to the forum

Why did you start a topic in the Uncategorised category of the forum when its description is

:warning: DO NOT CREATE TOPICS IN THIS CATEGORY :warning:

Your topic has been moved to the Programming category

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Hi and welcome. Did you not see the pinned post at the top of this category that says in capital letters "DO NOT CREATE TOPICS IN THIS CATEGORY"?

Have a read of the forum guidelines too as it will help you to get the best out of the forums.

Then please edit your post to enclose your code within the code tags - it's the "< CODE /> " icon.

I've no experience with PLCs, but I wonder if the issue(s) may be to do with the frequency of communication with the PLC.

I guess you're using an Ethernet shield. One problem that I have seen mentioned here on the forums is that some (or all) Ethernet shields only reset at a power cycle, not when the Arduino goes through a reset.

I've compiled your code after installing GitHub - DF-OUTSIDER/Profinet-for-Arduino: Profinet Librarie for Arduino Boards with W5500 Ethernet Module (I do not know if that's the correct library, please confirm). The compilation result is

Sketch uses 15816 bytes (49%) of program storage space. Maximum is 32256 bytes.
Global variables use 1298 bytes (63%) of dynamic memory, leaving 750 bytes for local variables. Maximum is 2048 bytes.

The "750 bytes free" is quite sufficient but the profinet library uses dynamic memory allocation which is not counted in the above results.

S7Client::S7Client()
{
	// Default TSAP values for connectiong as PG to a S7300 (Rack 0, Slot 2)
	LocalTSAP_HI = 0x01;
	LocalTSAP_LO = 0x00;
	RemoteTSAP_HI= 0x01;
	RemoteTSAP_LO= 0x02;
	ConnType = PG;
	Connected = false;
	LastError = 0;
	PDULength = 0;
	RecvTimeout = 500; // 500 ms

#ifdef S7WIFI
    TCPClient = new(WiFiClient);
#endif
#ifdef S7WIRED
    TCPClient = new(EthernetClient);
#endif
}

I do not know how much memory the EthernetClient uses but you might be running out of memory. If I'm right about that

  1. By the looks of it, your Buffer variable might be too big. If I understand the profinet ReadDemo correctly, you don't need that buffer.
  2. If you have a Mega laying around, you can use that for testing purposes to see if the problem still occurs.

The ReadDemo contains the following

// Uncomment next line to perform small and fast data access
#define DO_IT_SMALL
...
...
#ifdef DO_IT_SMALL
  Size=64;
  Target = NULL; // Uses the internal Buffer (PDU.DATA[])
#else
  Size=1024;
  Target = &Buffer; // Uses a larger buffer
#endif

I'm not familiar with the profinet library but have you tried something like that? If I compile that example, as is and with DO_IT_SMALL commented out, there is a significant difference in memory usage.

Your buffer is 200 bytes; does it give problems if you reduce the size to e.g. 100?

An Arduino Mega has significantly more (RAM) memory. If you have one, replace the Uno by the Mega and see if you run into the same problems.

You can also save some RAM by using the F macro for all fixed text that you print; e.g.

Serial.println(F("Cable connected"));

and

Serial.print(F("the value of Servo1 is: "));

That will save 250 bytes of RAM; it might be the life saver if I'm correct about the memory usage being the cause of your problems.

Please post your updated code.

I don't see a Settimino library in your code? Did I miss it? // edit: never mind, timerone, I guess.

I wanted to see where you placed it :wink: I don't know what you exactly used but there is (was) a bug in the Adafruit implementation when using it for AVR based boards like your Uno; see Classic Nano has too much RAM.

And further I unfortunately think that I can't help further.

I guess you don't do something silly, like powering the Arduino with 12volt.
That would explain the Arduino 5volt regulator shutting down after 1-2min and rebooting.
Leo..

Topic locked as OP no longer requires help.

@d4rkkkk please see PM. I have restored your deleted posts. Vandalising a topic risks a complete ban from the forum.

Thanks,