Sunday, August 30, 2015

How to Replace PLC Analog Output Module with Arduino




This application about how to replace PLC analog output module with arduino.
Analog output module generates a voltage between 0 volt to 5 volt.
Analog output module usually used for valve control, fan control, rolling door speed control, elevator speed control, escalator speed control, adjust the brightness of the light, and etc.
This voltage is used to set the frequency of the inverter and controlling the motor speed.
Sample application as shown below:

PLC Analog Output Module with Arduino




Hardware of PLC analog output module with arduino

  1. Arduino UNO such as PLC Analog Output Module
  2. Siemens PLC, Or Others plc with modbus support
  3. TTL to RS232 Male Module
  4. PPI to RS232 PLC Cable
  5. Volt Meter or Multi-tester for Testing
  6. Power supply for arduino
  7. 2 Pcs Push Botton Switch for test, and connect to PLC input: I0.0 and I0.1

Hardware Connections of PLC analog output module with arduino

Hardware Connection for PLC Analog Output Module with Arduino

Download Project File of PLC Analog Output Module with Arduino

  1. Download Arduino libraries,  click here
  2. Copy paste folder SimpleModbusMaster to folder ..\Arduino\libraries

  3. Download Arduino Project File, click here

  4. Download PLC Ladder Programming, click here

PLC Ladder Programming of PLC Analog Output Module with Arduino

PLC Ladder Programming of PLC Analog Output Module with Arduino

Arduino Code of PLC Analog Output Module with Arduino

#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,
  TOTAL_NO_OF_PACKETS
};
Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer packet1 = &packets[PACKET1];
unsigned int readRegs[3];

//ATmega8 only support analogWrite() on pins 9, 10, and 11.
int AnalogOutputPin1 = 9;
int AnalogOutputPin2 = 10;
int AnalogOutputPin3 = 11;


void setup() {
  pinMode(AnalogOutputPin1, OUTPUT);  
  pinMode(AnalogOutputPin2, OUTPUT);
  pinMode(AnalogOutputPin3, OUTPUT);  
  modbus_construct(packet1, slaveAddr, READ_HOLDING_REGISTERS, 0, 3, readRegs);
  modbus_configure(&Serial, baud, SERIAL_8E1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);  
}

void loop() {
    modbus_update();
    int VW800 = (int)readRegs[0];
    int VW802 = (int)readRegs[1];
    int VW804 = (int)readRegs[2];
    VW800 = map(VW800, 0, 32767, 0, 255); 
    VW802 = map(VW802, 0, 32767, 0, 255);
    VW804 = map(VW804, 0, 32767, 0, 255); 
    analogWrite(AnalogOutputPin1, VW800); 
    analogWrite(AnalogOutputPin2, VW802);
    analogWrite(AnalogOutputPin3, VW804);
}
Video Demonstration: PLC Analog Output Module with Arduino


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