HTML5: Best viewed in Mozilla Firefox.

This page will be moved to a new location: DCIUX

Header image

PLµX.

A Embedded Linux PLC.

Programmable Logic Microcontroller on Linux.

NEW: PCA9555 Ports for in and outputs are configurable ().

PLuX accept arguments for accepting input from user.
More...

PLµX introduction.

Last modified: De Coninck Ivo

PLµX. A Programmable Logic Microcontroller on Linux.
Project started: October 2012.

The PLµX Project is an effort to produce an Embedded Linux-based Programmable Logic Controller (PLC). PLCs were developed in the 1960s to replace the complex electrical relay circuits widely used for machine control in industrial automation. Users program PLCs to define a series of actions that a machine will perform. The PLC works by reading input signals from devices such as sensors or switches and, depending on the value(s), turning outputs on or off.

In its simplest form, a PLC replaces relay logic. Instead of mechanical devices like interconnected relays or timers providing the logic for a machine or other device, the PLC is a single boxed device performing the same function. Because it is programmable and in essence a computer, it is more flexible, easier to change than physical relay wiring and a great deal smaller than the relay equivalent. It can also perform arithmetic and other functions, such as servo control and analog measurement.

Traditional PLC programming resembles a relay diagram, and for simple diagrams it has the same meaning. PLCs are usually programmed off-line, using tools running Linux or Windows. The text-based programs or ladder diagrams are compiled to an intermediate language that is downloaded to the PLC and interpreted. The PLµX project is an interesting study as an embedded controller. Like the PLCs it will replace, it is much more general than most embedded projects.

With GNUBLIN (embedded GNU / Linux board) and the aid of eight GNUBLIN Module-Portexpander (PCA9555 Port-Expanders) the states of 64 inputs can be monitored and 64 outputs can be driven.

The PLµX project provides also 4 GNUBLIN ADC-Modules(32 anlalog inputs).
This ADC module is used to measure voltages. The modules can be easily connected via a ribbon cable to the Gnublin Board or the Gnublin Module-Bridge.

PLµX hardware test setup.

plux_test_board.png Top

Version history.

  1. PCA9555 Ports for in and outputs are configurable ().
    PLuX accept arguments for accepting inputs from user.
    More...
  2. ADC interface implemented ().
    Settings, Create Ladder Diagram, etc. More...
    ADC interface in action.
  3. ADC Analog 8-bit input ().
    Ladder Diagram Editor: analog 8-bit instruction implemented.
    More...
  4. Hardware test: 24V interface ().
    More...
  5. Digital 24 volt IO-interface ().
    More...
  6. Alarm Clock implemented now ().
    More...
  7. Timers and counters implemented ().
    More...
  8. Example tests ().
    More...
  9. I2C Interface ().
    More...

Top

Concept.

  1. Create a ladder diagram with the diagram editor.
    editor_create.png editor_create.png
    Create ladder diagram
  2. Test a ladder diagram in simulation state.
    editor_simulation_state.png editor_simulation_state.png
    Test a ladder diagram
  3. Build a ladder diagram (create object file).
    editor_build.png editor_build.png
    Build a ladder diagram.
  4. Download the *.obj file to the Gnublin board.

    Works only under Linux using ssh. Set up ssh

    editor_download.png editor_download.png
    Download the *.obj file.

    Using the command-line interface and scp.
    Scp copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh. Scp will ask for passwords or passphrases if they are needed for authentication.
    plux_scp.png

  5. Gnublin board with I/O Port expanders.

    PLuX_HW_Gnublin.png

  6. Login to the Gnublin board.

    After starting the Gnublin board, The first step is the bootloader (apex) copying the Linux image from the SD-Card into the RAM. After this the kernel will be booted with special parameters. Now the necessary drivers and modules will be loaded and after this the root filesystem will be participated and initialized. After this happened, you can login to the Gnublin board.

    plux_login.png
    The files in the directory: /root/plux on the embedded Linux machine.
    plux_directory.png

  7. Start/stop the plµx software on the Gnublin board.
    • Using the ladder diagram editor.
      Works only under Linux using ssh. Set up ssh
      editor_start.png editor_start.png
      Start/Stop PLC.

    • Start by using the command-line interface.
      plux_start.png
      When the program (plux_c) is running GPIO14 is set as output with high level.

  8. PCA9555 Ports for in and outputs are configurable.
    PLuX accept arguments for accepting inputs from user. Download latest version!
    Possible arguments (command + argument):
    Not yet implemented in the Ladder Diagram Editor!
    • ./plux_c 0
      • PCA9555 port 0 = all inputs
        PCA9555 port 1 = all outputs
    • ./plux_c 1
      • PCA9555 port 0 = all inputs & invers
        PCA9555 port 1 = all outputs
    • ./plux_c 2
      • PCA9555 port 0 = all inputs
        PCA9555 port 1 = all outputs & invers
    • ./plux_c 3
      • PCA9555 port 0 = all inputs & invers
        PCA9555 port 1 = all outputs & invers
    • ./plux_c 4
      • PCA9555 port 0 = all outputs
        PCA9555 port 1 = all inputs
    • ./plux_c 5
      • PCA9555 port 0 = all outputs & invers
        PCA9555 port 1 = all inputs
    • ./plux_c 6
      • PCA9555 port 0 = all outputs
        PCA9555 port 1 = all inputs & invers
    • ./plux_c 7
      • PCA9555 port 0 = all outputs & invers
        PCA9555 port 1 = all inputs & invers
  9. Online function.

    Works only under Linux using ssh.
    Not implemented yet.

Top

I2C Interface.

For coupling the board to various types of devices, relays and sensors an expansion board is needed.
More...
PLuX_HW_DCI.png

Top

Ladder Diagram Editor (written in Java).

Create, test and build a Ladder Diagram with the PLµX software.
Download Ladder Diagram Editor (Java) version: 1.13.06.29
PLµX Ladder Diagram Editor: Help contents.
How to Run a Java File.
Java Downloads for All Operating Systems.

The PLµX Ladder Diagram Editor is designed to allow you to easily prepare a PLC program by simply placing blocks. Ladder logic diagrams, which are in many ways similar to relay logic diagrams, are frequently used to graphically generate programs. When putting together a ladder logic diagram, you should always bear in mind that the symbols in the diagram represent instructions rather than physical contacts. When the instructions in the program are executed, the states of the inputs are monitored. Depending on these states, various outputs are set either High or Low.

More information about how to use the ladder diagram editor: Help contents.

Editor in action.

Plux editor in action. Plux editor in action.
Start/Stop PLC.

When generating a program, it is a good idea to work from left to right and to only start a new row after the current row has been completed.
The second point is also necessary because the program checks for empty rows.
You should also make a habit of always assigning a particular output only once when generating a PLC program. If the same output is used more than once in a program, this output will be assigned the state that it receives in the last row in which it is located!

Every PLC works in the following manner:

  1. When the PLC starts up (changes to Run mode), all outputs are set to inactive (no voltage).
  2. The states of all inputs are read in.
  3. The user program processes the instructions sequentially using the signal states acquired in Step 2. If the state of an input signal changes while the instructions are being processed, this does not have any effect during the cycle currently being executed. However, the states of timers, counters and flags are taken into account during the processing of the program.
  4. After the user program has been processed, the results are sent to the outputs.
  5. Steps 2, 3, and 4 are continuously repeated in a cyclic manner.

Top

Before using the Ladder Diagram Editor: Set up SSH.

On the Embedded Linux board:
First install OpenSSH.
apt-get update
apt-get install openssh-server
Create a key pair:
ssh-keygen -t rsa
The keys are stored in the hidden .ssh/ directory in your home directory. ssh-keygen generate a private and an public key.
Change directory permissions if needed.
chmod 700 ~/.ssh

On the local Linux (Ubuntu) machine:
First install OpenSSH.
apt-get update
apt-get install openssh-server
Create a key pair:
ssh-keygen -t rsa
The keys are stored in the hidden .ssh/ directory in your home directory. ssh-keygen generate a private and an public key.
Change directory permissions if needed.
chmod 700 ~/.ssh
Copy the public key to the embedded Linux board.
scp ~/.ssh/id_rsa.pub root@192.168.1.111:~/.ssh/authorized_keys
Login into the remote host (Embedded Linux board) and change file permissions if needed.
ssh -l ubuntuuser gnublin
Password: ********

chmod 0600 ~/.ssh/authorized_keys
Logout.
logout

Now use ssh to connect passwordless to the embedded Linux board!
ssh root@192.168.1.111

Top

PLµX software for the Gnublin Board.

Directory: /root/plux.
plux.directory.png.
Download the necessary software (2013-07-01) for the Gnublin board, and place them into directory: '/root/plux'.
Create a ladder diagram with the ladder diagram editor and build and download it to the gnublin board.
Or on the command line copy the created *.obj file to /root/plux and rename it to xxxx.obj.
To run the PLµX executable use the Ladder diagram editor.
Or on the command line, to run the PLµX executable type the path to the executable ./plux_c in the directory /root/plux.
Press Ctrl-c to stop the program.

When the program (plux_c) is running GPIO14 is set as output with high level.

Top

Example tests.

Example 1: press one switch (input) and 24 LEDs (outputs) light up.
Download onetoall.dg and open it with the Ladder diagram editor.
Click on Simulation state in the menu Project.
In the simulation window check the input 2.0 checkbox. This set outputs 0.0 - 2.7 high.
Build the ladder diagram and download it to the Gnublin board. Click on Start in the menu PLC.
Or copy the *.obj file and run the PLµX executable on the Gnublin board.
View the result:

HTML5 (Best viewed in Mozilla Firefox!)

More examples.

  1. I/O interface test. More....
  2. Timers and counters More....
  3. Alarm Clock More....

Top

Leave a Message.