Hello. I’m still learning to use PLCnext and would like some help. The aim of my project is to get electricity price from Nordpool-market via internet and somehow use this information in PLCnext engineer. My friend made a python code that returns a time when the heater for example would be cheapest to turn on(Code functionality might change, important thing would be to get the information to PLCnext).
I know there is a python installed on the controller. How would i install the code in the controller and how would i use it in PLCnext Engineer? Also the controller would need internet access to get the price, how would i connect to the internet? Controller is AXC F 2152 and im using plcnext Engineer 2023.6.
Thanks in advance
Hi iltsu,
You can install your friends Python code to the Linux using SSH or SFTP connection. I like to use the WinSCP which includes PuTTY for SSH and easy to use SFTP interface.
To get the ‘time’ variable to the PLCnext Engineer, you’ll need a connection between PLCnext Runtime and Linux. While this community is full of examples for Python using gRPC, REST API, Modbus etc. I would use the Nils Hetting’s “Read and Write PLC Process Data with Python”. I have tested this with the newest FW 2024.0 using the PLCnext Engineer 2024.0.
In Nils’ post is instructions how to download pip and PyPlcnextRsc package. With these and given code you can easily read and write directly to the PLCnext variables.
This however does require internet connection for the controller, which is the other thing you asked. You can connect the AXC F 2152 controller’s ethernet port to any router like you would a normal computer. The controller uses the same IP address for the communication to the router as it uses for PLCnext Engineer, WBM and SSH.
For example I have a 4G router in my test setup, which is the LAN gateway 192.168.0.1. I connect my AXC F 2152 directly to it, make a new project in PLCnext Engineer and give the controller an IP address 192.168.0.50. The router then provides internet access for the controller, like it would for a PC.
Ok, assuming everything works on the python code side of things, how would i configure PLCnext Engineer so it would be able to read the variable. Lets just assume that the variable is ‘Int16’ type or ‘boolean’