rPLC Home rPLC

    How to write your first basic PLC program

    Step by step instructions how to write your first PLC program.
    • Last Update:2024-12-05
    • Version:003
    • Language:en

    Agenda

    • Open your first PLC example program
    • Configure your first PLC example program for your rPLC coupler environment
    • Build your first PLC example program
    • Transfer and run your first PLC example program with your rPLC coupler
    • View your PLC code in action (video)
    • View your PLC code

    Requirements

    • a real rPLC coupler device which is properly configured
    • a Beremiz IDE installation

    Goal

    This how to explains how to open an example PLC program, configure it, compile it and finally run it on your rPLC coupler.

    Open your first PLC example program

    This section will make sure that you can open an example PLC program.

    Step 1: Git checkout examples PLC project from OSIE repository

    Please clone the OSIE project repository.

    ivan@t580:~$ git clone https://lab.nexedi.com/nexedi/osie.git

    Step 2: Start Beremiz IDE

    Then to start Beremiz IDE from your working laptop or workstation using python environment.

    ivan@t580:~$ source nexedi/osie-env/bin/activate
    (osie-env) ivan@t580:~$ cd nexedi/osie-env/Beremiz/beremiz/
    (osie-env) ivan@t580:~/nexedi/osie-env/Beremiz/beremiz$ python Beremiz.py

    Step 3: Open PLC project

    Once "Beremiz IDE" is started you can click on "Open" button so you can open previously checkout PLC projects from local file system.

    Step 4: Open PLC project (cont.)

    Select the highlighted project from locally checkout OSIE's repository location (tutorial_beremiz_opc_ua) from dialog. Click on "Open" button.

    Configure your first PLC example program for your rPLC coupler environment

    This section will make sure that you can configure access for your rPLC coupler in your individual environment.

    Step 1: Configuring the IPv4 address of the rPLC coupler

    1. The project being opened, you need to configure the IPv4 address of the OPC UA client which is running inside the rPLC coupler.
    2. We assume that the coupler is in the same LAN network and you can get its IPv4 address by yourself.
    3. To set it one needs to click on "1.x:opcua_0" tree item as shown above.

    Step 2: Configuring the IPv4 address of the rPLC coupler (continued)

    You will see the following dialog where you need to click on "Configure" tab and only after that fill in "Server URI" input with your rPLC coupler IPV4. For example it can be something like this: "opc.tcp://192.168.1.100:4840"

    Build your first PLC example program

    This section will show how to build you PLC program.

    Step 1: Build your PLC program

    You can click on "Build" button so you can build your PLC project as shown above. 

    Transfer and run your first PLC example program with your rPLC coupler

    Step 1: Connect to local Beremiz runtime

    Once the project is successfully built you need to connect to a local beremiz runtime which will execute the compiled PLC binary code independently from current Beremiz IDE. You should click on "Connect" button as shown above.

    Step 2: Transfer your build code to local Beremiz runtime

    Once you are connected to Beremiz runtime you need to transfer it to the compiled PLC binary code. You should click on "Transfer" button as shown above.

    Step3: Start your PLC

    Finally you can start your PLC. You should click on "Start" button as shown above. This will execute the program.

    View your PLC code in action (video)

    You could run an example PLC program using a real rPLC coupler device. Video below shows it in action.

    View your PLC code

    • You can see your rPLC device's relays blinking.
    • If you want to explore the contents of your PLC code you should click as shown above.
    • You are free to experiment and edit PLC code and see your changes in the rPLC coupler.