You are on page 1of 79

Modbus Protocol

Chapter 1 Modbus Protocol


Chapter 2 Data and Control Functions
Chapter 3 Diagnostic Subfunctions
Chapter 4 Exception Responses
Chapter !pplication "otes
Chapter # $RC % CRC &eneration
MODBUS Protocol is a messaging structure, widely used to establish master-slave
communication between intelligent devices. MODBUS message sent !rom a master to a
slave contains the address o! the slave, the "command" #e.g. "read register" or "write
register"$, the data, and a chec% sum #&'( or ('($.
Since Modbus )rotocol is *ust a messaging structure, it is inde)endent o! the underlying
)hysical layer. +t is traditionally im)lemented using 'S,-,, 'S.,,, or 'S./0 over a variety
o! media #e.g. !iber, radio, cellular, etc.$.
MODBUS P&US is a higher s)eed to%en )assing derivative that uses the MODBUS
messaging structure. MODBUS P&US chi)sets are available !rom Schneider utomation
through the MOD(O112(3 )rogram.
MODBUS 3(P4+P uses 3(P4+P and 2thernet to carry the MODBUS messaging structure.
MODBUS43(P re5uires a license but all s)eci!ications are )ublic and o)en so there is no
royalty )aid !or this license. 3he MODBUS 3(P license and s)eci!ication is available !or
download at htt)644www.modicon.com4o)enmbus.
3he MODBUS )rotocol comes in , !lavours6
S(++ transmission mode6 2ach eight-bit byte in a message is sent as , S(++
characters.
'3U transmission mode6 2ach eight-bit byte in a message is sent as two !our-bit
he7adecimal characters.
3he main advantage o! the '3U mode is that it achieves higher through)ut, while the
S(++ mode allows time intervals o! u) to 8 second to occur between characters without
causing an error.
3he basic structure o! a MODBUS !rame is shown below6
ADDRESS FUNCTION DATA CHECKSUM

3he address !ield o! a message !rame contains two characters #S(++$ or eight bits #'3U$.
9alid slave device addresses are in the range o! : ... ,.; decimal. 3he individual slave
devices are assigned addresses in the range o! 8 ... ,.;. master addresses a slave by
)lacing the slave address in the address !ield o! the message. <hen the slave sends its
res)onse, it )laces its own address in this address !ield o! the res)onse to let the master
%now which slave is res)onding.
3he !unction code !ield o! a message !rame contains two characters #S(++$ or eight bits
#'3U$. 9alid codes are in the range o! 8 ... ,00 decimal. <hen a message is sent !rom a
master to a slave device the !unction code !ield tells the slave what %ind o! action to
)er!orm. 27am)les are to read the O1 4 O== states o! a grou) o! discrete coils or in)uts> to
read the data contents o! a grou) o! registers> to read the diagnostic status o! the slave> to
write to designated coils or registers> or to allow loading, recording, or veri!ying the
)rogram within the slave.
<hen the slave res)onds to the master, it uses the !unction code !ield to indicate either a
normal #error-!ree$ res)onse or that some %ind o! error occurred #called an e7ce)tion
res)onse$. =or a normal res)onse, the slave sim)ly echoes the original !unction code. =or
an e7ce)tion res)onse, the slave returns a code that is e5uivalent to the original !unction
code with its most signi!icant bit set to a logic 8.
Chapter 1
Modbus Protocol
V Introducing Modbus Protocol
V Two Sri!l Tr!ns"ission Mods
V Modbus Mss!g Fr!"ing
V Error C#c$ing Mt#ods
1'1 Introducing Modbus Protocol
Modicon %rogr!""!bl controllrs c!n co""unic!t wit# !c# ot#r !nd wit# ot#r
d&ics o&r ! &!rit' o( ntwor$s) Su%%ortd ntwor$s includ t# Modicon Modbus !nd
Modbus Plus industri!l ntwor$s* !nd st!nd!rd ntwor$s suc# !s MAP !nd Et#rnt)
Ntwor$s !r !ccssd b' built+in %orts in t# controllrs or b' ntwor$ !d!%trs* o%tion
"oduls* !nd g!tw!'s t#!t !r !&!il!bl (ro" Modicon) For origin!l ,ui%"nt
"!nu(!cturrs* Modicon ModConnct %!rtnr %rogr!"s !r !&!il!bl (or closl' intgr!ting
ntwor$s li$ Modbus Plus into %ro%rit!r' %roduct dsigns)
T# co""on l!ngu!g usd b' !ll Modicon controllrs is t# Modbus %rotocol) T#is
%rotocol d(ins ! "ss!g structur t#!t controllrs will rcogni- !nd us* rg!rdlss o(
t# t'% o( ntwor$s o&r w#ic# t#' co""unic!t) It dscribs t# %rocss ! controllr
uss to r,ust !ccss to !not#r d&ic* #ow it will rs%ond to r,usts (ro" t# ot#r
d&ics* !nd #ow rrors will b dtctd !nd r%ortd) It st!blis#s ! co""on (or"!t (or
t# l!'out !nd contnts o( "ss!g (ilds)
T# Modbus %rotocol %ro&ids t# intrn!l st!nd!rd t#!t t# Modicon controllrs us (or
%!rsing "ss!gs) During co""unic!tions on ! Modbus ntwor$* t# %rotocol dtr"ins
#ow !c# controllr will $now its d&ic !ddrss* rcogni- ! "ss!g !ddrssd to it*
dtr"in t# $ind o( !ction to b t!$n* !nd .tr!ct !n' d!t! or ot#r in(or"!tion
cont!ind in t# "ss!g) I( ! r%l' is r,uird* t# controllr will construct t# r%l'
"ss!g !nd snd it using Modbus %rotocol)
On ot#r ntwor$s* "ss!gs cont!ining Modbus %rotocol !r i"bddd into t# (r!" or
%!c$t structur t#!t is usd on t# ntwor$) For .!"%l* Modicon ntwor$ controllrs (or
Modbus Plus or MAP* wit# !ssoci!td !%%lic!tion so(tw!r libr!ris !nd dri&rs* %ro&id
con&rsion btwn t# i"bddd Modbus "ss!g %rotocol !nd t# s%ci(ic (r!"ing
%rotocols t#os ntwor$s us to co""unic!t btwn t#ir nod d&ics)
T#is con&rsion !lso .tnds to rsol&ing nod !ddrsss* routing %!t#s* !nd rror+c#c$ing
"t#ods s%ci(ic to !c# $ind o( ntwor$) For .!"%l* Modbus d&ic !ddrsss
cont!ind in t# Modbus %rotocol will b con&rtd into nod !ddrsss %rior to
tr!ns"ission o( t# "ss!gs) Error+c#c$ing (ilds will !lso b !%%lid to "ss!g
%!c$ts* consistnt wit# !c# ntwor$/s %rotocol) At t# (in!l %oint o( dli&r'* #ow&r+(or
.!"%l* ! controllr+t# contnts o( t# i"bddd "ss!g* writtn using Modbus
%rotocol* d(in t# !ction to b t!$n)
Figur 0 s#ows #ow d&ics "ig#t b intrconnctd in ! #ir!rc#' o( ntwor$s t#!t
"%lo' widl' di((ring co""unic!tion tc#ni,us) In "ss!g tr!ns!ctions* t# Modbus
%rotocol i"bddd into !c# ntwor$/s %!c$t structur %ro&ids t# co""on l!ngu!g b'
w#ic# t# d&ics c!n .c#!ng d!t!)
Figure 1 ()er)ie* of Modbus Protocol !pplication
1'1'1 Tr!ns!ctions on Modbus Ntwor$s
St!nd!rd Modbus %orts on Modicon controllrs us !n RS+121C co"%!tibl sri!l intr(!c
t#!t d(ins connctor %inouts* c!bling* sign!l l&ls* tr!ns"ission b!ud r!ts* !nd %!rit'
c#c$ing) Controllrs c!n b ntwor$d dirctl' or &i! "od"s)
Controllrs co""unic!t using ! "!str+sl!& tc#ni,u* in w#ic# onl' on d&ic 3t#
"!str4 c!n initi!t tr!ns!ctions 3,uris4) T# ot#r d&ics 3t# sl!&s4 rs%ond b'
su%%l'ing t# r,ustd d!t! to t# "!str* or b' t!$ing t# !ction r,ustd in t# ,ur')
T'%ic!l "!str d&ics includ #ost %rocssors !nd %rogr!""ing %!nls) T'%ic!l sl!&s
includ %rogr!""!bl controllrs)
T# "!str c!n !ddrss indi&idu!l sl!&s* or c!n initi!t ! bro!dc!st "ss!g to !ll sl!&s)
Sl!&s rturn ! "ss!g 3rs%ons4 to ,uris t#!t !r !ddrssd to t#" indi&idu!ll')
Rs%onss !r not rturnd to bro!dc!st ,uris (ro" t# "!str)
T# Modbus %rotocol st!blis#s t# (or"!t (or t# "!str/s ,ur' b' %l!cing into it t#
d&ic 3or bro!dc!st4 !ddrss* ! (unction cod d(ining t# r,ustd !ction* !n' d!t! to b
snt* !nd !n rror+c#c$ing (ild) T# sl!&/s rs%ons "ss!g is !lso constructd using
Modbus %rotocol) It cont!ins (ilds con(ir"ing t# !ction t!$n* !n' d!t! to b rturnd*
!nd !n rror+c#c$ing (ild) I( !n rror occurrd in rci%t o( t# "ss!g* or i( t# sl!& is
un!bl to %r(or" t# r,ustd !ction* t# sl!& will construct !n rror "ss!g !nd snd it
!s its rs%ons)
1'1'2 Tr!ns!ctions on Ot#r Kinds o( Ntwor$s
In !ddition to t#ir st!nd!rd Modbus c!%!bilitis* so" Modicon controllr "odls c!n
co""unic!t o&r Modbus Plus using built+in %orts or ntwor$ !d!%trs* !nd o&r MAP*
using ntwor$ !d!%trs)
On t#s ntwor$s* t# controllrs co""unic!t using ! %r+to+%r tc#ni,u* in w#ic#
!n' controllr c!n initi!t tr!ns!ctions wit# t# ot#r controllrs) T#us ! controllr "!'
o%r!t it#r !s ! sl!& or !s ! "!str in s%!r!t tr!ns!ctions) Multi%l intrn!l %!t#s !r
(r,untl' %ro&idd to !llow concurrnt %rocssing o( "!str !nd sl!& tr!ns!ctions)
At t# "ss!g l&l* t# Modbus %rotocol still !%%lis t# "!str+sl!& %rinci%l &n
t#oug# t# ntwor$ co""unic!tion "t#od is %r+to+%r) I( ! controllr origin!ts !
"ss!g* it dos so !s ! "!str d&ic* !nd .%cts ! rs%ons (ro" ! sl!& d&ic)
Si"il!rl'* w#n ! controllr rci&s ! "ss!g it constructs ! sl!& rs%ons !nd rturns it
to t# origin!ting controllr)
1'1'3 T# 5ur'+Rs%ons C'cl
Figure 2 Master+Sla)e ,uer-+Response C-cle
.he ,uer-
T# (unction cod in t# ,ur' tlls t# !ddrssd sl!& d&ic w#!t $ind o( !ction to
%r(or") T# d!t! b'ts cont!in !n' !ddition!l in(or"!tion t#!t t# sl!& will nd to
%r(or" t# (unction) For .!"%l* (unction cod 62 will ,ur' t# sl!& to r!d #olding
rgistrs !nd rs%ond wit# t#ir contnts) T# d!t! (ild "ust cont!in t# in(or"!tion
tlling t# sl!& w#ic# rgistr to st!rt !t !nd #ow "!n' rgistrs to r!d) T# rror c#c$
(ild %ro&ids ! "t#od (or t# sl!& to &!lid!t t# intgrit' o( t# "ss!g contnts)
.he Response
I( t# sl!& "!$s ! nor"!l rs%ons* t# (unction cod in t# rs%ons is !n c#o o( t#
(unction cod in t# ,ur') T# d!t! b'ts cont!in t# d!t! collctd b' t# sl!&* suc# !s
rgistr &!lus or st!tus) I( !n rror occurs* t# (unction cod is "odi(id to indic!t t#!t t#
rs%ons is !n rror rs%ons* !nd t# d!t! b'ts cont!in ! cod t#!t dscribs t# rror) T#
rror c#c$ (ild !llows t# "!str to con(ir" t#!t t# "ss!g contnts !r &!lid)
1'2 Two Sri!l Tr!ns"ission Mods
Controllrs c!n b stu% to co""unic!t on st!nd!rd Modbus ntwor$s using it#r o( two
tr!ns"ission "ods7 ASCII or RTU) Usrs slct t# dsird "od* !long wit# t# sri!l
%ort co""unic!tion %!r!"trs 3b!ud r!t* %!rit' "od* tc4* during con(igur!tion o( !c#
controllr) T# "od !nd sri!l %!r!"trs "ust b t# s!" (or !ll d&ics on ! Modbus
ntwor$)
T# slction o( ASCII or RTU "od %rt!ins onl' to st!nd!rd Modbus ntwor$s) It d(ins
t# bit contnts o( "ss!g (ilds tr!ns"ittd sri!ll' on t#os ntwor$s) It dtr"ins #ow
in(or"!tion will b %!c$d into t# "ss!g (ilds !nd dcodd)
On ot#r ntwor$s li$ MAP !nd Modbus Plus* Modbus "ss!gs !r %l!cd into (r!"s
t#!t !r not rl!td to sri!l tr!n!s"ission) For .!"%l* ! r,ust to r!d #olding rgistrs
c!n b #!ndld btwn two controllrs on Modbus Plus wit#out rg!rd to t# currnt stu%
o( it#r controllr/s sri!l Modbus %ort)
1'2'1 ASCII Mod
8#n controllrs !r stu% to co""unic!t on ! Modbus ntwor$ using ASCII 3A"ric!n
St!nd!rd Cod (or In(or"!tion Intrc#!ng4 "od* !c# ig#t+bit b't in ! "ss!g is snt
!s two ASCII c#!r!ctrs) T# "!in !d&!nt!g o( t#is "od is t#!t it !llows ti" intr&!ls o(
u% to on scond to occur btwn c#!r!ctrs wit#out c!using !n rror)
Coding S-ste/
V H.!dci"!l* ASCII c#!r!ctrs 6 ))) 9* A ))) F
V On #.!dci"!l c#!r!ctr cont!ind in !c# ASCII c#!r!ctr o( t# "ss!g
0its per 0-te
V 0 st!rt bit
V : d!t! bits* l!st signi(ic!nt bit snt (irst
V 0 bit (or &n ; odd %!rit'+no bit (or no %!rit'
V 0 sto% bit i( %!rit' is usd+1 bits i( no %!rit'
Error Chec1 Field
V <ongitudin!l Rdund!nc' C#c$ 3<RC4
1'2'2 RTU Mod
8#n controllrs !r stu% to co""unic!t on ! Modbus ntwor$ using RTU 3R"ot
Tr"in!l Unit4 "od* !c# ig#t+bit b't in ! "ss!g cont!ins two (our+bit #.!dci"!l
c#!r!ctrs) T# "!in !d&!nt!g o( t#is "od is t#!t its gr!tr c#!r!ctr dnsit' !llows
bttr d!t! t#roug#%ut t#!n ASCII (or t# s!" b!ud r!t) E!c# "ss!g "ust b
tr!ns"ittd in ! continuous str!")
Coding S-ste/
V Eig#t+bit bin!r'* #.!dci"!l 6 ))) 9* A ))) F
V Two #.!dci"!l c#!r!ctrs cont!ind in !c# ig#t+bit (ild o( t# "ss!g
0its per 0-te
V 0 st!rt bit
V = d!t! bits* l!st signi(ic!nt bit snt (irst
V 0 bit (or &n ; odd %!rit'+no bit (or no %!rit'
V 0 sto% bit i( %!rit' is usd+1 bits i( no %!rit'
Error Chec1 Field
V C'clic!l Rdund!nc' C#c$ 3CRC4
1'3 Modbus Mss!g Fr!"ing
In it#r o( t# two sri!l tr!ns"ission "ods 3ASCII or RTU4* ! Modbus "ss!g is
%l!cd b' t# tr!ns"itting d&ic into ! (r!" t#!t #!s ! $nown bginning !nd nding %oint)
T#is !llows rci&ing d&ics to bgin !t t# st!rt o( t# "ss!g* r!d t# !ddrss %ortion
!nd dtr"in w#ic# d&ic is !ddrssd 3or !ll d&ics* i( t# "ss!g is bro!dc!st4* !nd to
$now w#n t# "ss!g is co"%ltd) P!rti!l "ss!gs c!n b dtctd !nd rrors c!n b
st !s ! rsult)
On ntwor$s li$ MAP or Modbus Plus* t# ntwor$ %rotocol #!ndls t# (r!"ing o(
"ss!gs wit# bginning !nd nd dli"itrs t#!t !r s%ci(ic to t# ntwor$) T#os
%rotocols !lso #!ndl dli&r' to t# dstin!tion d&ic* "!$ing t# Modbus !ddrss (ild
i"bddd in t# "ss!g unncss!r' (or t# !ctu!l tr!ns"ission) 3T# Modbus !ddrss is
con&rtd to ! ntwor$ nod !ddrss !nd routing %!t# b' t# origin!ting controllr or its
ntwor$ !d!%tr)4
1'3'1 ASCII Fr!"ing
In ASCII "od* "ss!gs st!rt wit# ! colon 3 7 4 c#!r!ctr 3ASCII 2A #.4* !nd nd wit# !
c!rri!g rturn+lin (d 3CR<F4 %!ir 3ASCII 6D !nd 6A #.4)
T# !llow!bl c#!r!ctrs tr!ns"ittd (or !ll ot#r (ilds !r #.!dci"!l 6 ))) 9* A ))) F)
Ntwor$d d&ics "onitor t# ntwor$ bus continuousl' (or t# colon c#!r!ctr) 8#n
on is rci&d* !c# d&ic dcods t# n.t (ild 3t# !ddrss (ild4 to (ind out i( it is t#
!ddrssd d&ic)
Intr&!ls o( u% to on scond c!n l!%s btwn c#!r!ctrs wit#in t# "ss!g) I( ! gr!tr
intr&!l occurs* t# rci&ing d&ic !ssu"s !n rror #!s occurrd) A t'%ic!l "ss!g
(r!" is s#own blow)
Figure 3 !SC22 Message Fra/e
Exception
8it# t# >=? !nd 9=?A;@;A controllrs* !n ASCII "ss!g c!n nor"!ll' tr"in!t !(tr t#
<RC (ild wit#out t# CR<F c#!r!ctrs bing snt) An intr&!l o( !t l!st on scond "ust
t#n occur) I( t#is #!%%ns* t# controllr will !ssu" t#!t t# "ss!g tr"in!td nor"!ll')
1'3'2 RTU Fr!"ing
In RTU "od* "ss!gs st!rt wit# ! silnt intr&!l o( !t l!st 2)> c#!r!ctr ti"s) T#is is
"ost !sil' i"%l"ntd !s ! "ulti%l o( c#!r!ctr ti"s !t t# b!ud r!t t#!t is bing usd
on t# ntwor$ 3s#own !s T0+T1+T2+T? in t# (igur blow4) T# (irst (ild t#n tr!ns"ittd
is t# d&ic !ddrss)
T# !llow!bl c#!r!ctrs tr!ns"ittd (or !ll (ilds !r #.!dci"!l 6 ))) 9* A ))) F)
Ntwor$d d&ics "onitor t# ntwor$ bus continuousl'* including during t# silnt
intr&!ls) 8#n t# (irst (ild 3t# !ddrss (ild4 is rci&d* !c# d&ic dcods it to (ind
out i( it is t# !ddrssd d&ic)
Following t# l!st tr!ns"ittd c#!r!ctr* ! si"il!r intr&!l o( !t l!st 2)> c#!r!ctr ti"s
"!r$s t# nd o( t# "ss!g) A nw "ss!g c!n bgin !(tr t#is intr&!l)
T# ntir "ss!g (r!" "ust b tr!ns"ittd !s ! continuous str!") I( ! silnt intr&!l o(
"or t#!n 0)> c#!r!ctr ti"s occurs b(or co"%ltion o( t# (r!"* t# rci&ing d&ic
(lus#s t# inco"%lt "ss!g !nd !ssu"s t#!t t# n.t b't will b t# !ddrss (ild o( !
nw "ss!g)
Si"il!rl'* i( ! nw "ss!g bgins !rlir t#!n 2)> c#!r!ctr ti"s (ollowing ! %r&ious
"ss!g* t# rci&ing d&ic will considr it ! continu!tion o( t# %r&ious "ss!g) T#is
will st !n rror* !s t# &!lu in t# (in!l CRC (ild will not b &!lid (or t# co"bind
"ss!gs) A t'%ic!l "ss!g (r!" is s#own blow)
Figure 4 R.3 Message Fra/e
1'3'3 How t# Addrss Fild is H!ndld
T# !ddrss (ild o( ! "ss!g (r!" cont!ins two c#!r!ctrs 3ASCII4 or ig#t bits 3RTU4)
V!lid sl!& d&ic !ddrsss !r in t# r!ng o( 6 ))) 1?: dci"!l) T# indi&idu!l sl!&
d&ics !r !ssignd !ddrsss in t# r!ng o( 0 ))) 1?:) A "!str !ddrsss ! sl!& b'
%l!cing t# sl!& !ddrss in t# !ddrss (ild o( t# "ss!g) 8#n t# sl!& snds its
rs%ons* it %l!cs its own !ddrss in t#is !ddrss (ild o( t# rs%ons to lt t# "!str
$now w#ic# sl!& is rs%onding)
Addrss 6 is usd (or t# bro!dc!st !ddrss* w#ic# !ll sl!& d&ics rcogni-) 8#n
Modbus %rotocol is usd on #ig#r l&l ntwor$s* bro!dc!sts "!' not b !llowd or "!'
b r%l!cd b' ot#r "t#ods) For .!"%l* Modbus Plus uss ! s#!rd glob!l d!t!b!s t#!t
c!n b u%d!td wit# !c# to$n rot!tion)
1'3'4 How t# Function Fild is H!ndld
T# (unction cod (ild o( ! "ss!g (r!" cont!ins two c#!r!ctrs 3ASCII4 or ig#t bits
3RTU4) V!lid cods !r in t# r!ng o( 0 ))) 1>> dci"!l) O( t#s* so" cods !r
!%%lic!bl to !ll Modicon controllrs* w#il so" cods !%%l' onl' to crt!in "odls* !nd
ot#rs !r rsr&d (or (utur us)
8#n ! "ss!g is snt (ro" ! "!str to ! sl!& d&ic t# (unction cod (ild tlls t#
sl!& w#!t $ind o( !ction to %r(or") E.!"%ls !r to r!d t# ON ; OFF st!ts o( ! grou%
o( discrt coils or in%utsB to r!d t# d!t! contnts o( ! grou% o( rgistrsB to r!d t#
di!gnostic st!tus o( t# sl!&B to writ to dsign!td coils or rgistrsB or to !llow lo!ding*
rcording* or &ri('ing t# %rogr!" wit#in t# sl!&)
8#n t# sl!& rs%onds to t# "!str* it uss t# (unction cod (ild to indic!t it#r !
nor"!l 3rror+(r4 rs%ons or t#!t so" $ind o( rror occurrd 3c!lld !n .c%tion
rs%ons4) For ! nor"!l rs%ons* t# sl!& si"%l' c#os t# origin!l (unction cod) For
!n .c%tion rs%ons* t# sl!& rturns ! cod t#!t is ,ui&!lnt to t# origin!l (unction
cod wit# its "ost signi(ic!nt bit st to ! logic 0)
For .!"%l* ! "ss!g (ro" "!str to sl!& to r!d ! grou% o( #olding rgistrs would
#!& t# (ollowing (unction cod7
0000 0011 (Hexadecimal 03)
I( t# sl!& d&ic t!$s t# r,ustd !ction wit#out rror* it rturns t# s!" cod in its
rs%ons) I( !n .c%tion occurs* it rturns7
1000 0011 (Hexadecimal 83)
In !ddition to its "odi(ic!tion o( t# (unction cod (or !n .c%tion rs%ons* t# sl!&
%l!cs ! uni,u cod into t# d!t! (ild o( t# rs%ons "ss!g) T#is tlls t# "!str w#!t
$ind o( rror occurrd* or t# r!son (or t# .c%tion)
T# "!str d&ic/s !%%lic!tion %rogr!" #!s t# rs%onsibilit' o( #!ndling .c%tion
rs%onss) T'%ic!l %rocsss !r to %ost subs,unt rtris o( t# "ss!g* to tr' di!gnostic
"ss!gs to t# sl!&* !nd to noti(' o%r!tors)
1'3' Contnts o( t# D!t! Fild
T# d!t! (ild is constructd using sts o( two #.!dci"!l digits* in t# r!ng o( 66 to FF
#.!dci"!l) T#s c!n b "!d (ro" ! %!ir o( ASCII c#!r!ctrs* or (ro" on RTU
c#!r!ctr* !ccording to t# ntwor$/s sri!l tr!ns"ission "od)
T# d!t! (ild o( "ss!gs snt (ro" ! "!str to sl!& d&ics cont!ins !ddition!l
in(or"!tion w#ic# t# sl!& "ust us to t!$ t# !ction d(ind b' t# (unction cod) T#is
c!n includ it"s li$ discrt !nd rgistr !ddrsss* t# ,u!ntit' o( it"s to b #!ndld*
!nd t# count o( !ctu!l d!t! b'ts in t# (ild)
For .!"%l* i( t# "!str r,usts ! sl!& to r!d ! grou% o( #olding rgistrs 3(unction
cod 624* t# d!t! (ild s%ci(is t# st!rting rgistr !nd #ow "!n' rgistrs !r to b r!d)
I( t# "!str writs to ! grou% o( rgistrs in t# sl!& 3(unction cod 06 #.!dci"!l4* t#
d!t! (ild s%ci(is t# st!rting rgistr* #ow "!n' rgistrs to writ* t# count o( d!t! b'ts
to (ollow in t# d!t! (ild* !nd t# d!t! to b writtn into t# rgistrs)
I( no rror occurs* t# d!t! (ild o( ! rs%ons (ro" ! sl!& to ! "!str cont!ins t# d!t!
r,ustd) I( !n rror occurs* t# (ild cont!ins !n .c%tion cod t#!t t# "!str
!%%lic!tion c!n us to dtr"in t# n.t !ction to b t!$n)
T# d!t! (ild c!n b non.istnt 3o( -ro lngt#4 in crt!in $inds o( "ss!gs) For
.!"%l* in ! r,ust (ro" ! "!str d&ic (or ! sl!& to rs%ond wit# its co""unic!tions
&nt log 3(unction cod 6@ #.!dci"!l4* t# sl!& dos not r,uir !n' !ddition!l
in(or"!tion) T# (unction cod !lon s%ci(is t# !ction)
1'3'# Contnts o( t# Error C#c$ing Fild
Two $inds o( rror+c#c$ing "t#ods !r usd (or st!nd!rd Modbus ntwor$s) T# rror
c#c$ing (ild contnts d%nd u%on t# "t#od t#!t is bing usd)
!SC22
8#n ASCII "od is usd (or c#!r!ctr (r!"ing* t# rror c#c$ing (ild cont!ins two
ASCII c#!r!ctrs) T# rror c#c$ c#!r!ctrs !r t# rsult o( ! <ongitudin!l Rdund!nc'
C#c$ 3<RC4 c!lcul!tion t#!t is %r(or"d on t# "ss!g contnts* .clusi& o( t#
bginning colon !nd tr"in!ting CR<F c#!r!ctrs)
T# <RC c#!r!ctrs !r !%%ndd to t# "ss!g !s t# l!st (ild %rcding t# CR<F
c#!r!ctrs)
R.3
8#n RTU "od is usd (or c#!r!ctr (r!"ing* t# rror c#c$ing (ild cont!ins ! 0C+bit
&!lu i"%l"ntd !s two ig#t+bit b'ts) T# rror c#c$ &!lu is t# rsult o( ! C'clic!l
Rdund!nc' C#c$ c!lcul!tion %r(or"d on t# "ss!g contnts)
T# CRC (ild is !%%ndd to t# "ss!g !s t# l!st (ild in t# "ss!g) 8#n t#is is
don* t# low+ordr b't o( t# (ild is !%%ndd (irst* (ollowd b' t# #ig#+ordr b't) T#
CRC #ig#+ordr b't is t# l!st b't to b snt in t# "ss!g)
Addition!l in(or"!tion !bout rror c#c$ing is cont!ind l!tr in t#is c#!%tr) Dt!ild
st%s (or gnr!ting <RC !nd CRC (ilds c!n b (ound in C#!%tr )
1'3'4 How C#!r!ctrs !r Tr!ns"ittd Sri!ll'
8#n "ss!gs !r tr!ns"ittd on st!nd!rd Modbus sri!l ntwor$s* !c# c#!r!ctr or b't
is snt in t#is ordr 3l(t to rig#t47
Least Significant Bit (LSB) ... Most Significant Bit
(MSB)
8it# ASCII c#!r!ctr (r!"ing* t# bit s,unc is7
Figure 0it (rder 5!SC226
8it# RTU c#!r!ctr (r!"ing* t# bit s,unc is7
Figure # 0it (rder 5R.36
1'4 Error C#c$ing Mt#ods
St!nd!rd Modbus sri!l ntwor$s us two $inds o( rror c#c$ing) P!rit' c#c$ing 3&n or
odd4 c!n b o%tion!ll' !%%lid to !c# c#!r!ctr) Fr!" c#c$ing 3<RC or CRC4 is !%%lid
to t# ntir "ss!g) @ot# t# c#!r!ctr c#c$ !nd "ss!g (r!" c#c$ !r gnr!td in
t# "!str d&ic !nd !%%lid to t# "ss!g contnts b(or tr!ns"ission) T# sl!&
d&ic c#c$s !c# c#!r!ctr !nd t# ntir "ss!g (r!" during rci%t)
T# "!str is con(igurd b' t# usr to w!it (or ! %rdtr"ind ti"out intr&!l b(or
!borting t# tr!ns!ction) T#is intr&!l is st to b long noug# (or !n' sl!& to rs%ond
nor"!ll') I( t# sl!& dtcts ! tr!ns"ission rror* t# "ss!g will not b !ctd u%on) T#
sl!& will not construct ! rs%ons to t# "!str) T#us t# ti"out will .%ir !nd !llow t#
"!str/s %rogr!" to #!ndl t# rror)
"ote7 A "ss!g !ddrssd to ! non.istnt sl!& d&ic will !lso c!us ! ti"out)
Ot#r ntwor$s suc# !s MAP or Modbus Plus us (r!" c#c$ing !t ! l&l !bo& t#
Modbus contnts o( t# "ss!g) On t#os ntwor$s* t# Modbus "ss!g <RC or CRC
c#c$ (ild dos not !%%l') In t# c!s o( ! tr!ns"ission rror* t# co""unic!tion %rotocols
s%ci(ic to t#os ntwor$s noti(' t# origin!ting d&ic t#!t !n rror #!s occurrd* !nd
!llow it to rtr' or !bort !ccording to #ow it #!s bn stu%) I( t# "ss!g is dli&rd* but
t# sl!& d&ic c!nnot rs%ond* ! ti"out rror c!n occur w#ic# c!n b dtctd b' t#
"!str/s %rogr!")
1'4'1 P!rit' C#c$ing
Usrs c!n con(igur controllrs (or E&n or Odd P!rit' c#c$ing* or (or No P!rit' c#c$ing)
T#is will dtr"in #ow t# %!rit' bit will b st in !c# c#!r!ctr)
I( it#r E&n or Odd P!rit' is s%ci(id* t# ,u!ntit' o( 0 bits will b countd in t# d!t!
%ortion o( !c# c#!r!ctr 3s&n d!t! bits (or ASCII "od* or ig#t (or RTU4) T# %!rit' bit
will t#n b st to ! 6 or 0 to rsult in !n E&n or Odd tot!l o( 0 bits) For .!"%l* t#s
ig#t d!t! bits !r cont!ind in !n RTU c#!r!ctr (r!"7
1100 0101
T# tot!l ,u!ntit' o( 0 bits in t# (r!" is (our) I( E&n P!rit' is usd* t# (r!"/s %!rit' bit
will b ! 6* "!$ing t# tot!l ,u!ntit' o( 0 bits still !n &n nu"br 3(our4) I( Odd P!rit' is
usd* t# %!rit' bit will b ! 0* "!$ing !n odd ,u!ntit' 3(i&4)
8#n t# "ss!g is tr!ns"ittd* t# %!rit' bit is c!lcul!td !nd !%%lid to t# (r!" o(
!c# c#!r!ctr) T# rci&ing d&ic counts t# ,u!ntit' o( 0 bits !nd sts !n rror i( t#'
!r not t# s!" !s con(igurd (or t#!t d&ic 3!ll d&ics on t# Modbus ntwor$ "ust b
con(igurd to us t# s!" %!rit' c#c$ "t#od4)
Not t#!t %!rit' c#c$ing c!n onl' dtct !n rror i( !n odd nu"br o( bits !r %ic$d u% or
dro%%d in ! c#!r!ctr (r!" during tr!ns"ission) For .!"%l* i( Odd P!rit' c#c$ing is
"%lo'd* !nd two 0 bits !r dro%%d (ro" ! c#!r!ctr cont!ining t#r 0 bits* t# rsult is
still !n odd count o( 0 bits)
I( No P!rit' c#c$ing is s%ci(id* no %!rit' bit is tr!ns"ittd !nd no %!rit' c#c$ c!n b
"!d) An !ddition!l sto% bit is tr!ns"ittd to (ill out t# c#!r!ctr (r!")
1'4'2 <RC C#c$ing
In ASCII "od* "ss!gs includ !n rror+c#c$ing (ild t#!t is b!sd on ! <RC "t#od)
T# <RC (ild c#c$s t# contnts o( t# "ss!g* .clusi& o( t# bginning colon !nd
nding CR<F %!ir) It is !%%lid rg!rdlss o( !n' %!rit' c#c$ "t#od usd (or t#
indi&idu!l c#!r!ctrs o( t# "ss!g)
T# <RC (ild is on b't* cont!ining !n ig#t+bit bin!r' &!lu) T# <RC &!lu is
c!lcul!td b' t# tr!ns"itting d&ic* w#ic# !%%nds t# <RC to t# "ss!g) T#
rci&ing d&ic c!lcul!ts !n <RC during rci%t o( t# "ss!g* !nd co"%!rs t#
c!lcul!td &!lu to t# !ctu!l &!lu it rci&d in t# <RC (ild) I( t# two &!lus !r not
,u!l* !n rror rsults)
T# <RC is c!lcul!td b' !dding togt#r succssi& ig#t+bit b'ts o( t# "ss!g*
disc!rding !n' c!rris* !nd t#n two/s co"%l"nting t# rsult) It is %r(or"d on t#
ASCII "ss!g (ild contnts excluding t# colon c#!r!ctr t#!t bgins t# "ss!g* !nd
excluding t# CR<F %!ir !t t# nd o( t# "ss!g)
In l!ddr logic* t# CKSM (unction c!lcul!ts ! <RC (ro" t# "ss!g contnts) For
!%%lic!tions using #ost co"%utrs* ! dt!ild .!"%l o( <RC gnr!tion is cont!ind in
A%%ndi. C)
1'4'3 CRC C#c$ing
In RTU "od* "ss!gs includ !n rror+c#c$ing (ild t#!t is b!sd on ! CRC "t#od)
T# CRC (ild c#c$s t# contnts o( t# ntir "ss!g) It is !%%lid rg!rdlss o( !n'
%!rit' c#c$ "t#od usd (or t# indi&idu!l c#!r!ctrs o( t# "ss!g)
T# CRC (ild is two b'ts* cont!ining ! 0C+bit bin!r' &!lu) T# CRC &!lu is c!lcul!td
b' t# tr!ns"itting d&ic* w#ic# !%%nds t# CRC to t# "ss!g) T# rci&ing d&ic
rc!lcul!ts ! CRC during rci%t o( t# "ss!g* !nd co"%!rs t# c!lcul!td &!lu to t#
!ctu!l &!lu it rci&d in t# CRC (ild) I( t# two &!lus !r not ,u!l* !n rror rsults)
T# CRC is st!rtd b' (irst %rlo!ding ! 0C+bit rgistr to !ll 0/s) T#n ! %rocss bgins o(
!%%l'ing succssi& ig#t+bit b'ts o( t# "ss!g to t# currnt contnts o( t# rgistr)
Onl' t# ig#t bits o( d!t! in !c# c#!r!ctr !r usd (or gnr!ting t# CRC) St!rt !nd sto%
bits* !nd t# %!rit' bit* do not !%%l' to t# CRC)
During gnr!tion o( t# CRC* !c# ig#t+bit c#!r!ctr is .clusi& ORd wit# t# rgistr
contnts) T#n t# rsult is s#i(td in t# dirction o( t# l!st signi(ic!nt bit 3<S@4* wit# !
-ro (illd into t# "ost signi(ic!nt bit 3MS@4 %osition) T# <S@ is .tr!ctd !nd
.!"ind) I( t# <S@ w!s ! 0* t# rgistr is t#n .clusi& ORd wit# ! %rst* (i.d
&!lu) I( t# <S@ w!s ! 6* no .clusi& OR t!$s %l!c)
T#is %rocss is r%!td until ig#t s#i(ts #!& bn %r(or"d) A(tr t# l!st 3ig#t#4 s#i(t*
t# n.t ig#t+bit b't is .clusi& ORd wit# t# rgistr/s currnt &!lu* !nd t# %rocss
r%!ts (or ig#t "or s#i(ts !s dscribd !bo&) T# (in!l contnts o( t# rgistr* !(tr !ll
t# b'ts o( t# "ss!g #!& bn !%%lid* is t# CRC &!lu)
8#n t# CRC is !%%ndd to t# "ss!g* t# low+ordr b't is !%%ndd (irst* (ollowd
b' t# #ig#+ordr b't)
In l!ddr logic* t# CKSM (unction c!lcul!ts ! CRC (ro" t# "ss!g contnts) For
!%%lic!tions using #ost co"%utrs* ! dt!ild .!"%l o( CRC gnr!tion is gi&n on %!g )
Chapter 2
Data and Control Functions
V Modbus Function For"!ts
V Function Cods
V R!d Coil St!tus
V R!d In%ut St!tus
V R!d Holding Rgistrs
V R!d In%ut Rgistrs
V Forc Singl Coil
V Prst Singl Rgistr
V R!d E.c%tion St!tus
V Ftc# Co"" E&nt Countr
V Ftc# Co"" E&nt <og
V Forc Multi%l Coils
V Prst Multi%l Rgistrs
V R%ort Sl!& ID
V R!d Dnr!l R(rnc
V 8rit Dnr!l R(rnc
V M!s$ 8rit ?x Rgistr
V R!d ; 8rit ?x Rgistrs
V R!d FIFO 5uu
2'1 Modbus Function For/ats
"ote7 Unlss s%ci(id ot#rwis* nu"ric!l &!lus 3suc# !s !ddrsss* cods* or d!t!4 !r
.%rssd !s dci"!l &!lus in t# t.t o( t#is sction) T#' !r .%rssd !s #.!dci"!l
&!lus in t# "ss!g (ilds o( t# (igurs)
2'1'1 Data !ddresses in Modbus Messages
All d!t! !ddrsss in Modbus "ss!gs !r r(rncd to -ro) T# (irst occurrnc o( !
d!t! it" is !ddrssd !s it" nu"br -ro) For .!"%l7
V Coil 0 in ! %rogr!""!bl controllr is !ddrssd !s coil 6666 in t# d!t! !ddrss (ild o(
! Modbus "ss!g
V Coil 01: dci"!l is !ddrssd !s coil 66:E #. 301C dci"!l4
V Holding rgistr ?6660 is !ddrssd !s rgistr 6666 in t# d!t! !ddrss (ild o( t#
"ss!g) T# (unction cod (ild !lr!d' s%ci(is ! #olding rgistr o%r!tion) T#r(or
t# ?x r(rnc is i"%licit)
V Holding rgistr ?606= is !ddrssd !s rgistr 66C@ #. 306: dci"!l4
2'1'2 Field Contents in Modbus Messages
T# (ollowing t!bls s#ow .!"%ls o( ! Modbus ,ur' !nd nor"!l rs%ons) @ot#
.!"%ls s#ow t# (ild contnts in #.!dci"!l* !nd !lso s#ow #ow ! "ss!g could b
(r!"d in ASCII or in RTU "od)
,uer-
Response
T# "!str ,ur' is ! R!d Holding Rgistrs r,ust to sl!& d&ic !ddrss 6C) T#
"ss!g r,usts d!t! (ro" t#r #olding rgistrs* ?606= ))) ?6006)
"ote7 T# "ss!g s%ci(is t# st!rting rgistr !ddrss !s 606: 366C@ #.4)
T# sl!& rs%ons c#os t# (unction cod* indic!ting t#is is ! nor"!l rs%ons) T# @'t
Count (ild s%ci(is #ow "!n' ig#t+bit d!t! it"s !r bing rturnd) It s#ows t# count
o( ig#t+bit b'ts to (ollow in t# d!t!* (or it#r ASCII or RTU) 8it# ASCII* t#is &!lu is
#!l( t# !ctu!l count o( ASCII c#!r!ctrs in t# d!t!) In ASCII* !c# (our+bit #.!dci"!l
&!lu r,uirs on ASCII c#!r!ctr* t#r(or two ASCII c#!r!ctrs "ust (ollow in t#
"ss!g to cont!in !c# ig#t+bit d!t! it")
For .!"%l* t# &!lu C2 #. is snt !s on ig#t+bit b't in RTU "od 3600666004) T#
s!" &!lu snt in ASCII "od r,uirs two b'ts* (or ASCII C 360060064 !nd 2 360066004)
T# @'t Count (ild counts t#is d!t! !s on ig#t+bit it"* rg!rdlss o( t# c#!r!ctr
(r!"ing "t#od 3ASCII or RTU4)
8o* to 3se the 0-te Count Field
8#n 'ou construct rs%onss in bu((rs* us ! @'t Count &!lu t#!t ,u!ls t# count o(
ig#t+bit b'ts in 'our "ss!g d!t!) T# &!lu is .clusi& o( !ll ot#r (ild contnts*
including t# @'t Count (ild)
2'1'3 Field Contents on Modbus Plus
Modbus "ss!gs snt on Modbus Plus ntwor$s !r i"bddd into t# <ogic!l <in$
Control 3<<C4 l&l (r!") Modbus "ss!g (ilds consist o( ig#t+bit b'ts* si"il!r to
t#os usd wit# RTU (r!"ing)
T# Sl!& Addrss (ild is con&rtd to ! Modbus Plus routing %!t# b' t# snding d&ic)
T# CRC (ild is not snt in t# Modbus "ss!g* bc!us it would b rdund!nt to t#
CRC c#c$ %r(or"d !t t# Hig#+l&l D!t! <in$ Control 3HD<C4 l&l)
T# rst o( t# "ss!g r"!ins !s in t# st!nd!rd sri!l (or"!t) T# !%%lic!tion so(tw!r
3)g)* MSTR bloc$s in controllrs* or Modco" III in #osts4 #!ndls t# (r!"ing o( t#
"ss!g into ! ntwor$ %!c$t)
Figur : s#ows #ow ! R!d Holding Rgistrs ,ur' would b i"bddd into ! (r!" (or
Modbus Plus tr!ns"ission)
Figure 4 Field Contents on Modbus Plus
2'2 Function Codes
T# listing blow s#ows t# (unction cods su%%ortd b' Modicon controllrs) Cods !r
listd in dci"!lB E indic!ts t#!t t# (unction is su%%ortd* !nd N indic!ts t#!t it is not
su%%ortd)
2'2'1 91 Read Coil Status
R!ds t# ON ; OFF st!tus o( discrt out%uts 36x r(rncs* coils4 in t# sl!&) @ro!dc!st
is not su%%ortd) T# "!.i"u" %!r!"trs su%%ortd b' &!rious controllr "odls !r
listd on %!g )
,uer-
T# ,ur' "ss!g s%ci(is t# st!rting coil !nd ,u!ntit' o( coils to b r!d) Coils !r
!ddrssd st!rting !t -ro+coils 0 ))) 0C !r !ddrssd !s 6 ))) 0>)
Hr is !n .!"%l o( ! ,ur' to r!d coils 16 ))) >C (ro" sl!& d&ic 0:7
Response
T# coil st!tus in t# rs%ons "ss!g is %!c$d !s on coil %r bit o( t# d!t! (ild) St!tus
is indic!td !s7 0 F ONB 6 F OFF) T# <S@ o( t# (irst d!t! b't cont!ins t# coil !ddrssd
in t# ,ur') T# ot#r coils (ollow tow!rd t# #ig# ordr nd o( t#is b't* !nd (ro" low
ordr to #ig# ordr in subs,unt b'ts)
I( t# rturnd coil ,u!ntit' is not ! "ulti%l o( ig#t* t# r"!ining bits in t# (in!l d!t!
b't will b %!ddd wit# -ros 3tow!rd t# #ig# ordr nd o( t# b't4) T# @'t Count
(ild s%ci(is t# ,u!ntit' o( co"%lt b'ts o( d!t!)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
T# st!tus o( coils 1: ))) 16 is s#own !s t# b't &!lu CD #.* or bin!r' 0066 0060) Coil
1: is t# MS@ o( t#is b't* !nd coil 16 is t# <S@) <(t to rig#t* t# st!tus o( coils 1: ))) 16
is ON+ON+OFF+OFF+ON+ON+OFF+ON)
@' con&ntion* bits wit#in ! b't !r s#own wit# t# MS@ to t# l(t* !nd t# <S@ to t#
rig#t) T#us t# coils in t# (irst b't !r 1: ))) 16* (ro" l(t to rig#t) T# n.t b't #!s coils
2> ))) 1=* l(t to rig#t) As t# bits !r tr!ns"ittd sri!ll'* t#' (low (ro" <S@ to MS@7 16 ) )
) 1:* 1= ) ) ) 2>* !nd so on)
In t# l!st d!t! b't* t# st!tus o( coils >C ))) >1 is s#own !s t# b't &!lu 0@ #.* or bin!r'
6660 0600) Coil >C is in t# (ourt# bit %osition (ro" t# l(t* !nd coil >1 is t# <S@ o( t#is
b't) T# st!tus o( coils >C ))) >1 is7 ON+ON+OFF+ON+ON)
"ote7 T# t#r r"!ining bits 3tow!rd t# #ig#+ordr nd4 !r -ro+(illd)
2'2'2 92 Read 2nput Status
R!ds t# ON ; OFF st!tus o( discrt in%uts 30x r(rncs4 in t# sl!&) @ro!dc!st is not
su%%ortd) T# "!.i"u" %!r!"trs su%%ortd b' &!rious controllr "odls !r listd on
%!g )
,uer-
T# ,ur' "ss!g s%ci(is t# st!rting in%ut !nd ,u!ntit' o( in%uts to b r!d) In%uts !r
!ddrssd st!rting !t -ro+in%uts 0 ))) 0C !r !ddrssd !s 6 ))) 0>)
Hr is !n .!"%l o( ! r,ust to r!d in%uts 0609: ))) 0610= (ro" sl!& d&ic 0:7
Response
T# in%ut st!tus in t# rs%ons "ss!g is %!c$d !s on in%ut %r bit o( t# d!t! (ild)
St!tus is indic!td !s7 0 F ONB 6 F OFF) T# <S@ o( t# (irst d!t! b't cont!ins t# in%ut
!ddrssd in t# ,ur') T# ot#r in%uts (ollow tow!rd t# #ig# ordr nd o( t#is b't* !nd
(ro" low ordr to #ig# ordr in subs,unt b'ts)
I( t# rturnd in%ut ,u!ntit' is not ! "ulti%l o( ig#t* t# r"!ining bits in t# (in!l d!t!
b't will b %!ddd wit# -ros 3tow!rd t# #ig# ordr nd o( t# b't4) T# @'t Count
(ild s%ci(is t# ,u!ntit' o( co"%lt b'ts o( d!t!)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
T# st!tus o( in%uts 0616? ))) 0609: is s#own !s t# b't &!lu AC #.* or bin!r' 0606
0066) In%ut 0616? is t# MS@ o( t#is b't* !nd in%ut 0609: is t# <S@) <(t to rig#t* t#
st!tus o( in%uts 0616? ))) 0609: is ON+OFF+ON+OFF+ON+ON+OFF+OFF)
T# st!tus o( in%uts 0610= ))) 06102 is s#own !s t# b't &!lu 2> #.* or bin!r' 6600
6060) In%ut 0610= is in t# t#ird bit %osition (ro" t# l(t* !nd in%ut 06102 is t# <S@) T#
st!tus o( in%uts 0610= ))) 06102 is7 ON+ON+OFF+ON+OFF+ON)
"ote7 T# two r"!ining bits 3tow!rd t# #ig# ordr nd4 !r -ro+(illd)
2'2'3 93 Read 8olding Registers
R!ds t# bin!r' contnts o( #olding rgistrs 3?x r(rncs4 in t# sl!&) @ro!dc!st is not
su%%ortd) T# "!.i"u" %!r!"trs su%%ortd b' &!rious controllr "odls !r listd on
%!g )
,uer-
T# ,ur' "ss!g s%ci(is t# st!rting rgistr !nd ,u!ntit' o( rgistrs to b r!d)
Rgistrs !r !ddrssd st!rting !t -ro+ rgistrs 0 ))) 0C !r !ddrssd !s 6 ))) 0>)
Hr is !n .!"%l o( ! r,ust to r!d rgistrs ?606= ))) ?6006 (ro" sl!& d&ic 0:7
Response
T# rgistr d!t! in t# rs%ons "ss!g !r %!c$d !s two b'ts %r rgistr* wit# t#
bin!r' contnts rig#t Gusti(id wit#in !c# b't) For !c# rgistr* t# (irst b't cont!ins t#
#ig# ordr bits !nd t# scond cont!ins t# low ordr bits)
D!t! is sc!nnd in t# sl!& !t t# r!t o( 01> rgistrs %r sc!n (or 9=?+A=A controllrs
39=?+C=>* tc4* !nd !t t# r!t o( 21 rgistrs %r sc!n (or !ll ot#r controllrs) T# rs%ons
is rturnd w#n t# d!t! is co"%ltl' !ss"bld)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
T# contnts o( rgistr ?606= !r s#own !s t# two b't &!lus o( 61 1@ #.* or >>>
dci"!l) T# contnts o( rgistrs ?6069 ))) ?6006 !r 66 66 !nd 66 C? #.* or 6 !nd 066
dci"!l)
2'2'4 94 Read 2nput Registers
R!ds t# bin!r' contnts o( in%ut rgistrs 32A r(rncs4 in t# sl!&) @ro!dc!st is not
su%%ortd) T# "!.i"u" %!r!"trs su%%ortd b' &!rious controllr "odls !r listd on
%!g )
,uer-
T# ,ur' "ss!g s%ci(is t# st!rting rgistr !nd ,u!ntit' o( rgistrs to b r!d)
Rgistrs !r !ddrssd st!rting !t -ro+ rgistrs 0 ))) 0C !r !ddrssd !s 6 ))) 0>)
Hr is !n .!"%l o( ! r,ust to r!d rgistr 26669 (ro" sl!& d&ic 0:7
Response
T# rgistr d!t! in t# rs%ons "ss!g !r %!c$d !s two b'ts %r rgistr* wit# t#
bin!r' contnts rig#t Gusti(id wit#in !c# b't) For !c# rgistr* t# (irst b't cont!ins t#
#ig#+ordr bits !nd t# scond cont!ins t# low+ordr bits)
D!t! is sc!nnd in t# sl!& !t t# r!t o( 01> rgistrs %r sc!n (or 9=?+A=A controllrs
39=?+C=>* tc4* !nd !t t# r!t o( 21 rgistrs %r sc!n (or !ll ot#r controllrs) T# rs%ons
is rturnd w#n t# d!t! is co"%ltl' !ss"bld)
Hr is !n .!"%l o( ! rs%ons to t# ,ur' on t# o%%osit %!g7
T# contnts o( rgistr 26669 !r s#own !s t# two b't &!lus o( 66 6A #.* or 06
dci"!l)
2'2' 9 Force Single Coil
Forcs ! singl coil 36x r(rnc4 to it#r ON or OFF) 8#n bro!dc!st* t# (unction
(orcs t# s!" coil r(rnc in !ll !tt!c#d sl!&s) T# "!.i"u" %!r!"trs su%%ortd
b' &!rious controllr "odls !r listd on %!g )
"ote7 T# (unction will o&rrid t# controllr/s ""or' %rotct st!t !nd t# coil/s dis!bl
st!t) T# (orcd st!t will r"!in &!lid until t# controllr/s logic n.t sol&s t# coil) T#
coil will r"!in (orcd i( it is not %rogr!""d in t# controllr/s logic)
,uer-
T# ,ur' "ss!g s%ci(is t# coil r(rnc to b (orcd) Coils !r !ddrssd st!rting !t
-ro+coil 0 is !ddrssd !s 6)
T# rgustd ON ; OFF st!t is s%ci(id b' ! const!nt in t# ,ur' d!t! (ild) A &!lu o(
FF 66 #. r,usts t# coil to b ON) A &!lu o( 66 66 r,usts it to b OFF) All ot#r
&!lus !r illg!l !nd will not !((ct t# coil)
Hr is !n .!"%l o( ! r,ust to (orc coil 0:2 ON in sl!& d&ic 0:7
Response
T# nor"!l rs%ons is !n c#o o( t# ,ur'* rturnd !(tr t# coil st!t #!s bn (orcd)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
2'2'# 9# Preset Single Register
Prsts ! &!lu into ! singl #olding rgistr 3?x r(rnc4) 8#n bro!dc!st* t# (unction
%rsts t# s!" rgistr r(rnc in !ll !tt!c#d sl!&s) T# "!.i"u" %!r!"trs
su%%ortd b' &!rious controllr "odls !r listd on %!g )
"ote7 T# (unction will o&rrid t# controllr/s ""or' %rotct st!t) T# %rst &!lu
will r"!in &!lid in t# rgistr until t# controllr/s logic n.t sol&s t# rgistr contnts)
T# rgistr/s &!lu will r"!in i( it is not %rogr!""d in t# controllr/s logic)
,uer-
T# ,ur' "ss!g s%ci(is t# rgistr r(rnc to b %rst) Rgistrs !r !ddrssd
st!rting !t -ro+rgistr 0 is !ddrssd !s 6)
T# rgustd %rst &!lu is s%ci(id in t# ,ur' d!t! (ild) M=? !nd ?=? controllrs us
! 06+bit bin!r' &!lu* wit# t# si. #ig# ordr bits st to -ros) All ot#r controllrs us 0C+
bit &!lus)
Hr is !n .!"%l o( ! r,ust to %rst rgistr ?6661 to 66 62 #. in sl!& d&ic 0:7
Response
T# nor"!l rs%ons is !n c#o o( t# ,ur'* rturnd !(tr t# rgistr contnts #!& bn
%rst)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
2'2'4 94 Read Exception Status
R!ds t# contnts o( ig#t E.c%tion St!tus coils wit#in t# sl!& controllr) Crt!in coils
#!& %rd(ind !ssign"nts in t# &!rious controllrs) Ot#r coils c!n b %rogr!""d b'
t# usr to #old in(or"!tion !bout t# contollr/s st!tus+)g)* "!c#in ON;OFF* #!ds
rtr!ctd* s!(tis s!tis(id* rror conditions .ist* or ot#r usr+d(ind (l!gs) @ro!dc!st is
not su%%ortd)
T# (unction %ro&ids ! si"%l "t#od (or !ccssing t#is in(or"!tion* bc!us t#
E.c%tion Coil r(rncs !r $nown 3no coil r(rnc is ndd in t# (unction4) T#
%rd(ind E.c%tion Coil !ssign"nts !r7
,uer-
Hr is !n .!"%l o( ! r,ust to r!d t# .c%tion st!tus in sl!& d&ic 0:7
Response
T# nor"!l rs%ons cont!ins t# st!tus o( t# ig#t E.c%tion St!tus coils) T# coils !r
%!c$d into on d!t! b't* wit# on bit %r coil) T# st!tus o( t# lowst coil r(rnc is
cont!ind in t# l!st signi(ic!nt bit o( t# b't)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
In t#is .!"%l* t# coil d!t! is CD #. 36006 0060 bin!r'4) <(t to rig#t* t# coils !r OFF+
ON+ON+OFF+ON+ON+OFF+ON) T# st!tus is s#own (ro" t# #ig#st to t# lowst
!ddrssd coil)
I( t# controllr is ! 9=?* t#s bits !r t# st!tus o( coils = ))) 0) I( t# controllr is ! ?=?*
t#s bits !r t# st!tus o( coils 1C? ))) 1>:) In t#is .!"%l* coil 1>: is ON* indic!ting t#!t
t# controllr/s b!ttris !r OK)
2'2': 11 590 8ex6 Fetch Co// E)ent Counter
Rturns ! st!tus word !nd !n &nt count (ro" t# sl!&/s co""unic!tions &nt countr)
@' (tc#ing t# currnt count b(or !nd !(tr ! sris o( "ss!gs* ! "!str c!n dtr"in
w#t#r t# "ss!gs wr #!ndld nor"!ll' b' t# sl!&) @ro!dc!st is not su%%ortd)
T# controllr/s &nt countr is incr"ntd onc (or !c# succss(ul "ss!g co"%ltion)
It is not incr"ntd (or .c%tion rs%onss* %oll co""!nds* or (tc# &nt countr
co""!nds)
T# &nt countr c!n b rst b' "!ns o( t# Di!gnostics (unction 3cod 6=4* wit# !
sub(unction o( Rst!rt Co""unic!tions O%tion 3cod 66 604 or Cl!r Countrs !nd
Di!gnostic Rgistr 3cod 66 6A4)
,uer-
Hr is !n .!"%l o( ! r,ust to (tc# t# co""unic!tions &nt countr in sl!& d&ic
0:7
Response
T# nor"!l rs%ons cont!ins ! two+b't st!tus word* !nd ! two+b't &nt count) T#
st!tus word will b !ll ons 3FF FF #.4 i( ! %r&iousl' issud %rogr!" co""!nd is still
bing %rocssd b' t# sl!& 3! bus' condition .ists4) Ot#rwis* t# st!tus word will b
!ll -ros)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
In t#is .!"%l* t# st!tus word is FF FF #.* indic!ting t#!t ! %rogr!" (unction is still in
%rogrss in t# sl!&) T# &nt count s#ows t#!t 1C? 360 6= #.4 &nts #!& bn countd
b' t# controllr)
2'2'; 12 59C 8ex6 Fetch Co// E)ent $og
Rturns ! st!tus word* &nt count* "ss!g count* !nd ! (ild o( &nt b'ts (ro" t#
sl!&) @ro!dc!st is not su%%ortd) T# st!tus word !nd &nt count !r idntic!l to t#!t
rturnd b' t# Ftc# Co""unic!tions E&nt Countr (unction 300* 6@ #.4)
T# "ss!g countr cont!ins t# ,u!ntit' o( "ss!gs %rocssd b' t# sl!& sinc its l!st
rst!rt* cl!r countrs o%r!tion* or %owr+u%) T#is count is idntic!l to t#!t rturnd b' t#
Di!gnostic (unction 3cod 6=4* sub(unction Rturn @us Mss!g Count 3cod 00* 6@ #.4)
T# &nt b'ts (ild cont!ins 6 ))) C? b'ts* wit# !c# b't corrs%onding to t# st!tus o(
on Modbus snd or rci& o%r!tion (or t# sl!&) T# &nts !r ntrd b' t# sl!&
into t# (ild in c#ronologic!l ordr) @'t 6 is t# "ost rcnt &nt) E!c# nw b't (lus#s
t# oldst b't (ro" t# (ild)
,uer-
Hr is !n .!"%l o( ! r,ust to (tc# t# co""unic!tions &nt log in sl!& d&ic 0:7
Response
T# nor"!l rs%ons cont!ins ! two+b't st!tus word (ild* ! two+b't &nt count (ild* !
two+b't "ss!g count (ild* !nd ! (ild cont!ining 6 ))) C? b'ts o( &nts) A b't+count
(ild d(ins t# tot!l lngt# o( t# d!t! in t#s (our (ilds)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
In t#is .!"%l* t# st!tus word is 66 66 #.* indic!ting t#!t t# sl!& is not %rocssing !
%rogr!" (unction) T# &nt count s#ows t#!t 1C? 360 6= #.4 &nts #!& bn countd b'
t# sl!&) T# "ss!g count s#ows t#!t 1=9 360 10 #.4 "ss!gs #!& bn %rocssd)
T# "ost rcnt co""unic!tions &nt is s#own in t# E&nt 6 b't) Its contnts 316 #.4
s#ow t#!t t# sl!& #!s "ost rcntl' ntrd t# <istn Onl' Mod)
T# %r&ious &nt is s#own in t# E&nt 0 b't) Its contnts 366 #.4 s#ow t#!t t# sl!&
rci&d ! Co""unic!tions Rst!rt)
<hat the E)ent 0-tes Contain
An &nt b't rturnd b' t# Ftc# Co""unic!tions E&nt <og (unction c!n b !n' on o(
(our t'%s) T# t'% is d(ind b' bit : 3t# #ig#+ordr bit4 in !c# b't) It "!' b (urt#r
d(ind b' bit C)
Sla)e Modbus Recei)e E)ent
T#is t'% o( &nt b't is stord b' t# sl!& w#n ! ,ur' "ss!g is rci&d) It is stord
b(or t# sl!& %rocsss t# "ss!g) T#is &nt is d(ind b' bit : st to ! logic 0) T#
ot#r bits will b st to ! logic 0 i( t# corrs%onding condition is TRUE) T# bit l!'out is7
Sla)e Modbus Send E)ent
T#is t'% o( &nt b't is stord b' t# sl!& w#n it (inis#s %rocssing ! ,ur' "ss!g)
It is stord i( t# sl!& rturnd ! nor"!l or .c%tion rs%ons* or no rs%ons) T#is &nt
is d(ind b' bit : st to ! logic 6* wit# bit C st to ! 0) T# ot#r bits will b st to ! logic 0
i( t# corrs%onding condition is TRUE) T# bit l!'out is7
Sla)e Entered $isten (nl- Mode
T#is t'% o( &nt b't is stord b' t# sl!& w#n it ntrs t# <istn Onl' Mod) T#
&nt is d(ind b' ! contnts o( 6? #.) T# bit l!'out is7
Sla)e 2nitiated Co//unication Restart
T#is t'% o( &nt b't is stord b' t# sl!& w#n its co""unic!tions %ort is rst!rtd)
T# sl!& c!n b rst!rtd b' t# Di!gnostics (unction 3cod 6=4* wit# sub(unction Rst!rt
Co""unic!tions O%tion 3cod 66 604)
T#!t (unction !lso %l!cs t# sl!& into ! Continu on Error or Sto% on Error "od) I( t#
sl!& is %l!cd into Continu on Error "od* t# &nt b't is !ddd to t# .isting &nt
log) I( t# sl!& is %l!cd into Sto% on Error "od* t# b't is !ddd to t# log !nd t# rst
o( t# log is cl!rd to -ros) T# &nt is d(ind b' ! contnts o( -ro) T# bit l!'out is7
2'2'19 1 59F 8ex6 Force Multiple Coils
Forcs !c# coil 36x r(rnc4 in ! s,unc o( coils to it#r ON or OFF) 8#n bro!dc!st*
t# (unction (orcs t# s!" coil r(rncs in !ll !tt!c#d sl!&s) T# "!.i"u"
%!r!"trs su%%ortd b' &!rious controllr "odls !r listd on %!g )
"ote7 T# (unction will o&rrid t# controllr/s ""or' %rotct st!t !nd ! coil/s dis!bl
st!t) T# (orcd st!t will r"!in &!lid until t# controllr/s logic n.t sol&s !c# coil)
Coils will r"!in (orcd i( t#' !r not %rogr!""d in t# controllr/s logic)
,uer-
T# ,ur' "ss!g s%ci(is t# coil r(rncs to b (orcd) Coils !r !ddrssd st!rting !t
-ro+coil 0 is !ddrssd !s 6)
T# rgustd ON ; OFF st!ts !r s%ci(id b' contnts o( t# ,ur' d!t! (ild) A logic!l 0
in ! bit %osition o( t# (ild r,usts t# corrs%onding coil to b ON) A logic!l 6 r,usts it
to b OFF)
T# (ollowing %!g s#ows !n .!"%l o( ! r,ust to (orc ! sris o( tn coils st!rting !t
coil 16 3!ddrssd !s 09* or 02 #.4 in sl!& d&ic 0:)
T# ,ur' d!t! contnts !r two b'ts7 CD 60 #. 30066 0060 6666 6660 bin!r'4) T#
bin!r' bits corrs%ond to t# coils in t# (ollowing w!'7
0it7 0 0 6 6 0 0 6 0 6 6 6 6 6 6 6 0
Coil7 1: 1C 1> 1? 12 11 10 16 + + + + + + 19 1=
T# (irst b't tr!ns"ittd 3CD #.4 !ddrsss coils 1: ))) 16* wit# t# l!st signi(ic!nt bit
!ddrssing t# lowst coil 3164 in t#is st)
T# n.t b't tr!ns"ittd 360 #.4 !ddrsss coils 19 !nd 1=* wit# t# l!st signi(ic!nt bit
!ddrssing t# lowst coil 31=4 in t#is st) Unusd bits in t# l!st d!t! b't s#ould b -ro+
(illd)
Response
T# nor"!l rs%ons rturns t# sl!& !ddrss* (unction cod* st!rting !ddrss* !nd ,u!ntit'
o( coils (orcd) Hr is !n .!"%l o( ! rs%ons to t# ,ur' s#own !bo&7
2'2'11 1# 519 8ex6 Preset Multiple Registers
Prsts &!lus into ! s,unc o( #olding rgistrs 3?x r(rncs4) 8#n bro!dc!st* t#
(unction %rsts t# s!" rgistr r(rncs in !ll !tt!c#d sl!&s) T# "!.i"u"
%!r!"trs su%%ortd b' &!rious controllr "odls !r listd on %!g )
"ote7 T# (unction will o&rrid t# controllr/s ""or' %rotct st!t) T# %rst &!lus
will r"!in &!lid in t# rgistrs until t# controllr/s logic n.t sol&s t# rgistr contnts)
T# rgistr &!lus will r"!in i( t#' !r not %rogr!""d in t# controllr/s logic)
,uer-
T# ,ur' "ss!g s%ci(is t# rgistr r(rncs to b %rst) Rgistrs !r !ddrssd
st!rting !t -ro+rgistr 0 is !ddrssd !s 6)
T# r,ustd %rst &!lus !r s%ci(id in t# ,ur' d!t! (ild) M=? !nd ?=? controllrs
us ! 06+bit bin!r' &!lu* wit# t# si. #ig# ordr bits st to -ros) All ot#r controllrs us
0C+bit &!lus) D!t! is %!c$d !s two b'ts %r rgistr)
Hr is !n .!"%l o( ! r,ust to %rst two rgistrs st!rting !t ?6661 to 66 6A !nd 60 61
#.* in sl!& d&ic 0:7
Response
T# nor"!l rs%ons rturns t# sl!& !ddrss* (unction cod* st!rting !ddrss* !nd ,u!ntit'
o( rgistrs %rst) Hr is !n .!"%l o( ! rs%ons to t# ,ur' s#own !bo&)
2'2'12 14 511 8ex6 Report Sla)e 2D
Rturns ! dscri%tion o( t# t'% o( controllr %rsnt !t t# sl!& !ddrss* t# currnt st!tus
o( t# sl!& Run indic!tor* !nd ot#r in(or"!tion s%ci(ic to t# sl!& d&ic) @ro!dc!st is
not su%%ortd)
,uer-
Hr is !n .!"%l o( ! r,ust to r%ort t# ID !nd st!tus o( sl!& d&ic 0:7
Response
T# (or"!t o( ! nor"!l rs%ons is s#own blow) T# d!t! contnts !r s%ci(ic to !c#
controllr t'%)
Su//ar- of Sla)e 2Ds
T#s !r t# Sl!& ID cods rturnd b' Modicon controllrs in t# (irst b't o( t# d!t!
(ild7
1:4 % 3:4
T# 0=? or 2=? controllr rturns ! b't count o( it#r ? or :? 3?A #.!dci"!l4) I( t#
controllr/s H2?: Modbus Sl!& Intr(!c is stu% %ro%rl'* !nd its intrn!l PI@ t!bl is
nor"!l* t# b't count will b :?) Ot#rwis t# b't count will b ?) T# (our b'ts t#!t
!r !lw!'s rturnd !r7
@'ts > ))) 06* rturnd (or ! corrct H2?: stu% !nd nor"!l PI@* !r7
@'ts 00 ))) :? cont!in t# PI@ t!bl) T#is d!t! is &!lid onl' i( t# controllr is running 3!s
s#own in @'t 14) T# t!bl is !s (ollows7
:4
T# >=? controllr rturns ! b't count o( 9* !s (ollows7
;:4
T# 9=? controllr rturns ! b't count o( 9* !s (ollows7
"ote7 @it 6 o( t# M!c#in St!t word d(ins t# us o( t# ""or' downsi- &!lus in
words 99* 066* !nd 0:> 3C2* C?* !nd AF #.!dci"!l4 o( t# con(igur!tion t!bl) I( bit 6 F
logic 0* downsi-ing is c!lcul!td !s (ollows7
P!g 6 si- 30C+bit words4 F 38ord 99 I ?69C4 + 38ord 0:> lo b't I 0C4
St!t t!bl si- 30C+bit words4 F 38ord 066 I 061?4 + 38ord 0:> #i b't I 0C4
Micro :4
T# Micro =? controllr rturns ! b't count o( =* !s (ollows7
4:4
T# ?=? controllr rturns ! b't count o( >* !s (ollows7
::4
T# ==? controllr rturns ! b't count o( =* !s (ollows7
2'2'13 29 514 8ex6 Read &eneral Reference
Rturns t# contnts o( rgistrs in E.tndd M"or' (il 3Cx4 r(rncs) @ro!dc!st is not
su%%ortd) T# (unction c!n r!d "ulti%l grou%s o( r(rncs) T# grou%s c!n b s%!r!t
3noncontiguous4* but t# r(rncs wit#in !c# grou% "ust b s,unti!l)
,uer-
T# ,ur' cont!ins t# st!nd!rd Modbus sl!& !ddrss* (unction cod* b't count* !nd rror
c#c$ (ilds) T# rst o( t# ,ur' s%ci(is t# grou% or grou%s o( r(rncs to b r!d)
E!c# grou% is d(ind in ! s%!r!t sub+r,ust (ild w#ic# cont!ins s&n b'ts7
V T# r(rnc t'%+on b't 3"ust b s%ci(id !s C4
V T# E.tndd M"or' (il nu"br+two b'ts 30 ))) 06* 6660 ))) 666A #.4
V T# st!rting rgistr !ddrss wit#in t# (il+two b'ts
V T# ,u!ntit' o( rgistrs to b r!d+two b'ts
T# ,u!ntit' o( rgistrs to b r!d* co"bind wit# !ll ot#r (ilds in t# .%ctd rs%ons*
"ust not .cd t# !llow!bl lngt# o( Modbus "ss!gs+1>C b'ts)
T# !&!il!bl ,u!ntit' o( E.tndd M"or' (ils d%nds u%on t# inst!lld si- o(
E.tndd M"or' in t# sl!& controllr) E!c# (il .c%t t# l!st on cont!ins 06*666
rgistrs* !ddrssd !s 6666 ))) 1:6F #.!dci"!l 36666 + ))) 9999 dci"!l4)
For controllrs ot#r t#!n t# 9=?+:=> wit# E.tndd Rgistrs* t# l!st 3#ig#st4 rgistr in
t# l!st (il is7
For t# 9=?+:=> wit# E.tndd Rgistrs* t# l!st 3#ig#st4 rgistr in t# l!st (il is s#own
in t# two t!bls blow)
E.!"%ls o( ! ,ur' !nd rs%ons (ollow) An .!"%l o( ! r,ust to r!d two grou%s o(
r(rncs (ro" sl!& d&ic 0: is s#own) Drou% 0 consists o( two rgistrs (ro" (il ?*
st!rting !t rgistr 1 3!ddrss 66604) Drou% 1 consists o( two rgistrs (ro" (il 2* st!rting !t
rgistr 06 3!ddrss 66694)
Response
T# nor"!l rs%ons is ! sris o( sub+rs%onss* on (or !c# sub+r,ust) T# b't count
(ild is t# tot!l co"bind count o( b'ts in !ll sub+rs%onss) In !ddition* !c# sub+
rs%ons cont!ins ! (ild t#!t s#ows its own b't count)
2'2'14 21 51 8ex6 <rite &eneral Reference
8rits t# contnts o( rgistrs in E.tndd M"or' (il 3Cx4 r(rncs) @ro!dc!st is not
su%%ortd)
T# (unction c!n writ "ulti%l grou%s o( r(rncs) T# grou%s c!n b s%!r!t
3noncontiguous4* but t# r(rncs wit#in !c# grou% "ust b s,unti!l)
,uer-
T# ,ur' cont!ins t# st!nd!rd Modbus sl!& !ddrss* (unction cod* b't count* !nd rror
c#c$ (ilds) T# rst o( t# ,ur' s%ci(is t# grou% or grou%s o( r(rncs to b writtn*
!nd t# d!t! to b writtn into t#") E!c# grou% is d(ind in ! s%!r!t sub+r,ust (ild
w#ic# cont!ins s&n b'ts %lus t# d!t!7
V T# r(rnc t'%+on b't 3"ust b s%ci(id !s C4
V T# E.tndd M"or' (il nu"br+two b'ts 30 ))) 06* 6660 ))) 666A #.4
V T# st!rting rgistr !ddrss wit#in t# (il+two b'ts
V T# ,u!ntit' o( rgistrs to b writtn+two b'ts
V T# d!t! to b writtn+two b'ts;rgistr
T# ,u!ntit' o( rgistrs to b writtn* co"bind wit# !ll ot#r (ilds in t# ,ur'* "ust not
.cd t# !llow!bl lngt# o( Modbus "ss!gs+1>C b'ts)
T# !&!il!bl ,u!ntit' o( E.tndd M"or' (ils d%nds u%on t# inst!lld si- o(
E.tndd M"or' in t# sl!& controllr) E!c# (il .c%t t# l!st on cont!ins 06*666
rgistrs* !ddrssd !s 6666 ))) 1:6F #.!dci"!l 36666 + ))) 9999 dci"!l4)
For controllrs ot#r t#!n t# 9=?+:=> wit# E.tndd Rgistrs* t# l!st 3#ig#st4 rgistr in
t# l!st (il is7
For t# 9=?+:=> wit# E.tndd Rgistrs* t# l!st 3#ig#st4 rgistr in t# l!st (il is s#own
in t# two t!bls blow)
E.!"%ls o( ! ,ur' !nd rs%ons (ollow) An .!"%l o( ! r,ust to writ on grou% o(
r(rncs into sl!& d&ic 0: is s#own) T# grou% consists o( t#r rgistrs in (il ?*
st!rting !t rgistr = 3!ddrss 666:4)
Response
T# nor"!l rs%ons is !n c#o o( t# ,ur')
2'2'1 22 51# 8ex6 Mas1 <rite 4x Register
Modi(is t# contnts o( ! s%ci(id ?x rgistr using ! co"bin!tion o( !n AND "!s$* !n
OR "!s$* !nd t# rgistr/s currnt contnts) T# (unction c!n b usd to st or cl!r
indi&idu!l bits in t# rgistr) @ro!dc!st is not su%%ortd)
"ote7 T#is (unction is su%%ortd in t# 9=?+:=> controllr onl')
,uer-
T# ,ur' s%ci(is t# ?x r(rnc to b writtn* t# d!t! to b usd !s t# AND "!s$*
!nd t# d!t! to b usd !s t# OR "!s$)
T# (unction/s !lgorit#" is7
Rsult F 3Currnt Contnts AND AndJM!s$4 OR 3OrJM!s$ AND AndJM!s$ 4
For .!"%l*
"ote7 I( t# OrJM!s$ &!lu is -ro* t# rsult is si"%l' t# logic!l ANDing o( t# currnt
contnts !nd AndJM!s$) I( t# AndJM!s$ &!lu is -ro* t# rsult is ,u!l to t# OrJM!s$
&!lu)
"ote7 T# contnts o( t# rgistr c!n b r!d wit# t# R!d Holding Rgistrs (unction
3(unction cod 624) T#' could* #ow&r* b c#!ngd subs,untl' !s t# controllr sc!ns
its usr logic %rogr!")
Hr is !n .!"%l o( ! M!s$ 8rit to rgistr > in sl!& d&ic 0:* using t# !bo& "!s$
&!lus7
Response
T# nor"!l rs%ons is !n c#o o( t# ,ur') T# rs%ons is rturnd !(tr t# rgistr #!s
bn writtn)
2'2'1# 23 514 8ex6 Read % <rite 4x Registers
Pr(or"s ! co"bin!tion o( on r!d !nd on writ o%r!tion in ! singl Modbus
tr!ns!ction) T# (unction c!n writ nw contnts to ! grou% o( ?x rgistrs* !nd t#n rturn
t# contnts o( !not#r grou% o( ?x rgistrs) @ro!dc!st is not su%%ortd)
"ote7 T#is (unction is su%%ortd in t# 9=?+:=> controllr onl')
,uer-
T# ,ur' s%ci(is t# st!rting !ddrss !nd ,u!ntit' o( rgistrs o( t# grou% to b r!d) It
!lso s%ci(is t# st!rting !ddrss* ,u!ntit' o( rgistrs* !nd d!t! (or t# grou% to b writtn)
T# b't count (ild s%ci(is t# ,u!ntit' o( b'ts to (ollow in t# writ d!t! (ild)
Hr is !n .!"%l o( ! ,ur' to r!d si. rgistrs st!rting !t rgistr >* !nd to writ t#r
rgistrs st!rting !t rgistr 0C* in sl!& d&ic 0:7
Response
T# nor"!l rs%ons cont!ins t# d!t! (ro" t# grou% o( rgistrs t#!t wr r!d) T# b't
count (ild s%ci(is t# ,u!ntit' o( b'ts to (ollow in t# r!d d!t! (ild)
Hr is !n .!"%l o( ! rs%ons to t# ,ur'7
2'2'14 24 51: 8ex6 Read F2F( ,ueue
R!ds t# contnts o( ! (irst+in (irst+out 3FIFO4 ,uu o( ?x rgistrs) T# (unction rturns !
count o( t# rgistrs in t# ,uu* (ollowd b' t# ,uud d!t!) U% to 21 rgistrs c!n b
r!d+t# count* %lus u% to 20 ,uud d!t! rgistrs) T# ,uu count rgistr is rturnd
(irst* (ollowd b' t# ,uud d!t! rgistrs)
T# (unction r!ds t# ,uu contnts* but dos not cl!r t#") @ro!dc!st is not su%%ortd)
"ote7 T#is (unction is su%%ortd in t# 9=?+:=> controllr onl')
,uer-
T# ,ur' s%ci(is t# st!rting ?x r(rnc to b r!d (ro" t# FIFO ,uu) T#is is t#
!ddrss o( t# %ointr rgistr usd wit# t# controllr/s FIN !nd FOUT (unction bloc$s) It
cont!ins t# count o( rgistrs currntl' cont!ind in t# ,uu) T# FIFO d!t! rgistrs
(ollow t#is !ddrss s,unti!ll')
An .!"%l o( ! R!d FIFO 5uu ,ur' to sl!& d&ic 0: is s#own blow) T# ,ur' is
to r!d t# ,uu st!rting !t t# %ointr rgistr ?01?: 36?DE #.4)
Response
In ! nor"!l rs%ons* t# b't count s#ows t# ,u!ntit' o( b'ts to (ollow* including t#
,uu count b'ts !nd d!t! rgistr b'ts 3but not including t# rror c#c$ (ild4)
T# ,uu count is t# ,u!ntit' o( d!t! rgistrs in t# ,uu 3not including t# count
rgistr4)
I( t# ,uu count .cds 20* !n .c%tion rs%ons is rturnd wit# !n rror cod o( 62
3Illg!l D!t! V!lu4)
Hr is !n .!"%l o( ! nor"!l rs%ons to t# %r&ious ,ur'7
In t#is .!"%l* t# FIFO %ointr rgistr 3?01?: in t# ,ur'4 is rturnd wit# ! ,uu
count o( 2) T# t#r d!t! rgistrs (ollow t# ,uu count) T#s !r7
V ?01?= 3contnts ??6 dci"!l* 60@= #.4
V ?01?9 3contnts ?:?6* 01=? #.4
V ?01>6 3contnts ?=9=* 0211 #.4
Chapter 3
Diagnostic Subfunctions
V Modbus Function 6=+Di!gnostics
V Di!gnostic Cods Su%%ortd b' Controllrs
V Rturn 5ur' D!t!
V Rst!rt Co""unic!tions O%tion
V Rturn Di!gnostic Rgistr
V C#!ng ASCII In%ut Dli"itr
V Forc <istn Onl' Mod
V Cl!r Countrs !nd Di!gnostic Rgistr
V Rturn @us Mss!g Count
V Rturn @us Co""unic!tion Error Count
V Rturn @us E.c%tion Error Count
V Rturn Sl!& Mss!g Count
V Rturn Sl!& No Rs%ons Count
V Rturn Sl!& NAK Count
V Rturn Sl!& @us' Count
V Rturn @us C#!r!ctr O&rrun Count
V Rturn IOP O&rrun Count 3==?4
V Cl!r O&rrun Countr !nd Fl!g 3==?4
V Dt ; Cl!r Modbus Plus St!tistics
V Modbus Plus Ntwor$ St!tistics
3'1 Function 9:+Diagnostics
Modbus (unction 6= %ro&ids ! sris o( tsts (or c#c$ing t# co""unic!tion s'st"
btwn t# "!str !nd sl!&* or (or c#c$ing &!rious intrn!l rror conditions wit#in t#
sl!&) @ro!dc!st is not su%%ortd)
T# (unction uss ! two+b't sub(unction cod (ild in t# ,ur' to d(in t# t'% o( tst to
b %r(or"d) T# sl!& c#os bot# t# (unction cod !nd sub(unction cod in ! nor"!l
rs%ons)
Most o( t# di!gnostic ,uris us ! two+b't d!t! (ild to snd di!gnostic d!t! or control
in(or"!tion to t# sl!&) So" o( t# di!gnostics c!us d!t! to b rturnd (ro" t# sl!& in
t# d!t! (ild o( ! nor"!l rs%ons)
Diagnostic Effects on the Sla)e
In gnr!l* issuing ! di!gnostic (unction to ! sl!& d&ic dos not !((ct t# running o( t#
usr %rogr!" in t# sl!&) Usr logic* li$ discrts !nd rgistrs* is not !ccssd b' t#
di!gnostics) Crt!in (unctions c!n o%tion!ll' rst rror countrs in t# sl!&)
A sl!& d&ic c!n* #ow&r* b (orcd into K<istn Onl' Mod/ in w#ic# it will "onitor t#
"ss!gs on t# co""unic!tions s'st" but not rs%ond to t#") T#is c!n !((ct t#
outco" o( 'our !%%lic!tion %rogr!" it it d%nds u%on !n' (urt#r .c#!ng o( d!t! wit#
t# sl!& d&ic) Dnr!ll'* t# "od is (orcd to r"o& ! "!l(unctioning sl!& d&ic
(ro" t# co""unic!tions s'st")
8o* .his 2nfor/ation is (rgani=ed in >our &uide
An .!"%l di!gnostics ,ur' !nd rs%ons !r s#own on t# o%%osit %!g) T#s s#ow
t# loc!tion o( t# (unction cod* sub(unction cod* !nd d!t! (ild wit#in t# "ss!gs)
A list o( sub(unction cods su%%ortd b' t# controllrs is s#own on t# %!gs !(tr t#
.!"%l rs%ons) E!c# sub(unction cod is t#n listd wit# !n .!"%l o( t# d!t! (ild
contnts t#!t would !%%l' (or t#!t di!gnostic)
,uer-
Hr is !n .!"%l o( ! r,ust to sl!& d&ic 0: to Rturn 5ur' D!t!) T#is uss !
sub(unction cod o( -ro 366 66 #. in t# two+b't (ild4) T# d!t! to b rturnd is snt in
t# two+b't d!t! (ild 3A> 2: #.4)
Response
T# nor"!l rs%ons to t# Rturn 5ur' D!t! r,ust is to loo%b!c$ t# s!" d!t!) T#
(unction cod !nd sub(unction cod !r !lso c#od)
T# d!t! (ilds in rs%onss to ot#r $inds o( ,uris could cont!in rror counts or ot#r
in(or"!tion r,ustd b' t# sub(unction cod)
3'2 Diagnostic Codes Supported b- Controllers
Sub(unction cods !r listd in dci"!lB E indic!ts t#!t t# sub(unction is su%%ortd* !nd
N indic!ts t#!t it is not su%%ortd)
3'2'1 99 Return ,uer- Data
T# d!t! %!ssd in t# ,ur' d!t! (ild is to b rturnd 3loo%d b!c$4 in t# rs%ons) T#
ntir rs%ons "ss!g s#ould b idntic!l to t# ,ur')
3'2'2 91 Restart Co//unications (ption
T# sl!&/s %ri%#r!l %ort is to b initi!li-d !nd rst!rtd* !nd !ll o( its co""unic!tions
&nt countrs !r to b cl!rd) I( t# %ort is currntl' in <istn Onl' Mod* no rs%ons is
rturnd) T#is (unction is t# onl' on t#!t brings t# %ort out o( <istn Onl' Mod) I( t#
%ort is not currntl' in <istn Onl' Mod* ! nor"!l rs%ons is rturnd) T#is occurs b(or
t# rst!rt is .cutd)
8#n t# sl!& rci&s t# ,ur'* it !tt"%ts ! rst!rt !nd .cuts its %owr+u%
con(idnc tsts) Succss(ul co"%ltion o( t# tsts will bring t# %ort onlin)
A ,ur' d!t! (ild contnts o( FF 66 #. c!uss t# %ort/s Co""unic!tions E&nt <og to b
cl!rd !lso) Contnts o( 66 66 l!& t# log !s it w!s %rior to t# rst!rt)
3'2'3 92 Return Diagnostic Register
T# contnts o( t# sl!&/s 0C+bit di!gnostic rgistr !r rturnd in t# rs%ons)
3'2'4 8o* the Register Data is (rgani=ed
T# !ssign"nt o( di!gnostic rgistr bits (or Modicon controllrs is listd blow) In !c#
rgistr* bit 0> is t# #ig#+ordr bit) T# dscri%tion is TRUE w#n t# corrs%onding bit is
st to logic 0)
3'2' 93 Change !SC22 2nput Deli/iter
T# c#!r!ctr CHAR %!ssd in t# ,ur' d!t! (ild bco"s t# nd o( "ss!g dli"itr
(or (utur "ss!gs 3r%l!cing t# d(!ult <F c#!r!ctr4) T#is (unction is us(ul in c!ss
w#r ! <in Fd is not w!ntd !t t# nd o( ASCII "ss!gs)
3'2'# 94 Force $isten (nl- Mode
Forcs t# !ddrssd sl!& to its <istn Onl' Mod (or Modbus co""unic!tions) T#is
isol!ts it (ro" t# ot#r d&ics on t# ntwor$* !llowing t#" to continu co""unic!ting
wit#out intrru%tion (ro" t# !ddrssd sl!&) No rs%ons is rturnd)
8#n t# sl!& ntrs its <istn Onl' Mod* !ll !cti& co""unic!tion controls !r turnd
o(() T# R!d' w!tc#dog ti"r is !llowd to .%ir* loc$ing t# controls o(() 8#il in t#is
"od* !n' Modbus "ss!gs !ddrssd to t# sl!& or bro!dc!st !r "onitord* but no
!ctions will b t!$n !nd no rs%onss will b snt)
T# onl' (unction t#!t will b %rocssd !(tr t# "od is ntrd will b t# Rst!rt
Co""unic!tions O%tion (unction 3(unction cod =* sub(unction 04)
3'2'4 19 59! 8ex6 Clear Counters and Diagnostic Register
For controllrs ot#r t#!n t# >=? or 9=?* cl!rs !ll countrs !nd t# di!gnostic rgistr) For
t# >=? or 9=?* cl!rs t# countrs onl') Countrs !r !lso cl!rd u%on %owr+u%)
3'2': 11 590 8ex6 Return 0us Message Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs t#!t t# sl!& #!s dtctd on t#
co""unic!tions s'st" sinc its l!st rst!rt* cl!r countrs o%r!tion* or %owr+u%)
3'2'; 12 59C 8ex6 Return 0us Co//unication Error Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( CRC rrors ncountrd b' t# sl!& sinc
its l!st rst!rt* cl!r countrs o%r!tion* or %owr+u%)
3'2'19 13 59D 8ex6 Return 0us Exception Error Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( Modbus .c%tion rs%onss rturnd b' t#
sl!& sinc its l!st rst!rt* cl!r countrs o%r!tion* or %owr+u%) For ! dscri%tion o(
.c%tion rs%onss* s %!g )
3'2'11 14 59E 8ex6 Return Sla)e Message Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!&* or
bro!dc!st* t#!t t# sl!& #!s %rocssd sinc its l!st rst!rt* cl!r countrs o%r!tion* or
%owr+u%)
3'2'12 1 59F 8ex6 Return Sla)e "o Response Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!& (or w#ic# it
rturnd no rs%ons 3nit#r ! nor"!l rs%ons nor !n .c%tion rs%ons4* sinc its l!st
rst!rt* cl!r countrs o%r!tion* or %owr+u%)
3'2'13 1# 519 8ex6 Return Sla)e "!? Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!& (or w#ic# it
rturnd ! Ng!ti& Ac$nowldg 3NAK4 .c%tion rs%ons* sinc its l!st rst!rt* cl!r
countrs o%r!tion* or %owr+u%) For ! dscri%tion o( .c%tion rs%onss* s %!g )
3'2'14 14 511 8ex6 Return Sla)e 0us- Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!& (or w#ic# it
rturnd ! Sl!& D&ic @us' .c%tion rs%ons* sinc its l!st rst!rt* cl!r countrs
o%r!tion* or %owr+u%) For ! dscri%tion o( .c%tion rs%onss* s %!g )
3'2'1 1: 512 8ex6 Return 0us Character ()errun Count
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!& t#!t it could
not #!ndl du to ! c#!r!ctr o&rrun condition* sinc its l!st rst!rt* cl!r countrs
o%r!tion* or %owr+u%) A c#!r!ctr o&rrun is c!usd b' d!t! c#!r!ctrs !rri&ing !t t# %ort
(!str t#!n t#' c!n b stord* or b' t# loss o( ! c#!r!ctr du to ! #!rdw!r "!l(unction)
3'2'1# 1; 513 8ex6 Return 2(P ()errun Count 5::46
T# rs%ons d!t! (ild rturns t# ,u!ntit' o( "ss!gs !ddrssd to t# sl!& t#!t it could
not #!ndl du to !n ==? IOP o&rrun condition* sinc its l!st rst!rt* cl!r countrs
o%r!tion* or %owr+u%) An IOP o&rrun is c!usd b' d!t! c#!r!ctrs !rri&ing !t t# %ort
(!str t#!n t#' c!n b stord* or b' t# loss o( ! c#!r!ctr du to ! #!rdw!r "!l(unction)
"ote7 T#is (unction is s%ci(ic to t# ==?)
3'2'14 29 514 8ex6 Clear ()errun Counter and Flag 5::46
Cl!rs t# ==? o&rrun rror countr !nd rsts t# rror (l!g) T# currnt st!t o( t# (l!g is
(ound in bit 6 o( t# ==? di!gnostic rgistr 3s sub(unction 614)
"ote7 T#is (unction is s%ci(ic to t# ==?)
3'2'1: 21 51 8ex6 &et % Clear Modbus Plus Statistics
Rturns ! sris o( >? 0C+bit words 306= b'ts4 in t# d!t! (ild o( t# rs%ons 3t#is
(unction di((rs (ro" t# usu!l two+b't lngt# o( t# d!t! (ild4) T# d!t! cont!ins t#
st!tistics (or t# Modbus Plus %r %rocssor in t# sl!& d&ic)
In !ddition to t# Function cod 36=4 !nd Sub(unction cod 366 0> #.4 in t# ,ur'* ! two+
b't O%r!tion (ild is usd to s%ci(' it#r ! Dt St!tistics or ! Cl!r St!tistics o%r!tion)
T# two o%r!tions !r .clusi&+t# Dt o%r!tion c!nnot cl!r t# st!tistics* !nd t# Cl!r
o%r!tion c!nnot rturn st!tistics %rior to cl!ring t#") St!tistics !r !lso cl!rd on
%owr+u% o( t# sl!& d&ic)
T# o%r!tion (ild i""di!tl' (ollows t# sub(unction (ild in t# ,ur'7
V ++ A &!lu o( 66 62 s%ci(is t# Dt St!tistics o%r!tion)
V ++ A &!lu o( 66 6? s%ci(is t# Cl!r St!tistics o%r!tion)
,uer-
T#is is t# (ild s,unc in t# ,ur'7
&et Statistics Response
T#is is t# (ild s,unc in t# nor"!l rs%ons to ! Dt St!tistics ,ur'7
Clear Statistics Response
T# nor"!l rs%ons to ! Cl!r St!tistics ,ur' is !n c#o o( t# ,ur'7
3'2'1; Modbus Plus "et*or1 Statistics
"ote7 8ord 6: bit"!%s !r usd intrn!ll' b' t# %r %rocssor to dtr"in w#ic# %!t#s
#!& !lr!d' #!d ! co""!nd snt to t#" during t# currnt to$n ownrs#i%) T#is li"its
t# nu"br o( co""!nds %r %!t# to on during ! singl to$n ownrs#i%)
"ote7 8ords 6= ))) 01 !r to$n ownr wor$ t!bls) T#' !r bit"!%s r%rsnting wor$
t#!t nds to b don b' t# nod t# n.t ti" it gts t# to$n) E!c# b't is ! bit"!%
corrs%onding to wor$ r,ustd o( !c# o( t# ig#t %!t#s o( t# indic!td t'%)
"ote7 8ords 02 ))) 11 cont!in %!irs o( =+bit countrs t#!t %rt!in to crt!in t'%s o( rror
conditions !s wll !s to succss(ul tr!ns!ctions) Undr nor"!l o%r!ting conditions* t#
onl' b'ts t#!t c#!ng !r word 16 <O !nd HI) 8ord 0? HI could !lso incr"nt bc!us
o( !n MSTR or si"il!r %rogr!""ing rror in t# !%%lic!tion) I( !n' ot#r b'ts incr"nts*
! %ossibl %robl" .ists on t# ntwor$+)g)* in ! singl st!tion or wiring connction)
"ote7 8ords 12 ))) 1C cont!in t# !cti& st!tion bit"!%s) An !cti& st!tion is !n' on t#!t
#!s snt %!c$ts o( d!t! o&r t# ntwor$)
"ote7 8ords 1: ))) 26 cont!in t# to$n st!tion t!bl bit"!%s) A to$n st!tion is !n' on
t#!t #!s to$n+%!ssing c!%!bilitis)
"ote7 8ords 20 ))) 2? cont!in t# glob!l d!t! %rsnt t!bl bit"!%s) E!c# ti" ! st!tion
%!sss ! to$n* it !lso %!sss t# glob!l d!t!* &n i( t#r !r -ro b'ts o( glob!l d!t!)
8#n on st!tion ss !not#r %!ss t# to$n wit# glob!l d!t!* it sts its bit in its t!bl (or
t#!t ot#r st!tion) T# bit r"!ins st until t# st!tion r!ds t# glob!l d!t! (ro" t#!t ot#r
st!tion* !(tr w#ic# t# bit is cl!rd) A scond r!d o( glob!l d!t! indic!ts t#!t no glob!l
d!t! is %rsnt)
"ote7 In scrn 1 o( t# M@PSTAT %rogr!"* t# nu"br o( glob!l d!t! words %rsnt is
indic!td undr t# st!tion nu"br) I( t#is (ild is (illd wit# s%!cs* t#n M@PSTAT #!s
r,ustd t# glob!l d!t! (ro" ! scond ti" b(or t# ot#r st!tion %!ssd t# to$n)
"ote7 T# <O b'ts o( words 2> ))) 2: indic!t t# us o( t# intrn!l rci& bu((rs wit#in
t# %r %rocssor)
Chapter 4
Exception Responses
V E.c%tion Rs%onss
V E.c%tion Cods
4'1 Exception Responses
E.c%t (or bro!dc!st "ss!gs* w#n ! "!str d&ic snds ! ,ur' to ! sl!& d&ic it
.%cts ! nor"!l rs%ons) On o( (our %ossibl &nts c!n occur (ro" t# "!str/s ,ur'7
V I( t# sl!& d&ic rci&s t# ,ur' wit#out ! co""unic!tion rror* !nd c!n #!ndl t#
,ur' nor"!ll'* it rturns ! nor"!l rs%ons)
V I( t# sl!& dos not rci& t# ,ur' du to ! co""unic!tion rror* no rs%ons is
rturnd) T# "!str %rogr!" will &ntu!ll' %rocss ! ti"out condition (or t# ,ur')
V I( t# sl!& rci&s t# ,ur'* but dtcts ! co""unic!tion rror 3%!rit'* <RC* or CRC4*
no rs%ons is rturnd) T# "!str %rogr!" will &ntu!ll' %rocss ! ti"out condition (or
t# ,ur')
V I( t# sl!& rci&s t# ,ur' wit#out ! co""unic!tion rror* but c!nnot #!ndl it 3(or
.!"%l* i( t# r,ust is to r!d ! non.istnt coil or rgistr4* t# sl!& will rturn !n
.c%tion rs%ons in(or"ing t# "!str o( t# n!tur o( t# rror)
T# .c%tion rs%ons "ss!g #!s two (ilds t#!t di((rnti!t it (ro" ! nor"!l rs%ons7
Function Code Field
In ! nor"!l rs%ons* t# sl!& c#os t# (unction cod o( t# origin!l ,ur' in t#
(unction cod (ild o( t# rs%ons) All (unction cods #!& ! "ost signi(ic!nt bit 3MS@4 o(
6 3t#ir &!lus !r !ll blow =6 #.!dci"!l4) In !n .c%tion rs%ons* t# sl!& sts t#
MS@ o( t# (unction cod to 0) T#is "!$s t# (unction cod &!lu in !n .c%tion
rs%ons .!ctl' =6 #.!dci"!l #ig#r t#!n t# &!lu would b (or ! nor"!l rs%ons)
8it# t# (unction cod/s MS@ st* t# "!str/s !%%lic!tion %rogr!" c!n rcogni- t#
.c%tion rs%ons !nd c!n .!"in t# d!t! (ild (or t# .c%tion cod)
Data Field
In ! nor"!l rs%ons* t# sl!& "!' rturn d!t! or st!tistics in t# d!t! (ild 3!n'
in(or"!tion t#!t w!s r,ustd in t# ,ur'4) In !n .c%tion rs%ons* t# sl!& rturns !n
.c%tion cod in t# d!t! (ild) T#is d(ins t# sl!& condition t#!t c!usd t# .c%tion)
Hr is !n .!"%l o( ! "!str ,ur' !nd sl!& .c%tion rs%ons) T# (ild .!"%ls !r
s#own in #.!dci"!l)
In t#is .!"%l* t# "!str !ddrsss ! ,ur' to sl!& d&ic 06 36A #.4) T# (unction
cod 3604 is (or ! R!d Coil St!tus o%r!tion) It r,usts t# st!tus o( t# coil !t !ddrss
01?> 36?A0 #.4)
"ote7 Onl' on coil is to b r!d* !s s%ci(id b' t# nu"br o( coils (ild 366604)
I( t# coil !ddrss is non.istnt in t# sl!& d&ic* t# sl!& will rturn t# .c%tion
rs%ons wit# t# .c%tion cod s#own 3614) T#is s%ci(is !n illg!l d!t! !ddrss (or t#
sl!&) For .!"%l* i( t# sl!& is ! 9=?+2=> wit# >01 coils* t#is cod would b rturnd)
4'2 Exception Codes
Chapter
!pplication "otes
V M!.i"u" 5ur' ; Rs%ons P!r!"trs
V Esti"!ting Sri!l Tr!ns!ction Ti"ing
V A%%lic!tion Nots (or t# >=? !nd 9=?A ; @ ; A
'1 Maxi/u/ ,uer- % Response Para/eters
T# listings s#ow t# "!.i"u" !"ount o( d!t! t#!t !c# controllr c!n r,ust or snd in !
"!str ,ur'* or rturn in ! sl!& rs%ons) All (unction cods !nd ,u!ntitis !r in dci"!l)
1:4%3:4
4:4
T#s &!lus !r (or !n =K controllr) S t# 484 User's Guide (or li"its o( s"!llr
controllrs)
:4
::4
M:4
;:4
'2 Esti/ating Serial .ransaction .i/ing
T# (ollowing s,unc o( &nts occurs during ! Modbus sri!l tr!ns!ction) <ttrs in
%!rnt#ss 3 4 r(r to t# ti"ing nots !t t# nd o( t# listing)
1 T# Modbus "!str co"%oss t# "ss!g)
2 T# "!str d&ic "od" RTS !nd CTS st!tus !r c#c$d) 3 !4
3 T# ,ur' "ss!g is tr!ns"ittd to t# sl!&) 3 04
4 T# sl!& %rocsss t# ,ur' "ss!g) 3 C* D4
T# sl!& c!lcul!ts !n rror c#c$ (ild) 3 E4
# T# sl!& d&ic "od" RTS !nd CTS st!tus !r c#c$d) 3 !4
4 T# rs%ons "ss!g is tr!ns"ittd to t# "!str) 3 04
: T# "!str !%%lic!tion !cts u%on t# rs%ons !nd its d!t!)
.i/ing "otes
A I( t# RTS !nd CTS %ins !r Gu"%rd togt#r* t#is ti" is ngligibl) For H?:= "od"s*
t# ti" is !bout > "s)
@ Us t# (ollowing (or"ul! to sti"!t t# tr!ns"ission ti"7
Ti" 3"s4 F 0666 I 3c#!r!ctr count4 I 3bits;c#!r!ctr4
@!ud R!t
C T# Modbus "ss!g is %rocssd !t t# nd o( t# controllr sc!n) T# worst+c!s dl!'
is on sc!n ti"* w#ic# occurs i( t# controllr #!s Gust bgun ! nw sc!n) T# !&r!g
dl!' is #!l( t# sc!n ti")
T# ti" !llottd (or sr&icing Modbus %orts !t t# nd o( t# controllr sc!n 3b(or
bginning ! nw sc!n4 d%nds u%on t# controllr "odl) Ti"ing (or !c# "odl is
dscribd on t# n.t %!g)
For ?=? controllrs t# ti" is !%%ro.i"!tl' 0)> "s) T# Modbus %ort is !&!il!bl on !
contntion b!sis wit# !n' H?:6 ; H?:? ; H?:> t#!t is %rsnt)
For >=? !nd 9=? controllrs t# ti" is !%%ro.i"!tl' 0)> "s (or !c# Modbus %ort) T#
%orts !r sr&icd s,unti!ll'* st!rting wit# %ort 0)
For 0=? ; 2=? controllrs t# ti" &!ris !ccording to t# !"ount o( d!t! bing #!ndld) It
r!ngs (ro" ! "ini"u" o( 6)> "s to ! "!.i"u" o( !bout C)6 "s 3(or 066 rgistrs4* or :)6
"s 3(or =66 coils4) I( ! %rogr!""ing %!nl is currntl' bing usd wit# t# controllr* t#
Modbus %ort is loc$d out)
D Modbus (unctions 0 t#roug# ?* 0>* !nd 0C %r"it t# "!str to r,ust "or d!t! t#!n
c!n b %rocssd during t# ti" !llotd (or sr&icing t# sl!&/s Modbus %ort) I( t# sl!&
c!nnot %rocss !ll o( t# d!t!* it will bu((r t# d!t! !nd %rocss it !t t# nd o( subs,unt
sc!ns)
T# !"ount o( d!t! t#!t c!n b %rocssd during on sr&ic %riod !t t# Modbus %ort is
!s (ollows7
"ote7 984-X8X r(rs to 9=? slot "ount "odls 39=?+2=>* +C=>* tc4)
For t# ==?* t# %rocssing ti" (or "ulti%l d!t! is !s (ollows7
E <RC c!lcul!tion ti" is lss t#!n 0 "s) CRC c!lcul!tion ti" is !bout 6)2 "s (or !c#
ig#t bits o( d!t! to b rturnd in t# rs%ons)
'3 "otes for the :4 and ;:4! % 0 % @
0aud Rates
8#n using bot# Modbus %orts 0 !nd 1* t# "!.i"u" !llow!bl co"bind b!ud r!t is
09*166 b!ud)
Port $oc1ups
8#n using ASCII* !&oid snding -ro+d!t!+lngt# "ss!gs or "ss!gs wit# no d&ic
!ddrss) For .!"%l* t#is is !n illg!l "ss!g7
: CR LF (colon CR LF)
R!ndo" %ort loc$u%s c!n occur t#is $ind o( "ss!g is usd)
.er/inating !SC22 Messages
ASCII "ss!gs s#ould nor"!ll' tr"in!t wit# ! CR<F %!ir) 8it# t# >=? !nd 9=?A;@;A
controllrs* !n ASCII "ss!g c!n tr"in!t !(tr t# <RC (ild 3wit#out t# CR<F
c#!r!ctrs bing snt4* i( !n intr&!l o( !t l!st 0 s is !llowd to occur !(tr t# <RC (ild) I(
t#is #!%%ns* t# controllr will !ssu" t#!t t# "ss!g #!s tr"in!td nor"!ll')
Chapter #
$RC % CRC &eneration
V <RC Dnr!tion
V CRC Dnr!tion
#'1 $RC &eneration
T# <ongitudin!l Rdund!nc' C#c$ 3<RC4 (ild is on b't* cont!ining !n ig#t+bit
bin!r' &!lu) T# <RC &!lu is c!lcul!td b' t# tr!ns"itting d&ic* w#ic# !%%nds t#
<RC to t# "ss!g) T# rci&ing d&ic rc!lcul!ts !n <RC during rci%t o( t#
"ss!g* !nd co"%!rs t# c!lcul!td &!lu to t# !ctu!l &!lu it rci&d in t# <RC (ild)
I( t# two &!lus !r not ,u!l* !n rror rsults)
T# <RC is c!lcul!td b' !dding togt#r succssi& ig#t+bit b'ts in t# "ss!g*
disc!rding !n' c!rris* t#n two/s co"%l"nting t# rsult) T# <RC is !n ig#t+bit (ild*
t#r(or !c# nw !ddition o( ! c#!r!ctr t#!t would rsult in ! &!lu #ig#r t#!n 1>>
dci"!l si"%l' rolls o&r t# (ild/s &!lu t#roug# -ro) @c!us t#r is no nint# bit* t#
c!rr' is disc!rdd !uto"!tic!ll')
&enerating an $RC
Step 1 Add !ll b'ts in t# "ss!g* .cluding t# st!rting colon !nd nding CR<F) Add
t#" into !n ig#t+bit (ild* so t#!t c!rris will b disc!rdd)
Step 2 Subtr!ct t# (in!l (ild &!lu (ro" FF #. 3!ll 0/s4* to %roduc t# ons+co"%l"nt)
Step 3 Add 0 to %roduc t# two/s+co"%l"nt)
Placing the $RC into the Message
8#n t# t# ig#t+bit <RC 3two ASCII c#!r!ctrs4 is tr!ns"ittd in t# "ss!g* t# #ig#
ordr c#!r!ctr will b tr!ns"ittd (irst* (ollowd b' t# low ordr c#!r!ctr+)g)* i( t#
<RC &!lu is C0 #. 36006 666047
Figure : $RC Character SeAuence
Exa/ple
An .!"%l o( ! C l!ngu!g (unction %r(or"ing <RC gnr!tion is s#own blow) T#
(unction t!$s two !rgu"nts7
!nsigned c"a# $a!c"Msg % & 'ointe# to t"e message (!ffe#
con)

taining (ina#* data to (e !sed fo#

gene#ating t"e LRC
!nsigned s"o#t !s+ataLen % ,"e -!antit* of (*tes in t"e
message (!ffe#.
T# (unction rturns t# <RC !s ! t'% unsignd c#!r)
$RC &eneration Function
static !nsigned c"a# LRC(a!c"Msg !s+ataLen)
!nsigned c"a# $a!c"Msg % .$ message to calc!late $.
!nsigned s"o#t !s+ataLen % .$ LRC !'on -!antit* of $.
.$ (*tes in message $.
/
!nsigned c"a# !c"LRC 0 0 % .$ LRC c"a# initiali1ed $.
2"ile (!s+ataLen))) .$ 'ass t"#o!g" message $.
!c"LRC 30 $a!c"Msg33 % .$ (!ffe# add (!ffe# (*te$.
.$ 2it"o!t ca##* $.
#et!#n ((!nsigned c"a#)()((c"a#4!c"LRC))) %
.$ #et!#n t2os com'lemen $.
5
#'2 CRC &eneration
T# C'clic!l Rdund!nc' C#c$ 3CRC4 (ild is two b'ts* cont!ining ! 0C+bit bin!r' &!lu)
T# CRC &!lu is c!lcul!td b' t# tr!ns"itting d&ic* w#ic# !%%nds t# CRC to t#
"ss!g) T# rci&ing d&ic rc!lcul!ts ! CRC during rci%t o( t# "ss!g* !nd
co"%!rs t# c!lcul!td &!lu to t# !ctu!l &!lu it rci&d in t# CRC (ild) I( t# two
&!lus !r not ,u!l* !n rror rsults)
T# CRC is st!rtd b' (irst %rlo!ding ! 0C+bit rgistr to !ll 0/s) T#n ! %rocss bgins o(
!%%l'ing succssi& ig#t+bit b'ts o( t# "ss!g to t# currnt contnts o( t# rgistr)
Onl' t# ig#t bits o( d!t! in !c# c#!r!ctr !r usd (or gnr!ting t# CRC) St!rt !nd sto%
bits* !nd t# %!rit' bit* do not !%%l' to t# CRC)
During gnr!tion o( t# CRC* !c# ig#t+bit c#!r!ctr is .clusi& ORd wit# t# rgistr
contnts) T# rsult is s#i(td in t# dirction o( t# l!st signi(ic!nt bit 3<S@4* wit# ! -ro
(illd into t# "ost signi(ic!nt bit 3MS@4 %osition) T# <S@ is .tr!ctd !nd .!"ind) I(
t# <S@ w!s ! 0* t# rgistr is t#n .clusi& ORd wit# ! %rst* (i.d &!lu) I( t# <S@
w!s ! 6* no .clusi& OR t!$s %l!c)
T#is %rocss is r%!td until ig#t s#i(ts #!& bn %r(or"d) A(tr t# l!st 3ig#t#4 s#i(t*
t# n.t ig#t+bit c#!r!ctr is .clusi& ORd wit# t# rgistr/s currnt &!lu* !nd t#
%rocss r%!ts (or ig#t "or s#i(ts !s dscribd !bo&) T# (in!l contnts o( t# rgistr*
!(tr !ll t# c#!r!ctrs o( t# "ss!g #!& bn !%%lid* is t# CRC &!lu)
&enerating a CRC
Step 1 <o!d ! 0C+bit rgistr wit# FFFF #. 3!ll 0/s4) C!ll t#is t# CRC rgistr)
Step 2 E.clusi& OR t# (irst ig#t+bit b't o( t# "ss!g wit# t# low ordr b't o( t#
0C+bit CRC rgistr* %utting t# rsult in t# CRC rgistr)
Step 3 S#i(t t# CRC rgistr on bit to t# rig#t 3tow!rd t# <S@4* -ro(illing t# MS@)
E.tr!ct !nd .!"in t# <S@)
Step 4 I( t# <S@ is 6* r%!t St% 2 3!not#r s#i(t4) I( t# <S@ is 0* E.clusi& OR t# CRC
rgistr wit# t# %ol'no"i!l &!lu A660 #. 30606 6666 6666 66604)
Step R%!t St%s 2 !nd ? until ig#t s#i(ts #!& bn %r(or"d) 8#n t#is is don* !
co"%lt ig#t+bit b't will #!& bn %rocssd)
Step # R%!t St%s 1 ))) > (or t# n.t ig#t+bit b't o( t# "ss!g) Continu doing t#is
until !ll b'ts #!& bn %rocssd)
Result T# (in!l contnts o( t# CRC rgistr is t# CRC &!lu)
Step 4 8#n t# CRC is %l!cd into t# "ss!g* its u%%r !nd lowr b'ts "ust b
sw!%%d !s dscribd blow)
Placing the CRC into the Message
8#n t# 0C+bit CRC 3two ig#t+bit b'ts4 is tr!ns"ittd in t# "ss!g* t# low ordr b't
will b tr!ns"ittd (irst* (ollowd b' t# #ig# ordr b't+)g)* i( t# CRC &!lu is 01?0 #.
36660 6606 6066 666047
Figure ; CRC 0-te SeAuence
Exa/ple
An .!"%l o( ! C l!ngu!g (unction %r(or"ing CRC gnr!tion is s#own on t#
(ollowing %!gs) All o( t# %ossibl CRC &!lus !r %rlo!dd into two !rr!'s* w#ic# !r
si"%l' ind.d !s t# (unction incr"nts t#roug# t# "ss!g bu((r) On !rr!' cont!ins
!ll o( t# 1>C %ossibl CRC &!lus (or t# #ig# b't o( t# 0C+bit CRC (ild* !nd t# ot#r
!rr!' cont!ins !ll o( t# &!lus (or t# low b't)
Ind.ing t# CRC in t#is w!' %ro&ids (!str .cution t#!n would b !c#i&d b'
c!lcul!ting ! nw CRC &!lu wit# !c# nw c#!r!ctr (ro" t# "ss!g bu((r)
"ote7 T#is (unction %r(or"s t# sw!%%ing o( t# #ig#;low CRC b'ts intrn!ll') T# b'ts
!r !lr!d' sw!%%d in t# CRC &!lu t#!t is rturnd (ro" t# (unction) T#r(or t#
CRC &!lu rturnd (ro" t# (unction c!n b dirctl' %l!cd into t# "ss!g (or
tr!ns"ission)
T# (unction t!$s two !rgu"nts7
!nsigned c"a# $'!c"Msg % & 'ointe# to t"e message (!ffe#
containing (ina#* data to (e !sed
fo#
gene#ating t"e CRC
!nsigned s"o#t !s+ataLen % ,"e -!antit* of (*tes in t"e
message (!ffe#.
T# (unction rturns t# CRC !s ! t'% unsignd s#ort)
CRC &eneration Function
!nsigned s"o#t CRC16('!c"Msg !s+ataLen)
!nsigned c"a# $'!c"Msg % .$ message to calc!late CRC
!'on $.
!nsigned s"o#t !s+ataLen % .$ -!antit* of (*tes in message
$.
/
!nsigned c"a# !c"CRCHi 0 0xFF % .$ "ig" CRC (*te
initiali1ed $.
!nsigned c"a# !c"CRCLo 0 0xFF % .$ lo2 CRC (*te
initiali1ed $.
!nsigned !7ndex % .$ 2ill index into
CRC
loo8!'$.
.$ ta(le
$.
2"ile (!s+ataLen))) .$ 'ass t"#o!g" message (!ffe#
$.
/
!7ndex 0 !c"CRCHi 9 $'!c"Msgg33 % .$ calc!late t"e CRC
$.
!c"CRCHi 0 !c"CRCLo 9 a!c"CRCHi:!7ndex5 %
!c"CRCLo 0 a!c"CRCLo:!7ndex; %
5
#et!#n (!c"CRCHi << 8 = !c"CRCLo) %
5
8igh (rder 0-te .able
.$ ,a(le of CRC >al!es fo# "ig")o#de# (*te $.
static !nsigned c"a# a!c"CRCHi:; 0 /
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1
0x00 0xC1 0x81 0x?0 0x00 0xC1 0x81 0x?0 0x01 0xC0
0x80 0x?1 0x01 0xC0 0x80 0x?1 0x00 0xC1 0x81 0x?0
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x00 0xC1
0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0 0x80 0x?1
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x00 0xC1
0x81 0x?0 0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x00 0xC1 0x81 0x?0
0x01 0xC0 0x80 0x?1 0x01 0xC0 0x80 0x?1 0x00 0xC1
0x81 0x?0 0x01 0xC0 0x80 0x?1 0x00 0xC1 0x81 0x?0
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x00 0xC1 0x81 0x?0
0x01 0xC0 0x80 0x?1 0x00 0xC1 0x81 0x?0 0x01 0xC0
0x80 0x?1 0x01 0xC0 0x80 0x?1 0x00 0xC1 0x81 0x?0
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1
0x00 0xC1 0x81 0x?0 0x00 0xC1 0x81 0x?0 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1
0x01 0xC0 0x80 0x?1 0x00 0xC1 0x81 0x?0 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0 0x00 0xC1 0x81 0x?0
0x01 0xC0 0x80 0x?1 0x01 0xC0 0x80 0x?1 0x00 0xC1
0x81 0x?0 0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1
0x00 0xC1 0x81 0x?0 0x01 0xC0 0x80 0x?1 0x01 0xC0
0x80 0x?1 0x00 0xC1 0x81 0x?0
5 %
$o* (rder 0-te .able
.$ ,a(le of CRC >al!es fo# lo2)o#de# (*te $.
static c"a# a!c"CRCLo:; 0 /
0x00 0xC0 0xC1 0x01 0xC3 0x03 0x0@ 0xC@ 0xC6 0x06
0x0A 0xCA 0x0B 0xCB 0xC? 0x0? 0xCC 0x0C 0x0+ 0xC+
0x0F 0xCF 0xCC 0x0C 0x0& 0xC& 0xCB 0x0B 0xCD 0x0D
0x08 0xC8 0x+8 0x18 0x1D 0x+D 0x1B 0x+B 0x+& 0x1&
0x1C 0x+C 0x+F 0x1F 0x++ 0x1+ 0x1C 0x+C 0x1? 0x+?
0x+B 0x1B 0x+A 0x1A 0x16 0x+6 0x+@ 0x1@ 0x13 0x+3
0x11 0x+1 0x+0 0x10 0xF0 0x30 0x31 0xF1 0x33 0xF3
0xF@ 0x3@ 0x36 0xF6 0xFA 0x3A 0xFB 0x3B 0x3? 0xF?
0x3C 0xFC 0xF+ 0x3+ 0xFF 0x3F 0x3C 0xFC 0xF& 0x3&
0x3B 0xFB 0x3D 0xFD 0xF8 0x38 0x@8 0xC8 0xCD 0x@D
0xCB 0x@B 0x@& 0xC& 0xCC 0x@C 0x@F 0xCF 0x@+ 0xC+
0xCC 0x@C 0xC? 0x@? 0x@B 0xCB 0x@A 0xCA 0xC6 0x@6
0x@@ 0xC@ 0xC3 0x@3 0xC1 0x@1 0x@0 0xC0 0x&0 0x60
0x61 0x&1 0x63 0x&3 0x&@ 0x6@ 0x66 0x&6 0x&A 0x6A
0x&B 0x6B 0x6? 0x&? 0x6C 0x&C 0x&+ 0x6+ 0x&F 0x6F
0x6C 0x&C 0x&& 0x6& 0x6B 0x&B 0x6D 0x&D 0x&8 0x68
0xA8 0xB8 0xBD 0xAD 0xBB 0xAB 0xA& 0xB& 0xBC 0xAC
0xAF 0xBF 0xA+ 0xB+ 0xBC 0xAC 0xB? 0xA? 0xAB 0xBB
0xAA 0xBA 0xB6 0xA6 0xA@ 0xB@ 0xB3 0xA3 0xB1 0xA1
0xA0 0xB0 0xB0 0xD0 0xD1 0xB1 0xD3 0xB3 0xB@ 0xD@
0xD6 0xB6 0xBA 0xDA 0xBB 0xDB 0xD? 0xB? 0xDC 0xBC
0xB+ 0xD+ 0xBF 0xDF 0xDC 0xBC 0xB& 0xD& 0xDB 0xBB
0xDD 0xBD 0xB8 0xD8 0x88 0x?8 0x?D 0x8D 0x?B 0x8B
0x8& 0x?& 0x?C 0x8C 0x8F 0x?F 0x8+ 0x?+ 0x?C 0x8C
0x?? 0x8? 0x8B 0x?B 0x8A 0x?A 0x?6 0x86 0x8@ 0x?@
0x?3 0x83 0x?1 0x81 0x80 0x?0
5 %

You might also like