OpenPLC with LDmicro

From Script | Spoken-Tutorial
Jump to: navigation, search



Industrial training has become an essential part in training personnel and getting them ready for the challenging work in the industry. An Open Source Hardware initiative by FOSSEE Project at IIT Bombay presents OpenPLC an open source Programmable Logic Controller. This cost effective, robust, dynamic and modular hardware with open source software enables students from various streams of Engineering and Polytechnics to learn Industrial automation using Ladder Logic programming language, one of the widely used languages in automation industries.

The Spoken Tutorials on OpenPLC will be based on OpenPLC hardware and LDmicro software. LDmicro is Free and Open Source software. LDmicro generates native code for microcontrollers like Atmel AVR and Microchip PIC16.

LDmicro was available only for Windows initially. The FOSSEE team has ported it and made it available for Linux OS also.

OpenPLC is based on ATMega16 AVR microcontroller. The board is equipped with sets of digital and analog input/output pins, a standard ISP header to which you can connect an external programmer for loading programs from computers, output power pins, external UART module, reset button etc and input power terminal.

The Spoken Tutorial effort for OpenPLC with LDmicro has been contributed by Harsha Priyanka from FOSSEE team and Nirmala Venkat from Spoken Tutorial team.

The domain review is done by Akshay Chipkar and Rajesh Kushalkar from the FOSSEE team.

Learners: UG/PG Electronics students, hardware professional or anyone who is interested in PLC programming.


  OpenPLC hardware schematic and gerber files for making PCB’s are available at links given below:
  https://openplc.fossee.in/
  https://openplc.fossee.in/downloads
  https://static.fossee.in/openplc/Schematic.pdf
  https://static.fossee.in/openplc/installation-files/Gerber_Files.zip

Students can perform OpenPLC experiments without OpenPLC hardware using the simulation mode in LDmicro. But we encourage having a hardware kit for better knowledge of the subject.

  OpenPLC hardware kit consist of:
  1. OpenPLC Mainboard (1 no.) 
  2. 24V, 2A SMPS (1 no.) 
  3. USBasp programmer (1 no.) 
  4. Traffic Light module (1 no.) 
  5. Switchboard module (1 no.) 
  6. Heater module (1 no.) 
  7. Jumper wires
  8. Relimate Connectors


Basic Level

  1. Overview of OpenPLC with LDmicro
    • Learning objectives of OpenPLC with LDmicro
    • Introduction to PLC
    • Embedded devices vs PLC
    • About OpenPLC
    • About LDmicro
    • Features of OpenPLC
    • What can you expect in this series?
    • Who can use OpenPLC?
    • Glimpse of Spoken Tutorials available on OpenPLC with LDmicro
    • How to use the Code Files?
  2. Installation of LDmicro on Linux
    • What is LDmicro?
    • Installation of LDmicro
    • What is AVRDUDE?
    • How to install AVRDUDE?
    • How to check the version of AVRDUDE ?
    • What is USBasp Programmer?
    • Why do we need USBasp drivers installed on our computer?
    • How to check if USBasp drivers are installed or not?
  3. Installation of LDmicro on Windows
    • What is LDmicro?
    • What is AVRDUDE?
    • How to install AVRDUDE on Windows?
    • How to check the version of AVRDUDE ?
    • What is USBasp Programmer?
    • Why do we need USBasp drivers installed on our computer?
    • How to install USBasp drivers on Windows
    • How to disable driver signature enforcement
  4. Introduction to LDmicro
    • LDmicro interface
    • Rungs
    • Rails
    • Instructions
    • Instructions toolbar
    • I/O list
    • Multiple inputs and Multiple outputs in a rung
    • Adding/Deleting a rung
    • Renaming instructions
    • Saving it as .ld file
  5. Simulation and Compilation
    • LDmicro simulator
    • Simulation mode
    • Real-time simulation
    • Single cycle option
    • Halt simulation
    • Effect of cycle time on simulation
    • Pre-compilation checklist
    • Microcontroller selection
    • MCU parameters
    • I/O assignment
    • Compile
  6. OpenPLC Mainboard
    • OpenPLC Mainboard
    • Input power unit
    • 24V, 2A power supply
    • Ouput power section
    • 4 different types of connectors
    • ATMega16 microcontroller
    • 4 I/O ports
    • ISP header
    • USBasp programmer
    • UART pins
  7. Programming OpenPLC
    • Programming OpenPLC Mainboard
    • Using USBasp to program the Mainboard
    • Connect SMPS and USBasp to the Mainboard
    • Check the programmer connection
    • AVRDUDE command to upload HEX file
    • Various parameters of the AVRDUDE command
    • Output to show the communication with the Mainboard
    • Precautions before programming
    • Ways to troubleshoot
    • Various part numbers for different controllers & programmers
  8. OpenPLC Traffic Light and Switchboard Modules
    • About OpenPLC Traffic Light module
    • Where can this module be used?
    • Different ways to connect using single LED connections
    • How to use LEDs with the connectors at the bottom of the module?
    • Power connections of the module
    • Working demo of Traffic Light module using connectors present at the bottom
    • Working demo of Traffic Light module using single LED connectors
    • About OpenPLC Switchboard module
    • Different types of switches and LEDs
    • Female berg connectors for connections
    • Working of each type of switch
    • How can a Switchboard module be powered?
  9. Normal Coil
    • Connection of SMPS and USBasp to the Mainboard
    • About types of Coils
    • About source types for Coils
    • Working of Normal Coil in LDmicro
    • Real-time simulation of Normal coil
    • Microcontroller and its parameter setting
    • Compile the logic and save the hex file
    • Upload normalcoil.hex to Mainboard
    • Make hardware connections for the Normal coil logic
    • Working of Normal coil on hardware
  10. Normal Contact
    • Connection of SMPS and USBasp to the Mainboard
    • Insert contact
    • Different types of Contact
    • Working of Normal Contact in LDmicro
    • Real-time simulation of Normal Contact
    • Microcontroller and its parameter setting
    • Compile the logic and save the hex file
    • Upload normalcontact.hex to Mainboard
    • Make hardware connections for the Normal Contact using traffic light module and switchboard module
    • Working of Normal contact on hardware
  11. Negated Coil and Negated Contact
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Coil and select Negated
    • Real-time simulation of Negated Coil
    • Make hardware connections for the Negated Coil using traffic light module
    • Working of Negated Coil on hardware
    • Insert Contact and select Negated
    • Real-time simulation of Negated Contact
    • Make hardware connections for the Negated Contact using traffic light module and switchboard module
    • Working of Negated Contact on hardware
  12. Implementing NOT and AND logic gates
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Coil and Contact, with either of them Negated.
    • Real-time simulation of NOT logic gate
    • Make hardware connections for the NOT gate using traffic light module and Switchboard module
    • Working of NOT gate on hardware
    • Insert two Contacts and a Coil in series
    • Real-time simulation of AND logic gate
    • Make hardware connections for the AND gate using traffic light module and Switchboard module
    • Working of AND gate on hardware
  13. Implementing OR and XOR logic gates
    • Connection of SMPS and USBasp to the Mainboard
    • Insert two Contacts in parallel with a Coil in series
    • Real-time simulation of OR logic gate
    • Make hardware connections for the OR gate using traffic light module and Switchboard module
    • Working of OR gate on hardware
    • Insert two Contacts one in each rung of OR gate logic and negate them
    • Rename them alternately according to already existing Contacts
    • Real-time simulation of XOR logic gate
    • Make hardware connections for the XOR gate using traffic light module and Switchboard module
    • Working of XOR gate on hardware
  14. Internal Relay and Output pin
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Contact and Coil and configure the Coil as Internal Relay
    • Insert a new rung below
    • Insert Contact and Coil in the new rung and configure the Contact as Internal Relay
    • Real-time simulation of Internal Relay
    • Insert Contact and Coil
    • Insert a new rung below
    • Insert Contact and Coil in the new rung and configure the Contact as Output pin
    • Real-time simulation of Output pin
    • Make hardware connections for the Output pin using Traffic light module and Switchboard module
    • Working of Output pin on hardware
  15. SET and RESET Coils
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Contact and Coil and configure the Coil as SET-only Coil
    • Real-time simulation of SET-only Coil
    • Make hardware connections for the SET-only Coil using Traffic light module and Switchboard module
    • Working of SET-only Coil on hardware
    • Insert a new rung below in the SET-only Coil ladder diagram
    • Insert Contact and Coil in the new rung and configure the Coil as RESET-only Coil
    • Real-time simulation of RESET-only Coil
    • Make hardware connections for the RESET-only Coil using Traffic light module and Switchboard module
    • Working of RESET-only Coil on hardware

Intermediate Level

  1. OneShot Instructions
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Contact, OSR and Coil in the same order
    • Real-time simulation of OSR
    • Change cycle time to 3000ms and simulate the OSR logic again
    • Make hardware connections for the OSR using Traffic light module and Switchboard module
    • Working of OSR on hardware
    • Replace OSR with OSF
    • Real-time simulation of OSF
    • Make hardware connections for the OSF using Traffic light module and Switchboard module
    • Working of OSF on hardware
  2. Arithmetic Instructions
    • Connection of SMPS and USBasp to the Mainboard
    • About Arithmetic instructions
    • 4 Arithmetic Instructions - ADD, SUB, MUL, DIV
    • Insert Contact and ADD instruction
    • Real-time simulation of ADD instruction
    • Check on operands for 16 bit signed integers
    • Show the result as 16 bit signed integer
    • Increment the variable when the input to ADD is 1
    • Add OSR/OSF instruction to increment the variable only on 0-1 transition
    • When to use OSR or OSF?
  3. Move Instruction
    • Connection of SMPS and USBasp to the Mainboard
    • About MOV instruction
    • Steps for creating a virtual counter
    • Insert a Contact, OSR and ADD instruction
    • Real-time simulation
    • How to reset the count value?
    • Insert a Contact and Move instruction in the new rung
    • Real-time simulation of Move instruction
    • Demo of Move instruction
    • Save the ladder diagram
  4. Compare Instructions
    • Connection of SMPS and USBasp to the Mainboard
    • 6 types of compare instructions - equals, not equals, less than, less than or equal, greater than, greater than or equal
    • About Compare instructions
    • Insert Contact, OSR and Coil in the same order
    • Insert Compare for equals and Move instruction in the new rung
    • Real-time simulation of compare for equals
    • Show the output as glowing of LED when count is 0
    • Insert a Compare for equals and a Coil in the new rung
    • Make hardware connections for the OSR using Traffic light module and Switchboard module
    • Working of Compare for equals on hardware
  5. TON and TOFF Instructions
    • Connection of SMPS and USBasp to the Mainboard
    • Different types of timers
    • Insert Contact, Delayed turn on timer and Coil in the same order
    • Real-time simulation of timeron
    • Make hardware connections for the timeron using Traffic light module and Switchboard module
    • Working of timeron on hardware
    • Replace Delayed turn on timer with Delayed turn off timer
    • Real-time simulation of timeroff
    • Make hardware connections for the timeroff using Traffic light module and Switchboard module
    • Working of timeroff on hardware
  6. RTO Timer Instruction
    • Connection of SMPS and USBasp to the Mainboard
    • Insert Contact, Retentive Delayed turn on timer and Coil in the same order
    • Real-time simulation of RTO
    • How RTO works?
    • Turn off simulation within 5 seconds
    • Again real-time simulation of RTO
    • Resetting the RTO timer by adding a RESET instruction
    • About Timer and counter option
    • Make hardware connections for the RTO using Traffic light module and Switchboard module
    • Working of timeron on hardware
  7. CTU Counter
    • Connection of SMPS and USBasp to the Mainboard
    • 3 types of counters - Count up, Count down, and Count circular
    • About working of CTU counter
    • Insert a Contact and a Coil
    • To the right of Contact, insert CTU and set the count value as 3
    • Real-time simulation of CTU
    • Working of CTU in simulation mode
    • Make hardware connections for the CTU using Traffic light module and Switchboard module
    • Demonstration of CTU on hardware
    • Resetting CTU using RESET instruction
  8. CTD Counter
    • Connection of SMPS and USBasp to the Mainboard
    • Insert a Contact and a Coil
    • Insert one more Contact parallel to existing Contact
    • To the right of first Contact, insert a CTU
    • To the right of second Contact, insert a CTD
    • Name both counters with same name
    • Insert a rung below
    • Insert a GEQ and a Coil in the new rung
    • Real-time simulation of CTD
    • Make hardware connections for the CTD using Traffic light module and Switchboard module
    • Working of CTD on hardware
    • Where can an up-down counter be used?
  9. CTC Counter
    • Connection of SMPS and USBasp to the Mainboard
    • Example for CTC counter
    • Insert a Contact and a CTC
    • Insert a rung below
    • Insert EQU and a Coil in the new rung
    • Set the parameters for count
    • Real-time simulation of CTC
    • Working of CTC in simulation mode
    • Make hardware connections for the CTC using Traffic light module and Switchboard module
    • Demonstration of CTC on hardware
  10. OpenPLC Heater module
    • About OpenPLC Heater module
    • How the Heater module works?
    • Main components - Fan, Resistor, Thermistor, Indicator LEDs and Connectors
    • Power input and 3 MCU pins as fan, heat and temp
    • Demonstration with resistor as the heating element
    • About NTC thermistor
    • How can the Heater module be powered?
    • How to use LEDs with the connectors at the bottom of the module?
    • Working demo of Heater module
  11. A to D Converter Read Instruction
    • Connection of SMPS and USBasp to the Mainboard
    • About Analog to Digital Converter Read instruction
    • Working of this instruction using a simple analog example
    • How to control the temperature of the resistor?
    • About NTC thermistor
    • Setting the required parameters in LDmicro
    • Real-time simulation of ADC
    • Connection pin details of Mainboard and Heater module
    • Make hardware connections for the ADC using Heater module
    • Demonstration of ADC working on hardware
  12. PWM Instruction
    • Connection of SMPS and USBasp to the Mainboard
    • About PWM instruction
    • Create a logic to control the speed of a fan using PWM
    • Setup in LDmicro
    • Setting the duty cyle and frequency
    • Real-time simulation of PWM
    • Working of PWM in simulation mode
    • Make hardware connections for the PWM using Heater module
    • Pin connection details
    • Demonstration of PWM on hardware

Contributors and Content Editors

Nirmala Venkat