Access to TwinCAT 3 data via Http requests and json. This let's you easily read and write data and thus control TwinCAT workflows from anywhere in your network using any programming language or a browser.You can also test and plan complex json requests in the manual request mode.
Download the latest Release. Put everything in one folder on your computer.
- Run the 'Start_TwinCAT-Http-Server' shortcut in the main folder with your TwinCAT 3 project running on the same machine (admin rights required).
- In the upper left corner, define the TwinCAT address and port. Hit "Connect" to connect to TwinCAT. The right log text box shows all messages regarding this backend connection between TwinCAT-HTTP-Server and TwinCAT
- Set port for local http server. Hit "Start" to start listening for incoming http requests. The left log text box shows all messages regarding incoming Http messages and the server itself.
- You can now make requests from anywhere in the network using Http GET or POST requests.
- To familiarize yourself with the required json structure chose an example in the lower left drop down menu.
- Edit this example to your needs and send manual requests by clicking "Send" for testing. (7. Under development: Copy this manual request in URL form to the clipboard by clicking the 'Copy as URL' button. Paste it to a browser to test the connection)
- You can now control TwinCAT from your host machine using http requests in Python, JavaScript, C#, Postman, a browser or whatever else can speak HTTP.
- Code snippets to make correct POST requests for all kinds of programming languages can be found in the 'RequestExamples' folder. (GET is also supported, but POST is preferred). Code snippets were not tested thoroughly.
TwinCAT-Http-Server internally uses a restful ASP.NET WebAPI. This should take care of all network configurations and open the relevant ports to your host machine.
However, if you experience problems such as 'Access denied' or similar, you might have to configure your network a bit.
This will most likely involve opening the port on the host machine's firewall and defining a binding in the IIS manager
To get the IIS manager to work use this tutorial.
Try to ping between the host machine and the remote machine.
By default TwinCAT-HTTP-Server will listen to all routes specified in the left log window at server start up.
When this works you will be able to read and write TwinCAT variables from any Http capable device in your network.
git clone https://github.com/HeinzBenjamin/TwinCAT-HTTP-Server.git
Special thanks to Tran Dang at the University of Technology Sydney for great support and insight into TwinCAT 3 and the EtherCAT ecosystem. This project was funded by the German Research Exchange Service (DAAD)