Monday, November 23, 2015

Allen-Bradley PLC - Arduino - Allen-Bradley DF1 Protocol

This application about how to communication between Allen-Bradley PLC and Arduino using DF1 Protocol.
Data from arduino send to Allen-Bradley PLC and data from Allen-Bradley PLC send to arduino.
Data from Analog input (0 - 5V or 0 - 32767) of Arduino send to N7:1 of Allen-Bradley PLC.
Data from N7:0 of Allen-Bradley PLC send to Analog Output of Arduino (0 - 5V).

Analog Input Output Allen-Bradley PLC using Arduino

I use Allen Bradley MicroLogix 1000 PLC and DF1 setting with baud rate 9600.
Check out my video demonstration:

Allen-Bradley DF1 communication between Micrologix 1000 and Arduino

Hardware requirements:

  1. Allen-Bradley PLC with DF1 Protocol Support, I use Micrologix 1000
  2. RS-232 PLC Cable for Allen Bradley Micrologix 1000/1100/1200/1500
  3. Arduino UNO
  4. TTL to RS232 Module : If TTL to RS232 FEMALE connector then use DB9 Male crossover cable
  5. For testing (optional): 2 push button, 1 potentiometer and voltmeter/multi tester

Hardware Connections

Hardware Connections for Allen Bradley PLC and Arduino

Software requirements:

  1. Arduino Software : I use HOURLY BUILDS version 1.6.6
  2. Arduino library : click here
Unzip and Copy Paste to folder ..\arduino-nightly\libraries
Only Folder : DF1

Project File

  1. for Upload to Arduino : click here
  2. for Download to Allen Bradley MicroLogix 1000 PLC : click here

DF1 Setting of Allen Bradley MicroLogix 1000 PLC

I use RSLogix Micro Starter Lite Software for MicroLogix 1000 programming and DF1 Setting, as shown below:
  1. Double Click Channel Configuration
  2. Check list Primary Protocol to DF1
  3. Select Baud to 9600
  4. Type Node Address with 1
  5. Check list Full Duplex
  6. Click OK

DF1 Setting of Allen Bradley MicroLogix 1000 PLC

Arduino Code of Allen-Bradley DF1 Protocol

#include <DF1.h>

#define DF1destination 1
#define DF1baud 9600
#define DF1format SERIAL_8N1
#define DF1timeout 1000


DF1packetPointer DF1packet1 = &DF1packets[DF1PACKET1];
DF1packetPointer DF1packet2 = &DF1packets[DF1PACKET2];

unsigned int DF1readRegs[1];

unsigned int DF1writeRegs[1];

#define AnalogOutputPin 9

void setup() {
DF1_construct(DF1packet1, DF1destination, DF1_READ_N7, 0, 1, DF1readRegs);
DF1_construct(DF1packet2, DF1destination, DF1_WRITE_N7, 1, 1, DF1writeRegs);

DF1_configure(&Serial, DF1baud, DF1format, DF1timeout, DF1packets, DF1TOTAL_NO_OF_PACKETS);


void loop() {

  //wrire N7:1
  int sensorValue = analogRead(A0);
  int outputValue = map(sensorValue, 0, 1023, 0, 32767);
  DF1writeRegs[0] = outputValue;

  //Read N7:0
  unsigned int N7_0 = DF1readRegs[0];
  N7_0 = map(N7_0, 0, 32000, 0, 255); 
  analogWrite(AnalogOutputPin, N7_0);


Newer Post Older Post Home

You may also like these ebook:

Get Free PLC eBook directly sent to your email,
and email subscription to

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

Your Email Will Be 100% Secured !