/iot-ladder-editor

An open-source Ladder Editor designed to generate code for IoT devices.

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

IoT Ladder Editor

This project is an open-source Ladder Editor designed to generate code for IoT devices. It enables interaction with program variables via the MQTT protocol, connecting with AWS IoT or Mosquitto MQTT Broker. The current version supports Arduino code generation (.ino) for ESP32 devices running FreeRTOS.

How to execute

  1. Install Java (8+) if it hasn't already been installed.
  2. Install Arduino IDE (2.3+), read the setup guide (Arduino_IDE_Setup.md).
  3. Download the latest released .jar file (Releases).
  4. Run the downloaded file with doule-click if supported, or run the command:
    java -jar iot_ladder_editor-0.0.2.jar

How to execute from the source code

  1. Install Java OpenJDK 11+ (jdk.java.net/archive).
  2. Install VS Code (https://code.visualstudio.com/download).
  3. Install VS Code Extensions: Extension Pack for Java, and Maven For Java. (Publisher: Microsoft).
  4. Download this repository and extract the .ZIP or clone this repository with git clone https://github.com/leofds/iot-ladder-editor.
  5. Open the project directory iot-ladder-editor on the VS Code. The project will be automatically builded by Maven, creating the directory target.
  6. Open the file iot-ladder-editor\src\main\java\com\github\leofds\iotladdereditor\IotLadderEditor.java.
  7. Run the project clicking on Run/Run Without Debugging (Ctrl+F5). Select Java if requested.

debug

To run in debug mode add breakpoints to the source code and click on Run/Start Debugging (F5)

generating .jar file

On the EXPLORER tab, JAVA PROJECTS navegation bar, click on Export Jar.

How to use the software

To understand about the Ladder Language read Ladder_Language.md.

  1. Use drag and drop to place instructions on the Rung and associate input/output variables to instructions.
  2. Go to Project/Build to generate the output code.
  3. The output file plc.ino will be created in the folder <current_folder>/out/plc.
  4. Double click to open Arduino IDE.
  5. Put the ESP32 board in programming mode. (It's no longer necessary)
  6. Click on Update icon on the Arduino IDE to load the program on the ESP32 board.
  7. After success
  8. Reset the ESP32 board to run the program. (It's no longer necessary)

Click on picture below to see the demo video:

Test Circuit

The table below shows recommended/equivalent Ladder Instruction for the input/output schematic.

Input
(pull-down resistor)
Input
(pull-up resistor)
Output
(active high)
Output
(active low)
Schematic

Ladder
Instruction

Pin Mapping

You can change the pin mapping on the Project/Properties, on the tab "Pin Mapping".

Default pinout

Connecting to the MQTT Broker

Before building, go to Project/Properties
Set the Wi-fi connection and on the tab MQTT set your Broker connection.

Sending messages to device

Only Integer and Floating program variable can be modified by MQTT messages.
Set the topic to subscribe on the tab MQTT/Topic.

Example of message: sending value 1 to variable MI01:

{
  "MI01": 1
}

... associate the Integer variable to instruction

Sending messages from the device

Set the topic to publish on the tab MQTT/Topic.
On the tab, MQTT/Telemetry set the period and variables to send.

Message sample sent from the device:

{
  "MI01": 0,
  "Q1": 0,
  "I1": 0
}

MQTT Broker

To use the AWS IoT read AWS_IoT_Setup_and_Configuration.md

To use the Mosquitto MQTT Broker read Mosquitto_Setup_and_Configuration.md.