How To Program An Arduino As A Modbus Rs485 Master Slave

Tags: Arduino

Learn how to create your own Modbus RS485 Master and Slave Device using the Arduino Uno Development System

Last updated 2022-01-10 | 4.3

- Understand the Arduino Uno and RS485 Shield from a Hardware persepctive
- Connect an Arduino RS485 Shield to an Arduino Uno
- Connect an Arduino Uno to a Hitachi HD44780 LCD display

What you'll learn

Understand the Arduino Uno and RS485 Shield from a Hardware persepctive
Connect an Arduino RS485 Shield to an Arduino Uno
Connect an Arduino Uno to a Hitachi HD44780 LCD display
Use the Arduino IDE to develop applications for the Arduino Uno
Write an Arduino Sketch application to display messages on an LCD display
Write an Arduino Sketch application to implement a Modbus Master
Test an Arduino Modbus master using the Modsim32 Modbus slave simulator
Write an Arduino Sketch application to implement a Modbus Slave
Test an Arduino Modbus slave using the Modscan32 Modbus master application

* Requirements

* Basic working knowledge of the Modbus RTU protocol.
* Familiarity with the installation of software applications on the Windows OS platform
* Elementary understanding of the "C" programming language
* Basic understanding of elementary electronics

Description

If you work in the Automation Industry, you will know that automation equipment is very expensive. And many a time, especially for small applications, you simply cannot justify the use of very expensive equipment. 

This is where the Arduino comes in! 

The Arduino development board allows you to create very simple, but very powerful, Modbus master or slave devices through the use of relatively simple "C" programming. With the Arduino, you have full custom control over the program design allowing you to create very lean and very efficient devices for very specific purposes. 

Put simply, mastering Modbus on the Arduino is going to take your skill level and value in the Automation Industry to a whole new level. 

That is what this course is going to do. At the end of the course, you will know how to:

1. Choose the appropriate Arduino hardware.

2. Interconnect Arduino hardware with other add-on hardware.

3. Write "C" applications to implement Modbus master and slave functionality.

4. Use software and hardware to test each application that you write.

All of the programs written in the course are freely downloadable and give you a perfect starting point for further development. At the end of the course, you will have the knowledge to create your own products, your own custom Modbus master and slave hardware.

Looking forward to seeing you on the inside!

Who this course is for:

  • Electrical Engineers
  • Electrical Technicians
  • Electrical Tech or Engineering Students
  • Process Control Technicians and Engineers
  • Process Automation Engineers
  • Programmers working in the Process Automation field

Course content

9 sections • 34 lectures

Introduction Preview 04:10

Accessing Attached Resources and Setting Optimal Video Resolution Preview 02:23

The Hardware List Preview 04:36

The hardware that is used in the course is listed and their purpose given.

The Arduino Uno Preview 05:05

An overview of the Arduino Uno.

The RS485 Shield for Arduino Uno Preview 04:31

An overview of the RS485 shield for Arduino Uno.

The LCD Display and Interconnecting Hardware Preview 05:07

An overview of the LCD display and Interconnecting Hardware.

The USB-to-RS485 Converter and Connection Overview Preview 03:19

An overview of the USB-to-RS485 converter as well as the basic connection of the hardware.

Hardware Setup on my Workbench Preview 02:41

A look at the physical hardware set up.

The Arduino Programming Software Preview 02:24

This lecture shows where to go on the web to download and install the free Arduino programming software.

The Modbus Libraries Preview 03:50

Modbus Libraries are used to simplify the implementation of the Modbus protocol on the Arduino.

Modsim32 Modbus Slave Simulator Preview 02:00

Modsim32 is a Modbus slave simulation application. It will be used to provide data values that will be read by the Windows Modbus Master application.

A look at the Programming Software - Arduino IDE Preview 06:20

The Arduino IDE is briefly introduced.

Our First Program - Testing the LCD Display Preview 07:23

A built in application is used as the first application and also to test the LCD display.

Getting the LCD to display the value of a Variable Preview 08:36

The code is modified to display the value of a variable on the LCD display.

Additional LCD Code to support Modbus Master Operation Preview 09:43

Additional LCD code is added to update the LCD display only on data changes.

Adding Code to Implement Modbus Master Functionality Preview 09:11

Running our First Arduino Modbus Master Application Preview 04:14

Using the laptop with Modsim32 as a Modbus Slave, the Arduino application is run and tested.

Review of the Current Application Code Preview 06:27

Quite a bit of coding was done very quickly in the last section. This lecture reviews all of the code so as to solidify the function of the various commands.

Adding Code to Read a Holding Register Preview 06:54

Code is added and the application updated to be able to read a holding register.

Adding Code to Read an Input Status Preview 07:54

Code is added and the application updated to be able to read an input status.

Adding Code to Read a Coil Preview 05:52

Code is added and the application updated to be able to read a coil.

What we are going to do in this Section Preview 02:47

An overview of the details of the section.

How to Acquire the Sensor Preview 03:25

We have a look at the website from which the sensor was purchased.

A Look at the Datasheet for the Sensor Preview 05:47

We look at the datasheet for the sensor to determine the communication details.

The Arduino and Sensor setup on my Workbench Preview 02:53

Writing the Arduino Code to Read Data from the Temp/Humidity Sensor Preview 07:08

Testing the Arduino Program Preview 03:10

Modification of Code to Display Decimal Places Preview 03:21

Adding Code to Write to a Modbus Coil based on a Condition Preview 05:48

Code is added to an existing Arduino program to write to a Modbus Coil based on the value in an Input Register.

Testing of the Write Modbus Function using Modsim32 Preview 03:13

The new code added in the previous video is testing using Modim32 as the Modbus Slave.

Installing the Modbus Slave Arduino Library Preview 03:59

The previously downloaded Modbus Slave Library is installed into the Arduino IDE.

Implementing the Arduino Modbus Slave and Testing Read Functionality Preview 07:44

Code is written to implement the Modbus Slave in the Arduino and then Modscan32 is used to read Modbus data.

Implementing the Arduino Modbus Slave and Testing Write Functionality Preview 03:49

The code from the previous lecture is modified to test the write functionality of the slave. Modscan32 is used to write to the Arduino slave.