Basics 06: Communicate with OpenPLC Runtime using Python

Поділитися
Вставка
  • Опубліковано 24 жов 2024
  • On Basics 06 we will use Python and PyModbus to communicate with your OpenPLC device over the network. We will also dive into the Modbus protocol to understand what type of data we can retrieve from our PLC runtime. Finally, we will build a little terminal application in Python that retrieves and displays PLC data in real time
    Modbus deep dive 00:54
    Crafting the test program 06:11
    Programming an ESP 8266 10:16
    Playing around with Python live 13:31
    Running our Python program 19:06
    openplcproject...
    Please consider supporting OpenPLC by joining our Patreon: / openplc
    OpenPLC Friends:
    Freewave
    FACTS Engineering

КОМЕНТАРІ • 18

  • @x86-64
    @x86-64 Рік тому +3

    this is awesome. thinking of using this as a cybersecurity project on the modbus protocol to pentest devices operating on that protocol

  • @khandah8489
    @khandah8489 Рік тому +2

    Thank you so very much for the quality of your video courses.

    • @openplc
      @openplc  Рік тому +1

      Glad you like them!

  • @ev-cars8442
    @ev-cars8442 Рік тому +3

    thank you Thiago!
    You will change the IoT and PLC world ... that is 100% the tool for fighting the world climate change.
    My dream is a toolbox of "energy-saving FunctionBlocks" and project-templates for i. e. heatpump, aircondition and cooling applications.
    I will try to help🙄

  • @mansurbhamani3905
    @mansurbhamani3905 8 місяців тому +1

    Well explained. Do we have features on OpenPLC to make ESP32 as Modbus Master to make it read values from another Device/PLC, RTU or TCP over RS485 or Ethernet?

    • @openplc
      @openplc  8 місяців тому +1

      This will be added in future releases

  • @FumblingArborist
    @FumblingArborist Рік тому

    This is absolutely brilliant! Thank you so much

  • @Llop66
    @Llop66 7 місяців тому

    Hello Thiago. This needs a device able to run Python, like a Raspberry Pi with an OS. A lot of sensor have a C library to run on µC like Arduino. Would it be possible to mix LADDER and C/C++ programming to run on an Arduino ?

  • @remiguillonbony6528
    @remiguillonbony6528 Рік тому +1

    Thank you very much ! Could you please present a scenario where you interact with multiple slaves instead of only one ? I'm curious to see how it has to be configured on the OpenPLC side

    • @openplc
      @openplc  Рік тому

      From the Python perspective, all you have to do is connect to each one of your slaves individually using client_n = ModbusTcpClient('slave_ip_address'). Then each 'client_n' will be an instance connected to a particular slave.

    • @EpicCalamar
      @EpicCalamar Рік тому

      @@openplc Thank you ! Clear from a Python perspective, but how would you manage multiple slaves from the OpenPLC perspective ? By assigning the location attribute of your variables to one slave or another ?

    • @openplc
      @openplc  Рік тому +1

      @@EpicCalamar That's quite simple. As you add more slaves on the Slave Devices tab you will see the I/O mapping for each one of your slave devices on the slave devices table. For more information, check this video ua-cam.com/video/dQ8GcfpGDuA/v-deo.html particularly from minute 7:45

  • @felixcenteno2003
    @felixcenteno2003 9 місяців тому

    I could not read the counter_value. then I assign the counter_value to the location: %QW1 and was able to read the counter_value , just in case some body was having the same problem. Also I use a program called ModbusTool V 1.1.4 an the register values were reading %QW0 (counter_max) = 2560 instead of 10, to fix that changing the byte order to: 2143 (was 1234 by default)

  • @kennyking6325
    @kennyking6325 Рік тому +1

    That cmd programming is a strange method to do live edits

  • @WenkangJi
    @WenkangJi Рік тому +1

    Thank you and Can I get this code?

    • @openplc
      @openplc  Рік тому +1

      Do you mean the Python code? Here it is:
      from pymodbus.client import ModbusTcpClient
      import time
      client = ModbusTcpClient(“192.168.0.192”)
      if client.connect() is True:
      while True:
      rr = client.read_holding_registers(0,2)
      print(“Counter value: “ + str(rr.registers[1]))
      time.sleep(0.3)

  • @sudeerawijetunga1525
    @sudeerawijetunga1525 Рік тому +1