TwinCat 3 Siemens PLC MODBUS TCP communication - tcp

My question is quite simple. Is it possible to communicate TwinCat PLC simulation (TwinCat 3 on normal PC) with real siemens S7-1200 over MODBUS TCP?
From what I've gathered, PC without Intel chipset network card prevents you from using protocols like EtherCat or Profibus. Nowhere in documentation is stated that Modbus TCP requires such card.
I've been trying to use Modbus TCP sample program from Beckhoff site for two days now, with no success. TCPView shows that connection between server (PC with TwinCat) and client (S7-1200) is "established" and even some packets are being exchanged. I'm pretty sure that the adressess and lengths and all that stuff are correct, yet TwinCat still gives me ERROR 26.
On the Siemens side MB_Client shows 7004 then 7005 and 7006 one after the other with no data coming to my array.
Is there something to do on the TwinCat side other than coping the sample code and changing the parameters, that i need to do? (I also set up the server with TcModbusSrvCfg.exe)
Sorry for the long post. If you have any ideas about what else i can do, plaase share.

Like Kolyur said, please check that TF6250 is installed on your machine.
As complement of Cliff response here are 3 tools to check your Modbus protocol on both sides :
Ananas,
Modbus Doctor,
Modbus Twin Request
Which Modbus function did you implement you could just try a simple Modbus write register (function 16).

My question is quite simple. Is it possible to communicate TwinCat PLC
simulation (TwinCat 3 on normal PC) with real siemens S7-1200 over
MODBUS TCP?
In answer to your question. Yes!! Absolutely you can!!
Is there something to do on the TwinCat side other than coping the
sample code and changing the parameters, that i need to do? (I also
set up the server with TcModbusSrvCfg.exe)
So part of your problem may be in this statement here. Using TcModbusSrvCfg.exe sets up the TwinCat PC Modbus TCP server, but the sample code provided in the manual is the TwinCat program acting as a Modbus TCP client. From your question it isn't 100% clear to me what you are trying to achieve.
The manual in section 2 (page 8 at the time of writing) shows the two different ways it can be setup. In the picture below;
the red line with a (1) next to it shows TwinCAT acting as a Modbus TCP Server, and
the red line with a (2) next to it shows TwinCAT acting as a Modbus TCP Client.
From your question it sounds like you have setup a Modbus Client on your siemens. If this is the case, you do not need to implement any example code in your TwinCAT program. The example code provided in the manual is for when Twincat is acting a Modbus Client. I think what you are probably looking for is to follow what is in section 4.
From a high level, the TwinCAT Modbus TCP server maps Modbus Registers to TwinCAT Memory areas. You would need to create TwinCAT tags and assign these tags to the appropriate memory areas. You can view the default mapping in section 4.3 or you can use the "Export Configuration" function on the Configuration tool to export an XML file where you can customize your mapping, and then import it again and apply the changes.
I don't know a lot about seimens, but to me it sounds as if your siemens client is actually connecting to the TwinCAT modbus server, however you have not created the relevant TwinCAT tags at the appropriate memory areas/address. If you want the seimens to read data from TwinCAT, then you will need to populate data in tags assigned to the memory areas in TwinCAT. If you want the siemens to write data to TwinCAT, then you will need to add tags in TwinCAT (again at the correct memory area) to view the data.
If however you do want TwinCAT to act as a client connect to a modbus server, you would need to following section 6.

Seems like the problem has to do directly with the configuration of your conection, the hardware itself shouldn't cause any problems with the connection and just like -kolyur said, for test you should deactivate the pc firewall.
As for the modbus server setup, you have to run the "TcModbusSrcCfg.exe"in your computer and set default parameters (to use your computer as server trough port 502), once you make a sucessfull conection with the PLC Siemens at port 502 (default configuration) you can try to modify the program.
The Beckhoff documentation already tells you the libraries, functions and values you should use for a default connection, just make sure you follow the server configuration steps, cause' in the past I had many issues with modbus just for not setting the modbus server right
I used this sample FB for modbus communitation to read from a Modbus Festo Master for IO Modules if you want to compare your variable values.

Related

Serial communications over stlink with stm32f4discovery, is it possible?

I have the following: STM32F407G-DISC1. My goal is to communicate (sending strings back and forth) between my pc and the mcu over serial and I currently am able to do so using the micro-usb (otg) port, while powering separately using the mini-usb st-link port (so using two cables).
Is it possible to use the mini-usb port for serial communications? (eliminating one of the cables)
I have read the user manual and my interpretation is that this is not possible without physical modifications. But I am a beginner and would like to verify I am correct in this interpretation. I have researched thoroughly however most sources seem to not refer to this specific board and it is my understanding with the newer version of st-link it uses this should be achievable.
It is possible - just send the messages via the USART2
You need to solder those two wires as they screw up the design.

Communication b/w two WiFi modules using Arduino Ide

Firstly, I'll just give you a brief introduction about our project... its "Speech controlled Home Automation System" where we are controlling the Home appliances by the voice or speech commands. We're successfully done with the voice recognition module. But our problem is with achieving the communication between the transmitter {where the user gives the voice command} and receiver {where the home appliances are present} through WiFi i.e. we have got 2 ESP8266 12E modules interfaced with Arduino both at the transmitter and receiver side and these two WiFi modules need to be communicated(To interchange some data sent by Arduinos).So please let us know which Arduino code need to be used at transmitter side wifi module and at Receiver side wifi module and also about the header files or additional softwares(if any)to be used.
you can achieve this by starting one of wifi modules in Access Point Mode and the other one has to be set to Station Mode in order to connect to the first one.
In case you want to add a router, just set both ESP8266 modules to Station Mode and connect them to the router.
And then transfer any data you want through AT commands of ESP8266.
Here is the refrence to them.
https://room-15.github.io/blog/2015/03/26/esp8266-at-command-reference/
If you are newbie to Esp8266 and Arduino , this will help you.
http://www.teomaragakis.com/hardware/electronics/how-to-connect-an-esp8266-to-an-arduino-uno/
Good Luck !
I worked on a similar system a year ago. I was developing a remote controlled toy. My main difference was I used the ESP8266 without an Arduino attached.
One ESP worked as a a WiFi hotspot and the other connected to it, sending messages through UDP.
For some reason, I could not get the two ESP modules to connect (I think it was a problem with the board I had), but I sent messages from my computer, and it worked out fine. I will not burden you with all of the code, but here is the GitHub link.
All that needs to happen is they will be on the same WiFi network, and then you can use the ESP8266 WiFi library to send messages between the two. Like I said above, I used UDP, which is good for high speed, with no error checking. But there is also TCP (higher up, has error checking code), or you can use the server/client part of the library to set up a full web server and read/write data to it. Without knowing what type of data, I cannot comment on what would be the best method.
As for headers, you will need WiFi.h, and if you are using UDP you will need WiFiUdp.h
You should not need any external software besides the Arduino IDE.
I taught myself from scratch for this product, using two main resources: the Arduino library reference, and the docs on the ESP8266 Arduino GitHub page

Which protocol to use if communicate with simatic plc over tcp/ip

I am using libnodave and s7netplus to read and write data blocks to my simatic s7-300.
Everything is working fine but I want to understand how libnodave or s7netplus are workingso that I can implement something similar in c++ or c# myself based on plain tcp/ip sockets, just for fun.
On the library websites or source code itself I could not find any information about how they are implemented only that they are using tcp/ip sockets (I know in libnodave you can also use other ways but for now I am only focused on tcp/ip).
On my researches on other websites I found that I can use open tcp/ip or modbus tcp/ip.
But I could not really find any specifications related to simatic s7-300 which are telling me how to establish a connection or what to send to start a data transfer....
Please don't understand me wrong.
For example for modbus tcp/ip itself I can find specifications but these specifications are not telling me anything about what to send to the plc if I want to read 10 bytes from data block 17 or write 3 bytes to data block 1.
So my question is which possibilities on top of tcp/ip I have to exchange data from a pc with my plc and where I can find exact specifications related to simatic s7-300?
The communication protocol to a Siemens PLC is discribed on the site of Snap7.
http://snap7.sourceforge.net/siemens_comm.html
(Maybe better to use Snap7 instead of Libnodave for support of newer PLC's!)

How to send data from 8051 input ports to esp8266?

Please pardon me if this question comes as a little too basic but I have tried searching almost everywhere but haven't found a clue.
I am using the esp8266 module and have uploaded the firmware in it. I have also set it as "Access point" so that other modules are able to connect with it. My problem is that I want to control it pro-grammatically through an 8051 micro-controller. I have searched online and there is a lot of documentation on how it program it through arduino, but that doesn't solve it for me. I want to use assembly language to build a serial protocol that communicates the data from 8051 to esp8266 and then to the connected modules (such as Android device).
My question really is, "would it be possible to just connect TX/RX of 8051 to RX/TX of esp8266 and write a code in assembly that transfers data as I desire to esp8266? Or, do I have to do something else?".
At the moment the only documented way for a host controller (the 8051 in your case) to talk to the ESP8266 is to use the serial port (there is a slave SPI port but the mechanism for driving it isn't known yet). So you will have to make up a little protocol to send and receive commands and data (assuming that the standard support for an enhanced AT command set isn't sufficient for you).
The baud rate can go a lot higher than the default 115200bps, if you need it to (although I'm not sure if the 8051 could keep up).

Programming Arduino's from a centralized location

I have 16 Arduinos that are in very tight spaces and hard to get to when I need to reprogram them with my FTDI cable. I would like to have or create some sort of centralized place where I can connect my FTDI cable, make some sort of selection (switch of some sort), which will then connect the pins my cable is on to the selected arduino.
Does anyone have any thoughts on how this can be accomplished? I've toyed with transistors, but that takes a lot of them and didn't quite work.
Are there any premade solutions that are out there that I have yet to find?
Thanks very much!
Here is a thought! TCP to Serial.
Sound complicated.
Not really.
Note from AVRDUDE's manual the following
For programmers that attach to a serial port using some kind of higher
level protocol (as opposed to bit-bang style programmers), port can be
specified as net:host:port. In this case, instead of trying to open a
local device, a TCP network connection to (TCP) port on host is
established. The remote endpoint is assumed to be a terminal or
console server that connects the network stream to a local serial port
where the actual programmer has been attached to. The port is assumed
to be properly configured, for example using a transparent 8-bit data
connection without parity at 115200 Baud for a STK500.
With this, One could place your Arduino's behind your choice of TCP to Serial Server. Which is available in several forms. Cisco has a gang TS (but that is expensive, unless used). lantronix (and others have single end point devices. But then for Linux, there is "Net2Ser" which can serve up all your ttyS (aka Serial/COM ports).
With the later you could use a raspberry or TP-Link TL-WR703N (
In the latest IDE 1.5.6r2 add one entry for each TCP-to-Serial Port to ./Arduino/hardware/arduino/avr/programmers.txt file. While replacing the IP and Port with corresponding values.
TCP2001.name=TCP 2001
TCP2001.communication=serial
TCP2001.protocol=stk500v1
TCP2001.program.protocol=stk500v1
TCP2001.program.tool=avrdude
TCP2001.program.extra_params=-Pnet:192.168.1.100:2001
TCP2002.name=TCP 2002
TCP2002.communication=serial
TCP2002.protocol=stk500v1
TCP2002.program.protocol=stk500v1
TCP2002.program.tool=avrdude
TCP2002.program.extra_params=-Pnet:192.168.1.100:2002
...
Additionally change "protocol" to "upload.protocol" the following line in ./Arduino/hardware/arduino/avr/platform.txt
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
to
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{upload.protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
With this you can use "Upload Using Programmer" with the selected programmer to send over TCP, rather then use the Upload.
That all said, it will only work on Linux.
avrdude: ser_open(): network connects are currently notimplemented for Win32 environments

Resources