Linux Libnodave example read data from Siemens S7-300
I used Linux Min 17.3, so you can do the same with other Debian based distribution.
-
Step 1 : install mono-complete
- sudo apt-get install mono-complete
- if you want to compile libnodave lib by your self, install c develeop headers
- sudo apt-get install libc6-dev
-
Step 2: download and compile libnodave http://libnodave.sourceforge.net/
- tar xzf libnodave.*.tar.gz
- cd libnodave
- if you are using x64 OS, you need to add CFLAG -fPIC
- just open Makefile, find the line “CFLAGS” and add at the end -fPIC
- make clean
- make
-
Step 3: Now copy libnodave.so and libnodave.net.dll to you project directory
-
Step 4:
- now create your Program, or use my from example (btw: you can download all files, link is below)
-
using System; using System.Threading; using System.Collections.Generic; using System.ComponentModel; public class S7reader { public static void Main(string[] args){ libnodave.daveOSserialType fds; libnodave.daveInterface di; libnodave.daveConnection dc; int res=0; try{ fds.rfd = libnodave.openSocket (102, "192.168.1.60"); fds.wfd = fds.rfd; if (fds.rfd > 0) { di = new libnodave.daveInterface (fds, "IF1", 0, libnodave.daveProtoISOTCP, libnodave.daveSpeed500k); di.setTimeout (10000);//10 seconds dc = new libnodave.daveConnection (di, 0, 0, 2); if (0 == dc.connectPLC ()) { while (fds.rfd>0) { res = dc.readBytes (libnodave.daveDB, 100, 12, 4, null); if (res == 0) { float tmp = dc.getFloat(); Console.WriteLine("DB100.DBD12: "+tmp); } Thread.Sleep (1500); } } } else { Console.Error.WriteLine(DateTime.Now + " :: Error"); } }catch(Exception exc){ Console.Error.WriteLine(DateTime.Now + "Exception: "+exc); } } }
- Step 5: compile this example
-
mcs S7reader.cs -r:libnodave.net.dll -out:./S7reader
-
- Step 6: run the program
-
mono S7reader
-
- Step 7: create you own application
Short Video with all steps:
I need to read data from S7300 PLC (Siemens) to Excel.
My system is 32 bit windows 7.
Kindly suggest the process
Hello,
is this example will working on raspberry pi (raspbian OS)?
Best regards
Yes
Hello again.
I have a little problem. I can’t connect with PLC from raspberry. This is my code https://www.dropbox.com/sh/v000o5jtuzo5kql/AADULNPbg75eGBhqivlSMasla?dl=0
It is working on Windows but when I try to use it on raspberry I receive “Connecting Error!”.
I think there is something wrong with daveInterface or daveConnection.
Best regards
Did you compile Libnodave on Raspberry?
If you mean command “mcs S7reader.cs -r:libnodave.net.dll -out:S7reader” so I did 😉
I use “mcs -t:library libnodave.net.cs” command
but still the same problem
you have to compile libnodave.so for raspberry. the precompiled .so file is for intel.
Hello,
can you help me how to read a string ?
Hello plc2k ,
I need to connect android with plc through the router using libnodave library. Can you please tell me how to import or use libnodave library in android studio.
Any kind of support is appreciated.
Thank you
Hello! I need to connect to Plc with a Raspberry using the libnodave library. Could you help me with how to do this? Thank you
Libnodave, I think it is about lib nodave (surname)
Snap7 project, it is an evolution about libnodave (I think), so you can use snap7 and theirs libraries (java,c, android, raspberry, even esp8266)
Is this procedure compatible with MPI communication? Tks