Monday, September 14, 2015

IR Remote Control - Programmable Logic Controller (PLC) - Arduino




PLC Application about how to use the IR Universal Remote Control for Programmable Logic Controller (PLC).
This application uses Arduino and IR Remote Control Module.
Communication between Programmable Logic Controller (PLC) and Arduino Using Modbus RTU.
IR Remote Control in this application used for Input Password on Machine by Infra Red Communication.

Input Password on PLC using IR Remote Control




Hardware:
1. IR Remote Control Module
2. Arduino UNO
3. TTL to RS232 Male Module
4. RS232 PLC Cable
5. Siemens PLC, or Others PLC with Modbus Support
6. Buzzer 5V
7. Power Supply for Arduino

Hardware for IR Remote Control - PLC - Arduino


Hardware Connections:

Hardware Connection for IR Remote Control - PLC - Arduino


Download Project File:
1. Delete Folder name is RobotIRremote in Arduino libraries

IR Remote Control on Arduino Project


2. Download Arduino libraries, click here
And copy paste folder Arduino-IRremote and SimpleModbusMaster to folder C:\Program Files (x86)\Arduino\libraries

3. Download Arduino IR Remote Control Project File, click here
4. Download PLC Ladder Programming, click here

Password Setting in PLC Ladder Programming:

Password Setting on PLC Ladder Programming for IR Remote Control


Arduino Code for IR Remote Control Project:
//MODBUS
#include <SimpleModbusMaster.h>
//Arduino Serial Port Connect to Port 0 of Siemens PLC S7 200
//for more info program-plc.blogspot.com
#define slaveAddr 1
#define baud 9600
#define timeout 1000
#define polling 200
#define retry_count 0
#define TxEnablePin 2 
enum
{
  PACKET1,
  PACKET2,
  TOTAL_NO_OF_PACKETS
};
Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer packet1 = &packets[PACKET1];
packetPointer packet2 = &packets[PACKET2];
unsigned int readRegs[1];
unsigned int writeRegs[1];

//IR REMOTE
#include <IRremote.h>
//Set IR Receive Value
//for Get IR Receive Value
//Using File - Examples - IRremote - IRrecvDemo
#define IR_NUM_0 0x1BC0157B //DEC 465573243
#define IR_NUM_1 0xC101E57B //DEC 3238126971
#define IR_NUM_2 0x97483BFB //DEC 2538093563
#define IR_NUM_3 0xF0C41643 //DEC 4039382595
#define IR_NUM_4 0x9716BE3F //DEC 2534850111
#define IR_NUM_5 0x3D9AE3F7 //DEC 1033561079
#define IR_NUM_6 0x6182021B //DEC 1635910171
#define IR_NUM_7 0x8C22657B //DEC 2351064443
#define IR_NUM_8 0x488F3CBB //DEC 1217346747
#define IR_NUM_9 0x449E79F //DEC 71952287
#define IR_OK 0xD7E84B1B //DEC 3622325019
#define IR_STAR 0x32C6FDF7 //DEC 851901943
#define IR_HASTAG 0x3EC3FC1B //DEC 1053031451
#define IR_ARROW_UP 0x511DBB //DEC 5316027
#define IR_ARROW_DOWN 0xA3C8EDDB //DEC 2747854299
#define IR_ARROW_LEFT 0x52A3D41F //DEC 1386468383
#define IR_ARROW_RIGHT 0x20FE4DBB //DEC 553536955

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int LED_PIN = 13;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  modbus_construct(packet1, slaveAddr, READ_HOLDING_REGISTERS, 0, 1, readRegs);
  modbus_construct(packet2, slaveAddr, PRESET_MULTIPLE_REGISTERS, 0, 1, writeRegs);
  modbus_configure(&Serial, baud, SERIAL_8E1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);  
  irrecv.enableIRIn(); 
}


void loop() {
modbus_update();
unsigned int WriteACT = (word)readRegs[0];

  if (irrecv.decode(&results)) {    
    writeRegs[0] = (word)Remote_Character(results.value);
    irrecv.resume();    
  }
  
if(WriteACT==writeRegs[0]){
  writeRegs[0] = 0;
  digitalWrite(LED_PIN,LOW);
}

digitalWrite(LED_PIN, writeRegs[0]>0 ? HIGH : LOW);
}


char Remote_Character(unsigned long IRresult) {
  switch (IRresult) {
    case IR_NUM_0:
      return '0'; //DEC 48
      break;
    case IR_NUM_1:
      return '1'; //DEC 49
      break;
    case IR_NUM_2:
      return '2'; //DEC 50
      break;
    case IR_NUM_3:
      return '3'; //DEC 51
      break;
    case IR_NUM_4:
      return '4'; //DEC 52
      break;
    case IR_NUM_5:
      return '5'; //DEC 53
      break;
    case IR_NUM_6:
      return '6'; //DEC 54
      break;
    case IR_NUM_7:
      return '7'; //DEC 55
      break;
    case IR_NUM_8:
      return '8'; //DEC 56
      break;
    case IR_NUM_9:
      return '9'; //DEC 57
      break;
    case IR_OK:
      return 'K'; //DEC 75
      break;
    case IR_STAR:
      return '*'; //DEC 42
      break;
    case IR_HASTAG:
      return '#'; //DEC 35
      break;
    case IR_ARROW_UP:
      return 'U'; //DEC 85
      break;
    case IR_ARROW_DOWN:
      return 'D'; //DEC 68
      break; 
    case IR_ARROW_LEFT:
      return 'L'; //DEC 76
      break;
    case IR_ARROW_RIGHT:
      return 'R'; //DEC 82
      break;
    default:
      return 0; //DEC 0
      break;     
  }
}
Video Demonstration: How to use Remote Control to PLC


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 !