thiagoralves
Hello OpenPLC Community
 
Thanks to @davenardella OpenPLC runtime (for Linux and Windows only) now supports Siemens S7 protocol! Take a look at the documentation he added on the repository here: https://github.com/thiagoralves/OpenPLC_v3/blob/master/documentation/S7-Protocol/Siemens%20Protocol%20driver%20for%20OpenPLC.pdf
 
You will have to reinstall your runtime using the latest release (2025-03-17) to be able to use S7. Let us know if it is working for you 🙂
Reply 3 0
epgodoy
Amazing news!
Reply 1 0
fg71
I'm really impressed how easy its for @davenardella to do thing in short time and his excellent documentation how to use it.
Reply 0 0
davenardella
I'm really impressed how easy its for @davenardella to do thing in short time and his excellent documentation how to use it.
Thanks 🙏
even though I will have to change it soon. 😂

Thiago and I decided to make the activation/deactivation of S7 smarter.
So I modified the settings page and the DB to contain the option.

Now I'm testing it, stay tuned...😉
 
s7web.png
Reply 1 0
fg71
Now I'm testing it, stay tuned
It looks great, could I ask you something about WinCC Unified, when I was asking CoPilot about JavaScript function DBRequest it was telling me it was used by Siemens and WinCC Unified and LOGO Web Editor. I'm doing some reverse engineering to understand Siemens LOGO HTTP server that make it possible to have HMI on the local network to control the LOGO hardware.
 
I have a Giga r1 and it has USB port so I was thinking why not build a HMI interface and store it on USB stick.
 
Its kind of same approach LOGO does it with sd-card.
 
So my question is DBRequest a common JavaScript function also for WinCC ??
Reply 0 0
davenardella
Siemens discontinued the LOGO driver for WinCC starting from V18.0 (in the Communication driver you cannot chose LOGO anymore).
I honestly didn't even know about DBRequest 😁, generally they are functions added as third parties (WinCC Unified is very extensible).
Anyway, you can find some information about HTTP calls here.
 
I have a Giga r1 and it has USB port so I was thinking why not build a HMI interface and store it on USB stick.
Its kind of same approach LOGO does it with sd-card.
 
Maybe an Ethernet shield, which has the SD card too, could be more suitable.
 
In my opinion, mimicking the HTTP-REST LOGO protocol might be the least convenient method.
I would prefer Modbus (which is the preferred method to communicate with LOGO together with S7 Protocol), which is fully supported on GIGA-R1 😉
 
Just as example, here you can find how to communicate with LOGO using Modbus (the article is in Italian language, but Google makes a good work).
 
 
Reply 0 0
fg71
LOGO driver for WinCC starting from V18.0 (in the Communication driver you cannot chose LOGO anymore

Siemens have/had Siemens LOGO Starting kit there KPT basic line of display was included. The license of WinCC is basic version. It could be that LOGO communication driver only support the legacy display KPT basic. This legacy display I believe are no longer maintained by Siemens so maybe thats why they remove it in V18.

And from Siemens Catalog I do not find 6AV2132-0KA00-0AA1 anymore.

I did know that KPT basic panels are legacy product and based on old Microsoft technology 😉, WinCE 6.0 I believe

Reply 0 0
fg71
I try your Settimino with Giga r1 to connect to LOGO but I never got it to work.
 
The Giga is connected to my router, next
 
S7Client Client;
Client.SetConnectionParams(PLC, 0x03, 0x02);
Client.Connect()
 
When I read your documentation it looks to me this will work but the problem is Client.Connect() that do not work for me.
Any hint why ?
 
I have also tested Nano ESp32
 
Reply 0 0
davenardella
I try your Settimino with Giga r1 to connect to LOGO but I never got it to work.
 
The Giga is connected to my router, next
 
S7Client Client;
Client.SetConnectionParams(PLC, 0x03, 0x02);
Client.Connect()
 
When I read your documentation it looks to me this will work but the problem is Client.Connect() that do not work for me.
Any hint why ?
 
I have also tested Nano ESp32
 
I like your enthusiasm, but this is the OpenPLC News board, LOGO and Snap7/Settimino are quite OT.😉

That said, the tests I did with LOGO at the time required Local TSAP and Remote TSAP to be 0x0300, 0x0200, not 0x03, 0x02.
Try one of the Snap7 demos first, the error detected is more explanatory.
Reply 0 0
fg71
My understand that newer LOGO do not use TSAP that was used for older LOGO.
 
Here is words from Helmut himself (long time Product manager for LOGO)
Basically TSAP (Transport Service Access Point) is comming from the past where Controller havn't had Ethernet on board.
At this time Ethernet was only possible via CP connected mostly to EM-Bus and so the CP has to know the position in the configuration.
Today it is RACK and SLOT.

If you configure a LOGO! - LOGO!) then each chanel get its own TSAP.
LOGO! supports 8 chanels. If you configure it for LOGO! - LOGO!, then the first Ethernet connection
will get TSAP 20:00, second 21.00 und so on.

HMI is different. If you enable to use a HMI, then the HMI requires the TSAP 02.00 at the controller side.
So if you do a LOGO! - LOGO! exchange then you have to use right TSAP. If not it will not work.
 
So of course I need to test it and s7Client.ConnectTo(PLC, 0, 0); also work with LOGO 8.3
 
I could inform you, I solve it by update the platform.h and include
#ifdef ARDUINO_GIGA
  #include <WiFi.h>
  #define S7WIFI
#endif
And here is the example using WriteBit
#include <Platform.h>
#include <Settimino.h>

IPAddress PLC(PLC_IP);   // PLC Address

char ssid[] = "SSID";
char pass[] = "PASSWORD";

S7Client s7Client;

void setup() {
    Serial.begin(115200);

#ifdef S7WIFI    
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid, pass);
    while (WiFi.status() != WL_CONNECTED)
    {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.println("WiFi connected");  
    Serial.print("Local IP address : ");
    Serial.println(WiFi.localIP());
  #endif

    s7Client.SetConnectionParams(PLC, 0x03, 0x02);
    s7Client.Connect();
    Serial.println(s7Client.Connected);
}

void Dump(void *Buffer, int Length)
{
  int i, cnt=0;
  pbyte buf;
  
  if (Buffer!=NULL)
    buf = pbyte(Buffer);
  else  
    buf = pbyte(&PDU.DATA[0]);

  Serial.print("[ Dumping ");Serial.print(Length);
  Serial.println(" bytes ]===========================");
  for (i=0; i<Length; i++)
  {
    cnt++;
    if (buf[i]<0x10)
      Serial.print("0");
    Serial.print(buf[i], HEX);
    Serial.print(" ");
    if (cnt==16)
    {
      cnt=0;
      Serial.println();
    }
  }  
  Serial.println("===============================================");
}

void loop() {
  void *Target;
  int Result;

  //Target = NULL;
  //Result = s7Client.ReadArea(S7AreaDB, 1, 2, 64, Target);
  //Serial.println(Result);
  //Dump(Target, 64);

  s7Client.WriteBit(S7AreaDB, 1, 2, 0, true);
}
 
Reply 1 0
tejonbiker
Sounds like a great good news!!, congrats @davenardella!, I was thinking about this some weeks ago when I started to play with s7server, but the match with DB always make a mess in my mind, as far I can see you declared static relationship with siemens variables (DB) and OpenPLC vars, I was thinking to add some type of option to upload a config file with the relationship/mapping, this because I was thinking to use OpenPLC to simulate things in a project that already have defined DBs.
Reply 1 0
davenardella
Sounds like a great good news!!, congrats @davenardella!, I was thinking about this some weeks ago when I started to play with s7server, but the match with DB always make a mess in my mind, as far I can see you declared static relationship with siemens variables (DB) and OpenPLC vars, I was thinking to add some type of option to upload a config file with the relationship/mapping, this because I was thinking to use OpenPLC to simulate things in a project that already have defined DBs.
Do you mean making the DB number association editable (red rectangle in the image)?
map.png
 
That should be quite simple, you just need to change the switch in oplc_snap7.cpp 😉
Changing, as example , case 1002: to case my_int_memory_DB: where my_int_memory_DB is the var containing the loaded association.
 
 
switch.png
Reply 0 0
Reply