0% found this document useful (0 votes)
141 views23 pages

HMI Modbus Help

This document provides a guide for using the Modbus RTU protocol with an HMI to connect to a controller. It discusses how Modbus RTU frames are structured and transmitted over RS485. Function codes for reading and writing registers are described. Instructions are given for configuring an HMI to communicate with a controller using Modbus RTU.

Uploaded by

Iman Peykar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views23 pages

HMI Modbus Help

This document provides a guide for using the Modbus RTU protocol with an HMI to connect to a controller. It discusses how Modbus RTU frames are structured and transmitted over RS485. Function codes for reading and writing registers are described. Instructions are given for configuring an HMI to communicate with a controller using Modbus RTU.

Uploaded by

Iman Peykar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

HMI    Modbus RTU

  
 

1393 
:  
Version : 1.0
 :  
www.knowledgeplus.ir

www.controlsystemco.com
   :   

 :  

   :   


HMI Modbus RTU

 
3 .............................................................................................................................................................  -1

4 .......................................................................................................................... Modbus RTU


  -2

4 ....................................................................................................... : Modbus RTU  (Frame)   -1-2

5 ............................................................................................................. : (Function Codes) 


 -2-2

6 :(3 ) (Read Holding Registers) 


      2-2-1-
8 :(6 ) (Write Single Register)   $%
# !"  2-2-2-
9 ................................................................................................................................      -3

11 .................................................................................................................................. HMI_Modbus    -4

11 ................................................................................................................... : HMI_Modbus.h*% &' -1-4

11 :
31/2 -./0 +%, -1-1-4

12 : Modbus
 7 # USART 6 Timer 45 -2-1-4

13 .................................................................................................................... : HMI_Modbus.c*% &' -1-4

15 ................................................................................................................................ HMI "    ! 5-

2|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

 -1
! " #  !   
  
 

   
 
    

   +/  0
 *
  +   ,  -   .  ! 
# $
  $% &'()

" #  8   4 6 3


+7  ! LCD 2  3

 40, 52   5
 &01 1

. 01 6  :*
 0
 (HMI) / 
#
!:#

&42 9*

:
4
36= HMI !4(< 2 

? &!
0C! -  2D ? &  #   ! AB@ 9B

? &@% - $% , ?


? &F=     G  -C% H0I 9J
? & E  !
% 9B
? & !
0C! 7

0
 #

  M0= ? &'() 
 -C%  / L 
? &

-C%   K

61  9J
? &!
#
   '() OP H 
? & 3=N5
2D  $% 
   

? &'() 
0
56
!: #

? &S 0Q/ R ? &8J 4+ ? &'()  !

M 

 - !4(<  3

@   T   K   0I %!   

. 

Modicon 4 1 T   H



 1979 9   4
9 56
: # G Modbus : #
9B
4,  U 52   
 01 *
5 ! PLC H .6

 ( Schneider Electric %! 
.1 
: # H
'() !4 
! - 
  '5 H .6

 &: # H
T  

RTU ! 4 
. RTU , ASCII , TCP :
06=   U 
< 
 : # H

3 4  

!61  TCP 4   1 


 H#  A7*   GI  ! 61  S% ASCII 
.
   Ethernet 0 V


 (% /
 4
 


  '() !4(<  !4%<  = ! HMI
,12 )   1
Siemens, Omron, LS, Mitsubishi, Panel Master , Beiger , Delta , Fararo Paya 

 Modbus RTU : # !HMI H


R%!  (1 0 

42 HMI G M 4@ H
  4

.0 6C#

42 PK43 90 HMI .6



 RS485 

4) @  Modbus RTU 4 
" # H

    Master 
=  HMI  4
01 
Panel Master 7 M  Cermate 4 1

.   0!
2 :%= Slave 
=  ATXmega

3|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

Modbus RTU  


-2
          (Request/Reply) /  
 Modbus
 & +,-" .*  Slave
 ' (   )*  Slave #$ % &"  Master   !
6 7"  8 ! #'  9$:;" ."  4 (Bus) 2  3 
  0"  % 1 
!  C Bus 
  = >? !  >@: A" 6 6' B* ! .& 6&   ( 6 7<" .* Bus
" 8  6' )"! =B H  & G (Half Duplex) 6(   EF 6 RS485 D2 
H> )& EJK ( 1I     4 Bus 
  6' 8 #$ $ %'   
.(& M" RS485 2" RE,DE
: Modbus RTU  (Frame)   -1-2

! 2  014   (  )&"  Slave 


Master   ! 6' "> $
: (Figure 1)(   6 OP ! ( 
 0> )&
Device ID Function Code Data Bytes CRC16 Check
1 Byte 1 Byte  >:$J '  0" n Bytes 2 Bytes
8 .*  >:$J ' %.* "&  "  >:$J '  0" <F   '
Slave (Table 2) R2 & 1 I 
 %" EJK
Figure 1 : Modbus RTU Transmission Frame
H '
&  256 ! -> 2 ( / ) #>   S'I Modbus RTU 

 0")  
 #>  6' B* ! .&  6G4
)

T  - EF 6  #>
 V )"! E" @   >@ 8  %#>  C )& +,-" A" 6 %&" >U" ( >:$J '
6 . >@" A  & #$  #> 014 %& ( > 42=12 * 3/5)  3/5 ! -> > H * ( ! &
H  &"  => Start > 
%Parity >  % Stop >
 % > -   $ 6 :J
%& 19200 bps   Baud rate @ S"   .T >@" A  > 12       > 
42*52=2184  4I #> C +>,-   >
 6>?
>" 52 >   )"! E"
.& 6>?
>"
(   H Slave #$ %&" ![* Master  !    Z
& Y4

#>  )* .* 6' %Slave 8 %&"  V Stop bit H * ( ! > 42 4I 6' "!
'"
  )*  )& "* \<" 6
'"  ) ' "* 6 Z
& %& +,-" 
(Figure 2).'"

4|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

 42  
Master +,   %" -  $ %# &%' ! 
 ( ) ! *
Master ! "#


42 
Slave $ %#  %" ! Slave +,  &%' - 
  

! "# &%'

Figure 2 : Master/Slave Data Transmission Diagram


Slave             
  (PLC) 
  

 .    Master ,-  HMI +  HMI $% &"'


!  (" ! &) * +!
#! " 
 8" 1
.3) 7 HMI * +"1  2 4 5% , ,* 6' , 6! :3) 1 
 1
#! ! 2 ./

! "  C%  1 " ,*+ HMI A% , 6! 7 B" &"' 


1 " HMI
 ) 9;<  
* = > -?@

.+"+/
#! "  Master   HMI * Slave ,-   * 6! #" D*  2  2   . ... * +"1 

: (Function Codes)  


-2-2

1 &"'
* 2/"  * 1 ,+"
  * (Table 1) +/ E %  F"  &G Modbus  3 @ 
Table 2)/!  < %* <! % 3-
+
.(

   / 


   

5 %#   3% 4! %"  %! !   PLC   2 0!  Discretes
8   -9!  67  
%" $1  0!
  Input
PLC 
Coils
 3% 4!   48%  %! !    2 0! 

8% $1  0!


 ;< =#  ) -9!  '" %#     

5 %#   3% 4! %"  %! !   PLC   2 0!  Input
8   -9!  67 >' 
%" $1  16
  Registers
EEPROM ?SRAM @  %#  5*< =
A%B  6# ) 3% 5 5> 5 8 Flash ! 
 2 0!   Holding
  CD  2
>' 
8% ? %"  16
!"#$ Registers
Table 1 Modbus Data types
:

Modbus function codes


Function type Function name Function code
Physical Discrete Inputs Read Discrete Inputs 2
Bit access Read Coils 1
Internal Bits or Physical Coils Write Single Coil 5
Write Multiple Coils 15
Data Access Physical Input Registers Read Input Registers 4
Read Holding Registers 3
16-bit access Internal Registers or Physical Output Write Single Register 6
Registers Write Multiple Registers 16
Read/Write Multiple Registers 23
5|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014
www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
Mask Write Register 22
Read FIFO Queue 24
File Record Access Read File Record 20
Write File Record 21
Read Exception Status 7
Diagnostic 8
Diagnostics Get Com Event Counter 11
Get Com Event Log 12
Report Slave ID 17
Read Device Identification 43
Other Encapsulated Interface Transport 43
Table 2 : Modbus RTU Function Codes
 !
 (Holding Register)   
  HMI  
 

, -& '


* "#$ +# (&
 
    %&' (!'&)  & 
 "#$ !  

!&)  2 3&  4"0


10  HMI  &/' '0   & 
10  . !

(6 !)  
    %&' (3 !)  
 (!'&)  "#$ ! 67 8    .!%

.&%
 2 3&

   >? (


 (Word)  *&<  =   
   % ;& !

10   .!' &;   %&'/(!'&) D8 C .!%  ' ( @ )  @  67  AB&

2 3&  
HMI  ,7' F8 1 &
  =  GH  . HMI D 
'
.&%


:(3  ) (Read Holding Registers)


       -1-2-2

.&%
   
 I&" @ (!'&) &
  "#$ !  

(Figure 3)!%  J%  ! Master &)


Slave ID 0x03 Starting Address Quantity of Registers CRC16 Check
1 Byte (0-255) 1 Byte 2 Bytes (0-65535) 2 Bytes (0-127) 2 Bytes

  0 - () '$ !  + (  - $% .$/ 0 () * + *$% &'   

Slave +234 $% (, ()   1 (, !"#

 0x04 0x03 0x00C1 0x0002 0x95A2


Figure 3 : Read Holding Register Request Frame
4)&O$ 2 I&" @ &/
 &) 4 GH  Slave
Master N : L& ,K

N 

+ ? ='  Master 6& D ' CRC16 ! .! , &%


P % (0xC1) 193 GH      (

. !% 3

6&   +# ( B   !


H + ? ='   CRC16 !   Q  +R

TUK
) U  ATXMEGA  
CRC16 ! ! & ! Master
(  SC )

B  &


 
 U   #
  ;&  
 . ! & J B (ATXMEGA64A3U

6|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
   C              
   

:(Code 1) !    "  Delta !

/**************************** CRC16 Generation C Code ****************************/


unsigned int CRC_16=0xFFFF;
for (unsigned char i=0;i<Buff_Lenght;i++)
{
CRC_16^= Request_Buffer[i];
for(unsigned char ii=0;ii<8;ii++)
{
if(CRC_16 & 0x01)
CRC_16=(CRC_16>>1 ) ^ 0xA001;
else
CRC_16=CRC_16 >>1;
}//end of for(ii)
}//end of for(i)
Code 1: CRC16 Generation C Code
.  ' Request_Buffer[] &$   ! "! % Buff_Lenght $   #

  !  - ( HMI Master


* +  )   ! "( &$ Request_Buffer[]

.  /+ $   "    


45 (($ !  23 ) $ CRC16  0 + 01 !  % ( 


) Slave   

 ; <= >(  ?  " 0 + @  6  67   89 (($ ! ) CRC16  

!(  B CD @ A 57 CRC16  "7    (Figure 5)


. " - >( 0 + HMI 

. Figure 4)
( " -

Figure 4
( )  G
   E?  F  ( !(  Slave CD
Slave ID 0x03 Byte Count Register Values CRC16
1 Byte (0-255) 1 Byte 1 Byte (0-256) N Bytes (0-65535)
*
2 Bytes**

  4 1  !  2 3    !. /0 $ ! %& '( )  

LSB +,  MSB  )


0'  
Slave ( $ ! %& '( /0 =)%$ (  !"#

5( 6'7 5( 6'

 0x04 0x03 0x04 6667(Dec) 39(Dec) 0xD460


0x1A 0x0B 0x00 0x27
Figure 4 : Read Holding Register Response Frame
I -J  . "8  (  F %  CD 0 + -H "   H 1 *
!(  F 10 LJ M -? @!  ! 9 CD 0 + -H     !(  F  K

7|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU



 :   :  Slave
: )   25   
 
.(CRC16: !
! "#$  % : 
.

0$+ (Code 1) / ("&"$,!"-) Slave *+ CRC16 & ' **
(Figure 5)  "/ 5- 6  6789 ;"#$ / < =3 +3
6 Slave 1" / 23 4
Slave ID 0x83 Exception code CRC16 Check
1 Byte (0-255) 1 Byte 1 Bytes (1-4) 2 Bytes
Slave 
  1 +,-. */ 0 '% $% )*  
*
$% &' # (    !" # 

 0x04 0x83 0x01 0x20F4


Figure 5 : Read Holding Register Error Frame
: ,> 23 ;  *
."#$ 
 
23 : 0x02  ? .+ >$  +   : 0x01  ?
Slave @$+

23 : 0x04  ? .

 % 
23 : 0x03  ?
(Modbus_Protocol.PDF)
 6"  6F 58 49 AB0C 6   D 5 EF ;"
:(6 ) (Write Single Register)    
   -2-2-2

.

0$+ 6789 ;"#$ / - ;! D$= 7, 6   D /
(Figure 6)  "/ 5- 6  Master +3

Slave ID 0x06 Register Address Register Value CRC16 Check
1 Byte (0-255) 1 Byte 2 Bytes (0-65535) 2 Bytes (0-65535) 2 Bytes

  1 63  )*   +23 */  3# + 4 !" # 
+,-. */ 1
Slave +,-. */ '5 

 0x02 0x06 0x000F 0x003A 0x39E9


Figure 6: Write Single Register Request Frame
 ;"#$ ;!  (0x3A)58  % + 6$+3 2 
  Slave @$+
/ Master @$+
: G8 H 

.+  68F  ;'$= 6 Master *+ I= CRC16  .


I" (0xF)16 

("3  !
IJ ) < CRC16    8
/  ("&"$,!"- Slave I=   D 

KLM 23 ;!9  $8


  <
 N!0$ NC 
! , 6% ("3  !
) CRC16  !
" 6>+B
"#  /    EBC CRC16 6 C 
 .(Figure 8) , + 23  HMI 6 !


.(Figure 7)
 + +3
 O+,$  "#$  % 
 +3

(Figure 7)  "/ 5- 6  6789"#$  ;! D$= +3


6 Slave 

8|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
Slave ID 0x06 Register Address Register Value CRC16 Check
1 Byte (0-255) 1 Byte 2 Bytes (0-65535) 2 Bytes (0-65535) 2 Bytes

  , 1&  0' !  $%& '(  & $ )   
$-./ '( ,
Slave $-./ '( *+ !"#

 0x02 0x06 0x000F 0x003A 0x39E9


Figure 7 : Write Single Register Response Frame
.                  
 *
(Figure 8) % ! 01 %  % &' ()* + ,- /*    % Slave 
! " #$
Slave ID 0x86 Exception code CRC16 Check
1 Byte (0-255) 1 Byte 1 Bytes (1-4) 2 Bytes
Slave 
  , $-./ '( 1&  6+* 23 0' ! 
*
23 4*  5   !"#   

 0x04 0x86 0x01 0x24AB


Figure 8 : Write Single Register Error Frame
(Modbus_Protocol.PDF)   ;    9 0 ' 49 4567 %  / 0  89 : ,%*

  
 -3

F  + G' HMI % @ A: ,%  BC ! D-  E  % ,   <% =' > ! ?- /
H )  I*-1 ! I/O    /% %  !    RS485 ,=' > *<%  USART H 
,    % F $#
 H  ,% (Half Duplex) '
+ RS485  J    "  .(RxD,TxD,EN) 
EJ Low    /  % '  !  - J High  (MAX485  )L/*' IC % @ % RE,DE
.   *6L EN    B    /  I*-1 ! ,  % ?- / 
ISL83485 ,C !  :  E    I- -( ? *I- % ATXMEGA , I*-1  BC !
3.3

.  6*    '   ! %  *( % -  I-  Intersil   
3.3

= H  @ A: ,% - E   6* (www.knowledgeplus.ir) M   * ! C % ! ?- / ,%
% H P: ,%    + - LED $  NO E RS485 ,% IC + 0    *  - (
, %
,C ,  - ,- %     (Figure 9 , Figure 10) RS485 % +:  4Q  . %  Earth
(560) -  +  % (120)R % -  % -#$ ( Fail-Safe ,? I 1:   H ) RS485 HA
    !  " !-% ! ,L T  / T$ E  SP Pulldown(560) -  + - Pullup
07- ,C - %   -  % *  ,-- I (    R % ,-    ,C  :
I (  ,C   !  EB 4  % A<  A 4  ? *I-   :U % -  - /  ' 9 D-  . A
.  / V: E   Idle

9|Page www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

Figure 9 :Schematic of RS485 Board

Figure 10 : Assembled RS485 Board Photos


PCB.rar      Altium Designer V10 
  RS485  SCH  PCB  
. ) (Build_RS485.PDF) (  RS485 "  #$ %&'  ! . 
(  Analog Device   RS485* +    ISL83485 * +  Datasheet
. 

10 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

HMI_Modbus  -4

HMI  ATXMEGA 
 Atmel 

 
   
 IAR Ver 6.3.1
    
." HMI_Modbus.h  HMI_Modbus.c !      
.  !  "#$ %    
     
HMI_Modbus.h&'( )
: -1-4

0! *+, -
/ &2 .( )  Header"'
! &1 :" # $%   ! 
.5 -
/ #4 &4 . Modbus 
 4  USART 3 Timer 12 &3

: !( *+ ,' -1-1-4

*+, -
/ # )) *
9  ( " ; <=
4    "'1 
  "678 $
:2  
 . (Hardware Definitions) 0!
?, @A 31 ?,  " ">
'  )  I/O  4   ")   ) i .
:  TxD CD   ">
' C *4 1B 4 1 "
#define HMI_TXD_DIR(_) PORTC_DIRSET=PIN7_bm //Set TXD Pin as Output
.(Net_LED)  )
   LED )D E *D@F !)  G #6 2  =
4  )
: .1 " ?,  " Toggle  Reset 3 Set 
2 )  4  ") H  ii .
#define HMI_EN_SET(_) PORTC_OUTSET=PIN5_bm //Set EN Pin to High(Data Out)
Vector  Register H   1 " ?,  G
  Baud rate  / # ) iii .

2 ) ">
'  ) CD   "4  J )1 " ?,  )B ) USART  

: .(1!
K
#define HMI_BAUD_SELECT 38400 //USART Baud rate = 38400
bps
#define HMI_USART_CTRLA USARTC1_CTRLA //USART CTRLA Register
#define HMI_USART_DATA USARTC1_DATA //USART DATA Register
#define HMI_USART_TXD_INT_VECT USARTC1_TXC_vect //USART TxD Interrupt Vector
?, (Modbus Timeout Timer)
6  
Vector  Register  / 678 ) iv .
:M@A .)
#define HMI_MB_TIMER_CTRLA TCD1_CTRLA //Modbus Timer CTRLA Register
#define HMI_MB_TIMER_INT_VECT TCD1_OVF_vect //Modbus Timer Interrupt Vector

:M@A .1 ?,  (Slave)



 
 N)O  $ )  .v
11 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014
www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
#define HMI_MODBUS_ID 0x01 //Slave Address

.    


   HMI   
 

$ '(

  EEPROM SRAM   
 
  !"  
  #  
 $%&
*  

  12 3  
45
 .0 + , - /   HMI )  *$

 
 2 2 "  
0 HMI   
 7& 
  EEPROM  6 SRAM 

:. / 
5 
  
 
#define EEPROM_MNU_PARAM_NO 200
#define SRAM_MNU_PARAM_NO 200
. 
0< 
 9 8$;0 .c 9 8, #  

: Modbus 
  USART  Timer  -2-1-4

:=2
/ >0? USART
 (#define) 2 #  
 .i
1) #define HMI_USART_TRANSMITTER(_) { }
C B2
D  '0 (Flag)!A- B 
 B2
7&
 '0 Interrupt
 
 
 (1
30000 >  ="  =2
/ 
5 B2
=)  (EN) =/B2
=) E 
$ FG2 -
. K
$< RS485 2  D  2 I
D$&J

 9*$2
2) #define HMI_USART_RECIEVER(_) {}
= D  '0 (Flag)!A- B 
 = 7&
 '0 Interrupt
 
1$  
 (2

. / 
5 = =)  (EN) =/B2
=) E 
 FG2 - C 

3) #define HMI_USART_TXD_WAIT(_) {}
D !A D M  
 
 
J USART L20 = M B2
 

   
 (3

I
D$&J
0  9*$2 8000 ="   C  NO 2


 !A 
FG2  B2

  =)   45


.0 K
$< (HMI) PQ 6 2   B2
N
 N$<R =
. 9*$2 8000 I
 & 
0 
0 I
$S  $< 

Q 9&3   /

  Modbus Timeout & !$ 0   


 
5 (#define) "A  #   .ii
 & D 50  - & 
Q D Reset -&  $)
 
Q : I
(3 !$ 
- 

. 
0< 
 9 8$;0 .c 9 8, #   & 
*T&3 0  .D K I


 ="

.
  U0 $  
 
 V
 (6) (3) $T&3   ="  .iii

12 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

: HMI_Modbus.c   -1-4

 Slave ATXMEGA  Master   HMI   


  
 

 $%  $* +  ATXMEGA  $% &      '() .  # RS485 ! "

 5 $ 4     2   3 ) 4 (USART 0%))  $  $* ,- 

"$* 97" 6  7 4  $* $


 2 Reset )   $*


2 *> ? 4 HMI_MB_Recieve_Index =  :  ;< (HMI_MB_Recieve_Buffer[])

)
@ $* "  5 $   "A% $ B% C DC   2C E  $ ;7 $* C

6  C   H#  .  2 F%  ' 9#     2 (Overflow)F% G
B% $K   7  L% M5 "$* 97" "- &I-) C J  2 +  *  

(Figure 11). 2

USART       


Overflow

Modbus Timer
T=10 Char


   
Modbus Timer Overflow Interrupt

Receiver Transmitter
RS485 EN Pin

Figure 11 : Modbus Transmission Diagram


:$% (Function)H) N & HMI_Modbus.c &*
: void HMI_Modbus_Initialising(void) H) .i

5 " # EP  H) 9:   5  (main)2IP  0%)  $% 2J) K) H) 
 6R USART  ' E+) QA%
* # 32MHz " " Q*   H)   .  2

.$%   7 ) $K 

: __ interrupt void HMI_USART_RXD_Interrupt(void) H) .ii

13 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
(USART_RXC_vector)        
USART   
     

 
"  %"   '   USART ' & $! % & "
 . #!  "
.#! Reset -  Modbus Timeout 
,
!    #  )*+ (HMI_MB_Recieve_Buffer[])
: __ interrupt void HMI_USART_TXD_Interrupt (void) 
 .iii
(USART_TXC_vector) -       
USART   
/ -     

 
#! (true)/ -     
,
! (Flag) 01  % & "
 . #!  "

#! 45 USART & 3-  &

/ ' ! 2   3(HMI_Data_Trasmited=true)
.# / 01    0)6 
74!
__ : void HMI_MB_Timer_Interrupt (void) 
 .iv
interrupt

' #!  "   6 !   .#!  " Modbus   (Overflow) 8   

 
 =)

 *%      '   >! ' ; 
 *  ) / USART : ;  < 4' 9)!
 (Frame) , H =5
4 BC 
)*   !  D
 4E)
FG; &
). 4#?@ 4' '   !


.(# " ! : Modbus RTU



   4
<   ) BC 3 Modbus    ' -  )K  

  
L%  ;   #6 M9E! 4   ) CRC 76  ' C 3#! 
CRC_Check_Program()

F # # $
N! (HMI_MODBUS_ID) < 4' 9)! L%
("4   )" - 
) Slave  24
.'! O"  '  !%
4   4
3#
!  )M ' (HMI_MB_Recieve_Buffer[1])"4   )" 
)! P6% 
"O"  )" %  # ;
! case  (6 3) )M ' 
Q 4! switch
&  )  4*  -2 2 =5
5 BC ).'! -  RS   !%  (HMI_MB_Response_Buffer[])
-

(#  V)W 37 T & )U4! &


4#6  6* & < T 3O"  *
)U4! L% : ;  $ Modbus >9   P6%  : & W 0X! 496 / V)W P 
 C L%  ' 0)'!   

30)#
4#  4 EEPROM  SRAM & )U4! 
0)6!
L%   EEPROM  #  )*+ & 4!  Y45! EEPROM_MNU_PARAM_NO L%
Y45! (EEPROM_MNU_PARAM_NO+ SRAM_MNU_PARAM_NO) L%  EEPROM_MNU_PARAM_NO
 4 29
, H &
>9    '   24    .#
SRAM  "! & )U4!
.#!  4 29   F6  ' 8P! &
Z )  ( PLC 6 !)'!
% \ )4])
L% 3#
100

EEPROM & )U4!  ' C  - [! &

% \ )4])


L%  20

(EEPROM_Menu_Parameters[19]) EEPROM& )U4!
14 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014
www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
    HMI     120   (SRAM_Menu_Parameters[19]
) SRAM 
.     W120  W20 
:void Send_HMI_MB_Response(char Response_Buffer[] , char Buff_Lenght)  ! .v
&'" $  :         HMI_MB_Timer_Interrupt()  ! "#!   ! 
2#  CRC  /!  !  $01 .(Buff_Lenght)    ,-  
!  (Response_Buffer[])"* +
<=#    7 4 # 9/;   USART  8    .  34 4 567   +
.  2# ?   A CRC  9 A     Update  CRC  3 9   2#  >?@
: bool CRC_Check_Program(char volatile Recieve_Buffer[] , char Recieve_Index)  ! .vi
 .G  7 40#  (USART "#!) 4 9  B-5C 9DE #   !  F
9  F 9#   Recieve_Buffer[]  9# 4 9  9   
! H@ Recieve_Index
  9   ?I ) Recieve_Buffer[]$  F 40#  4 6#D CRC  G  ! A  .4 9 
3(  Boolean BE  ) !  + 3   (   9  )4 9  CRC   ( 
.   false BE  J   true
:  >! HK'  L   F 40#  39 A  
1- Copy "HMI_Modbus.c" , "HMI_Modbus.h" , "avr_compiler.h" to your project folder
2- Add "HMI_Modbus.c" in your project
3-Include "HMI_Modbus.h" in your project header file(Or in main file)
4- Adjust USART & Modbus_Timer parameters(Hardware Definitions) in "HMI_Modbus.h" Carefully.
5- Add "HMI_Modbus_Initialising();" in first line of main function
6- Add SRAM & EEPROM parameters array in each file that you want to change in this parametres:
__eeprom extern unsigned int EE_Menu_Parameters[EEPROM_MNU_PARAM_NO];
extern unsigned int SRAM_Menu_Parameters[SRAM_MNU_PARAM_NO];

HMI   


-5

I! &  Cermate 9 9# PK43 2 HMI F 4K'    0G  C>@
 9# O  HMI  ? &  6 N HMI   M   ? & 6/ 39# 4 40# Master_Panel
F Cermate  HMI ?   .9G   O   ? & ;   > ! > G 
9 # F > ! >O  BE    ? &  3 40# PM_Designer Ver2.0  ? &
. A! Software Download P / www.cermate.com

15 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
(On_Line_Simulator)  
     PM_Designer   
      
&' " ()*  #  "  +  ,  - !."#   HMI   
#$ # !%  &    !  "
.(&  ! Mouse  67- ()* 8  9" 5#   ) . "  ! 2+# HMI / $.
 0 1+

 ,&  Help  F1   !  &   !  + " ; <  #  = "  
 Help
.&  AB&  
 <  ?   " @#     9 " $>  !  

   
 .i
( HMI_Test 0HI)
 " #  $2 . ." G !
  New (. F File &.  $$8 CD# >  E  
$2 76+  .(PK043 # 4.3 J I  ) ." 2 <  HMI J$ # $
 9D# > C ?K 6 #
 =  $  D# >    " .$
& L. ( - !."#  D# >  )$
 >  ,  < ! >
:(Figure 12)$ 

Figure 12 : HMI New Link


5 7L.  $  7!% < ! >  "  8& $  .$
& L. USART < ! > $2  
"  
 5$ I"$% Timeout Time ! > .(Figure 13)$.  ! 
&? < - !."#  USART
&? J    HMI ?    5$ Command Delay # $." J   N >  *  - !."# 
. $2

16 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

Figure 13 : HMI Link Parameters

PM Designer   


.ii

   .    Project Manager  View   
     
$2  "&1+ ( * " + Global /*

 +
, -   Project Manager $%  & '(  )  !"#
(Figure 14).,    ( HMI_Test 567) "&1+ ( * "  .   3

Figure 14 : HMI Project Manager window

  (Objects)<=>  $ ; 2  & " 


,   +  /icon 
!"# 9 ( + :  
: (Figure 17) + (Figure 16)  (Figure 15). ,
? @ A !"#

17 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

Figure 15 : List of top bottons-1

Figure 16 : List of top bottons-2

Figure 17 : List of bottom bottons

(New Screen)     



#)          !    " "  HMI  
 
2 3 4 5/  (Screen Botton(b)),-./  0"1  (' ( * $ $ % &
</ (  $ 2  :"; %  #37 ( %/  New Screen(a) "1 " "9 * ( 3   .( 67/
( BC 2  " "9 * > ( 3  % "D.(?
 @ A $4)(;/ = . > /  $ $ # ;

18 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

! Project Manager>Screens  
      .   " 
" 
,-(/ .'(% )*+ Screen Properties(c) #$%  & ! '(% Double Click 
 
, $% 4  .# Background ! General 3Tab    0 1/ 2  Screen_Properties
= (>  %   3 Base Screen (&:; <*
 % + %9  6  7  8! Help   5&
5&#(A  % & :8 (@& 7   8   ( 1/ = (>  # )# ?&@ Base 
  Base_Screen = (>   5& ! #
 )!C Base 
    #
   B  

  Base_Screen = (>  % HMI_Test.pm3 ,G!/  Base1  #(
) .; D E&
.(#((%  :
E&  + Base1     ! + )# ) %  Main, Setting, Page2
:    
 
 
  5* & ! I!#8 7JB> 7+#(3 IB 
   =  (Figure 17) 3#$%  )*+ 
'+    =C ! '(% K$% =C ! Mouse  +  % D  :8  K& 3 =%     .%
. Double Click M
C ! #& #
     % & :8 L  '(   .'(%

 (&:; K& & ! Visibility Tab K& 7)#     % & :8 L L(  N&O
 

$+!   Object =C 1&L


#> & 1&L
=  =C <*
 %   8! Visibility_controled_by_bit
K& 202 RC  MA  ; % + )# S (Figure 18) PB  IQ   .% I*(%  K&
.L
)  1&L
 5& T  !  )  1&L

 Object #

Figure 18 : Visibility Control

:   

0 1/ = = (>  $E
7 Panel Master  . + ?$* 3= 
N*/ HMI & :  B&
 Languages (&:; Project (  #& + = =%     7# )*+ PU ) L3 ! +
(Figure 19):'3  & PB   =C ! '(% <*

Figure 19 : Languages List

19 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
  !" " #   $        
       
(Figure 20)' .,' #-
. / 0$ 1 # 2 3 (Font Templates ('$*
Project ')   %& #

Figure 20 : Font Tempelates

3 /#   6     1 .  !" (Text(d)) 5  6     
%&  89:   ; $   <=    .,   7 # 3 ( / ,'  Double_Click
;/ ?  @/; # > #  
 /   !" $  # ;/ 6 9>' ( #  $  
.,' !" 3  AB" / ,'     %&  # 3  $ 

:    

!" Screen Botton(b) 5  5 (  6C
 $ / D$ (    6#  
 #% '  5 6$ G=C ( #  3 /# Double_Click / " $F; 5" ,"#  1 . 
: (Figure 21)# ;/ Tab H #2I ,   #   #  $*;

Figure 21 : Properties tabs

('$*
<=     6'M9 .,'  #/ ,$/  3  " #    L#9 General K= #
 .O ,'  N=C #  5 $G / 6 Lable K= # .C
 5 (  Previous_Screen
$ / # " $/G <=    Q$  # ;/ '$*
/  5 $G <=    :  " P

20 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

 .( ) !" 


  
   

 ( )   
    
 

: &' $ 


() *+),- !/
0!" Advanced %  #$
89
);  89 $ )< !=+5 56 3) 4 56
))7  0!" -12 #   : Enabled by bit
$ 389 )<  4 (W7.2) 7 >$? 
)7" @ &0 ) 2
A 3  B("
@ C0+ $ 8D" 
.


(Figure 22) 89


); *$0E #
);
.

Figure 22 : Enabled by bit

)< # @ -0!" A


$ @ FG & H)-!" B(" -12 #   : Enabled by User Level
$0J 1"$ 
 $ 0/$
$ @ 3)< @   89 )< 
-12 #  !"-A .-- I

Panel>Passwords 0-" @ $ A1"$ # 0!"    L


9 
$ 1"$ FG 9 K0+'" $ .0!"

?  89 
 B(" FG @
M   =" 
 $ $ 0/ 1"$  
$ FG
2 .H)A
))7

.  !
 )< ?  0!" 3 )<

*$0E  3   ? >$?  !) 0 


( )< 2
A 3-12 #   : Notification
A0/ PQJ
) # 56  Off  $ State  !$0E $ .0!" 4 (Pulse) ,O5  (Level)!+N
.

 89 
3
IE @
()   #))9 -12 # 
 !"@
2 : Minimum Hold Time
.0 89     B(" "@ R@  S6 $?  )<

!I" !Q :


T Q" U $   $ # .
 !I" $ )< 0!" Visibility % @ I 
FG @ I   (Controlled By bit) ) 4 @ I  
 3 (Invisible)!+N *$0E  0

))7 $ )< SO" 9  0!" % # $ #)-V+A . (Controlled By User Level)
$

.(Dimension)H)A

:    

 .H)- 4 
IE HN  ,O5 *$0E  $ ) 4 0!" Bit Button(e) )< @ I 

3
@ C0+ $ D" - * I" 0!" 0/!" ?  $ @ =0!" ?  $ )<  !$?  0

))7 W302.7 >$? )< # 


(    !$0E $ # -!"
))7 W212.3 >$?  )< SQ
.(Figure 23)A!" 56

21 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU

Figure 23: Write address , Monitor address

.          


 / 
. %& '      (  
  
)* $ #
 Bit Lamp(f)
 !" 

:  
  / 
 &
0' General %-  .

+ 
+   , $ Numeric Entry(g)
 !" 
9- :   #
  $6 (Display type)%& 78  (Data type)3 4
+ 56 $   !12

 (  2 = 7 8 $6 9-  ( !  (>* Range Check < ( ('#; Advanced %-  .
A=   ! B@ <+
C  ! 8   ?@ !   (   2 ;      
. '  D =  E"'  2 "
. !" Numeric Display(h)
 #

+  %&  

:  

General %-  . !" Function Button(i)
 &F
"   "  <=  
 (   @  . G-H 
; <=
 $ H>   (  3 4
 &
0'
HMI ' J8 ( $   4(8 '

+ 4$

+ : 'A2  <= $


  !"
....  # F
 %& 4% >   & 21K 7
@L 4M J8  > ; ' C 4

:  


   !" . iii

(  B@ F
 . '  OP N"   B@  ) !  ( J  Compile(j)
$ 
. ! %& B@ = O8 4B@  Double Click  ()M    6 %& ( (8  
"(
A  . "(
A Offline(l)   Online  (  $6 $ (  #
6
,> OP  )
RS485 C ( Q  N   
' (>* 
P ( = C  RS485 Q Q"  Online
HMI ' D,
: (Run Online Simulation J'#; Tools ' ) Online "(
A J   $  '  R

D1  (  (   ( $ HMI  @ ( 
 $   U2 !) V> $R  .
' !"
.
' F  &2

22 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

 :  

   :   


HMI Modbus RTU
:HMI    .iv
USB     :
  HMI        
    
   

 '%&  HMI  $


 Driver "# ! Download(m)        . Flash_Disk

. 
( )! % *+ 


   "
   -/  01 +  
   HMI  
   , 
   )! 2 

01  PRP 1 6
78 9  # ;<   Build_Panel_Runtime_Package_(PRP) 3 45 Panel '

HMI #/! '  21  HMI   +  "01 '


 1 2  % 7!   .# ;<  -/ 
.# ;<   Update_From_File 3 45


 

!  "%  6=


& 2  ) 
 >  *  ?1 @  ", )!7 4 4A !   & 

 '
   2EF  . 
1 
C 7 'DED   2 [email protected] B  Email
.% ? G ?H
8  "  E/(  =
& 2 

J! 'C I )1 '  

23 | P a g e www.knowledgeplus.ir Ver: 1.0 - Sep,2014


www.controlsystemco.com

You might also like