Wednesday, January 13, 2016

LCD Display Arduino for Allen-Bradley PLC Micrologix




This application how to use two LCD Display Arduino 16 x 2 for Allen-Bradley PLC Micrologix.
LCD display used for status display on PLC ladder programming such as output status of Motor, status of heater ON or OFF,  and others.
This application how to use multiple LCD display module hd44780.
And in this case use two I2C LCD display Arduino 16 x 2 with chip hd44780.

I2C LCD display Arduino on Allen-Bradley PLC


Video demonstration:

Multiple I2C LCD Display Arduino 16 x 2 for Allen Bradley PLC Micrologix



Hardware for LCD display application for Allen Bradley PLC

  1. 2 pieces 16x2 LCD display module hd44780
  2. 2 pieces  I2C module for LCD display
  3. Arduino UNO
  4. Allen-Bradley PLC Micrologix
  5. RS232 PLC Cable Programming for Allen-Bradley PLC Micrologix
  6. TTL to RS232 Module
  7. Adaptor for Arduino
  8. 4 pieces push button switch for testing
I2C module and 16x2 LCD display


Hardware Connections for LCD display application for Allen Bradley PLC

1. I2C LCD Display

I2C LCD Display


2. I2C LCD Display and Arduino

I2C LCD Display and Arduino


3. TTL to RS232 Module, Arduino and PLC

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwaJdAkBGsQI9nHU-0p2IMg7b_gjIpZ5Vrv7QQ5T-jua2ow08eIQGYpehRSuuU_hSH_tGMv3bMsLik93-FN7v1trjTyvATWs9XjnL26dG4lHHvr6ApqZCZWJbIK3h1CKhhvYZtE7cokTg/s1600/Hardware-Connection-Between-Allen-Bradley-PLC-and-Arduino.jpg


4. TTL-RS232 Module to RS232 PLC Cable

Connect DB9 of TTL RS232 Module to DB9 RS232 PLC Cable
If TTL to RS232 use DB9 female then use DB9 Male crossover cable : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga4kZC5BPvcbjvEig7G9-tOM9vHoiwxyBWuVZh8sN5B1aQDSzTuRbyUgqDtt4fADv6ZxF35fDX9i-fMol5TLmIF_H3I4gFYaBE1iEVw4ikKHLhh6ENEN3zIAeL4jsqgxrNtsmDduo3bQE/s1600/DB9-Male-crossover-cable.jpg


5. Push Button to PLC Input

  1. Connect push button 1 to PLC Input I:0/0
  2. Connect push button 2 to PLC Input I:0/1
  3. Connect push button 3 to PLC Input I:0/2
  4. Connect push button 4 to PLC Input I:0/3


Software for LCD display application for Allen Bradley PLC

  1. Arduino Software (IDE) Version 1.6.6
  2. Arduino Library : click here
  3. Unzip and copy paste DF1 and LiquidCrystal_I2C to ..\arduino-nightly\libraries


Download File for LCD  Display Arduino Project

  1. LCD display arduino project file : click here
  2. Allen Bradley PLC MicroLogix project file: click here


PLC Memory to 16x2 LCD display



ON / OFF LCD text with Copy File in PLC Ladder Programming

LCD text with COP PLC Ladder Programming


LCD Display Arduino Code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

#include <DF1.h>
//Allen Bradley PLC
#define DF1destination 1
#define DF1baud 9600
#define DF1format SERIAL_8N1
#define DF1timeout 1000


enum
{
  DF1PACKET1,
  DF1TOTAL_NO_OF_PACKETS
};
DF1Packet DF1packets[DF1TOTAL_NO_OF_PACKETS];

DF1packetPointer DF1packet1 = &DF1packets[DF1PACKET1];

unsigned int DF1readRegsLCD[32];

//lcd display arduino 16 x 2
LiquidCrystal_I2C lcd1(0x26,16,2);
LiquidCrystal_I2C lcd2(0x27,16,2);

String LCD_STR[4];
String LCD_STR_PREV[4];
 
void setup()
{
  
  DF1_construct(DF1packet1, DF1destination, DF1_READ_N7, 0, 32, DF1readRegsLCD);
  
  DF1_configure(&Serial, DF1baud, DF1format, DF1timeout, DF1packets, DF1TOTAL_NO_OF_PACKETS);

  lcd1.init();
  lcd2.init();
  //lcd display screen backlight
  lcd1.backlight();  
  lcd2.backlight(); 
  //clear lcd display
  lcd1.clear(); 
  lcd1.home(); 
  lcd2.clear();
  lcd2.home();
}
 
void loop()
{
  DF1_update(); 
  
  //lcd display memory from N7:0 to N7:31 of Allen Bradley PLC
  for (int i = 0; i < 4; i++)LCD_STR[i] ="";
  int counter=0;
  int index=0;
  for (int i = 0; i < 32; i++){     
    if(DF1readRegsLCD[i]==0){
      LCD_STR[index]+="  "; // 2 space
    }else{
       LCD_STR[index]+=char((DF1readRegsLCD[i] >> 8) & 0x00FF);
       LCD_STR[index]+=char(DF1readRegsLCD[i] & 0x00FF);
    }
    counter++;
    if(counter==8){
      index++; 
      counter=0;
    }
  }

  //LCD1 Display Line 1
  if(LCD_STR_PREV[0] != LCD_STR[0]){
  lcd1.setCursor(0, 0);
  lcd1.print(LCD_STR[0]);
  LCD_STR_PREV[0] = LCD_STR[0];
  }

  //LCD1 Display Line 2
  if(LCD_STR_PREV[1] != LCD_STR[1]){
  lcd1.setCursor(0, 1);
  lcd1.print(LCD_STR[1]); 
  LCD_STR_PREV[1] = LCD_STR[1];
  }

  //LCD2 Display Line 1
  if(LCD_STR_PREV[2] != LCD_STR[2]){
  lcd2.setCursor(0, 0);
  lcd2.print(LCD_STR[2]);
  LCD_STR_PREV[2] = LCD_STR[2];
  }

  //LCD2 Display Line 2
  if(LCD_STR_PREV[3] != LCD_STR[3]){
  lcd2.setCursor(0, 1);
  lcd2.print(LCD_STR[3]); 
  LCD_STR_PREV[3] = LCD_STR[3];
  }

}


Labels:






Newer Post Older Post Home

You may also like these ebook:

Get Free PLC eBook directly sent to your email,
and email subscription to program-plc.blogspot.com




We hate SPAM. Your information is never sold or shared with anyone.

Your Email Will Be 100% Secured !

Your email is stored safely on Google FeedBurner