background image

SMAX MODBUS®

8    Programming examples

Hereafter are some examples of both reading and writing parameters. Unless
otherwise stated, all values are expressed in hexadecimal notation.

8.1 Using the 03 Read Holding Registers function code

EXAMPLE 1

Request to read the  

Preset value [0001 hex]

  parameter (register 2) to the

Slave having the node address 1.

Request PDU

 (in hexadecimal notation)

[01][03][00][01][00][01][D5][CA]
where:
[01] = Slave address
[03] = 

03 Read Holding Registers

 function code

[00][01] = starting address (

Preset value [0001 hex]

 parameter, register 2)

[00][01] = number of requested registers
[D5][CA] = CRC

Response PDU

 (in hexadecimal notation)

[01][03][02][05][DC][BA][8D]
where:
[01] = Slave address
[03] = 

03 Read Holding Registers

 function code

[02] = number of bytes (2 bytes for each register)
[05][DC] = value of register 2, 05 DC hex = 1500 dec
[BA][8D] = CRC

Preset value [0001 hex]

 parameter (register 2) contains the value 05 DC hex,

i.e. 1500 in decimal notation; in other words the value set in the 

Preset value

[0001 hex]

 parameter is 1500 dec.

MAN SMAX MB E 1.2

Programming examples

77 of 84

Содержание SMAX-AI1-PRG-L2

Страница 1: ...S 485 interface Up to IP69K protection rate Suitable for the following models SMAX MB Table of Contents Safety summary 12 Identification 14 Mechanical installation 15 Electrical connections 19 Quick r...

Страница 2: ...on herein is subject to change without notice and should not be construed as a commitment by Lika Electronic s r l Lika Electronic s r l reserves the right to make all modifications at any moments and...

Страница 3: ...pin connector 20 4 2 Ground connection 20 4 3 Node address 21 4 4 Data transmission rate baud rate and parity bit 21 4 5 Bus termination resistor 21 4 6 Diagnostic LED Figure 3 22 5 Quick reference 2...

Страница 4: ...cription 45 6 3 Transmission modes 46 6 3 1 RTU transmission mode 47 6 4 Function codes 49 6 4 1 Implemented function codes 49 03 Read Holding Registers 49 04 Read Input Register 51 06 Write Single Re...

Страница 5: ...ection 72 Alarm 73 7 2 Exception response and exception codes 74 8 Programming examples 77 8 1 Using the 03 Read Holding Registers function code 77 8 2 Using the 04 Read Input Register function code 7...

Страница 6: ...W Version 0005 hex 72 L Load default parameters 67 M Machine data not valid 33 69 Mounting error 69 N Node address 35 Node address 0004 hex 65 O Offset value 35 Offset value 0002 hex 63 Operating para...

Страница 7: ...t to highlight the parts of the text where information of great significance for the user can be found user must pay the greatest attention to them Instructions must be followed strictly in order to g...

Страница 8: ...rent SMAX AI1 analogue interface SSI analogue interface encoders are provided with their own technical documentation It is mandatory to pair the sensor with the MTAX type magnetic scale The measuring...

Страница 9: ...or fibre optic Client A Client is any network device that sends data requests to servers MODBUS follows the Client Server model MODBUS Masters are referred to as Clients while MODBUS Slaves are Server...

Страница 10: ...LRC Checking In ASCII mode messages include an error checking field that is based on a Longitudinal Redundancy Checking LRC calculation that is performed on the message contents exclusive of the begi...

Страница 11: ...unicate on a MODBUS serial line using the RTU mode each 8 bit byte in a message contains two 4 bit hexadecimal characters The main advantage of this mode is that its greater character density allows b...

Страница 12: ...uipment Lika Electronic assumes no liability for the customer s failure to comply with these requirements 1 2 Electrical safety Turn OFF power supply before connecting the device connect according to...

Страница 13: ...echanical installation has to be carried out with stationary mechanical parts do not disassemble the unit do not tool the unit delicate electronic equipment handle with care do not subject the device...

Страница 14: ...number when reaching Lika Electronic for purchasing spare parts or needing assistance For any information on the technical characteristics of the product refer to the technical catalogue Warning devi...

Страница 15: ...1 Overall dimensions values are expressed in mm 3 2 Magnetic tape The sensor has to be paired with the MTAX type magnetic scale only For detailed information on the MTAX type tape and how to mount it...

Страница 16: ...unt when the sensor moves in the direction indicated by the arrow further information can be found in the Code sequence section on page 64 WARNING The system cannot operate if mounted otherwise than i...

Страница 17: ...rip is applied The distance D see Figure 2 between the centre of the screw fixing holes and the MTAX magnetic scale has to be as follows without cover strip with cover strip 31 7 mm 33 2 mm 1 248 1 30...

Страница 18: ...023 and 680 mm 26 771 for further information refer the order code in the product datasheet As the sensor area has always to be fully within the limits of the tape magnetic surface then the maximum m...

Страница 19: ...S485 OUT 2 Green 5 B_RS485 OUT 2 Orange 6 n c White 7 n c Grey 8 Shield Shield Case 1 OVdc of the RS 485 serial line too 2 In order to minimize cable reflections and ensure a defined noise level on th...

Страница 20: ...erly the cable shield to ground on user s side Lika s EC pre assembled cables are fitted with shield connection to the connector ring nut in order to allow grounding through the body of the device Lik...

Страница 21: ...aud rate and parity bit The data transmission rate baud rate and parity bit is set via software in the Serial com baud rate 0005 hex register see on page 65 The default value is 04 hex Baud rate 19200...

Страница 22: ...is meant to show visually the operating or fault status of the Modbus interface and the device as well The LED operation is explained in the following table In case of error to know in detail which al...

Страница 23: ...e see Figure 2 Refer to the Mechanical installation section on page 15 Double flash 200 ms ON OFF twice 1 s OFF Several errors are active at the same time To know in detail which alarm has been trigge...

Страница 24: ...st turn the power off and on again to reset the device and restart the operation For any information please refer to the 5 4 Update FW page Firmware upgrade section on page 39 ON Solid GREEN The firmw...

Страница 25: ...function item bit 0 in the Operating parameters 0003 hex register 1 see on page 64 and then set the resolution you need for your application next to the Resolution 0000 hex item register 1 see on pag...

Страница 26: ...in the personal computer when the port is available is the RS 232 type Therefore you must install an RS 232 to RS 485 converter easily available in the market Should the personal computer not be equip...

Страница 27: ...connection is established for reading and writing the parameters are available 3 In the group box on the right information about the device will be displayed as soon as the connection is established 4...

Страница 28: ...TIONS group box the MESSAGES button is available By pressing the button the main page widens and an additional section appears on the right The communication frames transmitted from the software tool...

Страница 29: ...clear that this searching operation may take a while To start searching and connect to the device press the CONNECT button in the DEVICE group box While the program is attempting to connect to the de...

Страница 30: ...device are shown in the INPUT REGISTERS and HOLDING REGISTERS group boxes Furthermore the Read params and Write Holding buttons appear in the DEVICE group box Read params When you press the Read param...

Страница 31: ...s are available UPDATE FW and MANUAL FRAME The first button allows the operator to enter the page for the firmware upgrade the second button allows to enter the page where PDUs can be transmitted manu...

Страница 32: ...out cease To stop the continuous reading press the Continuous reading button once again To send a single command to read the registers instantaneous reading press the Read params button in the DEVICE...

Страница 33: ...t 0003 hex register refer to page 71 If a wrong parameter has been set it is stated on the right while the position value above disappears Status word and Alarm register registers activate too The inp...

Страница 34: ...ters are fully described in the 7 1 1 Machine data parameters Holding registers section on page 59 in this manual WARNING If the Auto save check box at the bottom of the page is selected see on page 3...

Страница 35: ...reset operation you must then press the Execute preset button next to the Control word item at the bottom of the page it executes the whole sequence of preset commands activation of the Perform counti...

Страница 36: ...tting Select deselect the check box to switch between the options the decimal value which results from the binary sequence of the sixteen bits in the Operating parameters 0003 hex register will appear...

Страница 37: ...ge 67 Upload defaults This button allows to activate the function meant to upload the default parameters It executes the whole sequence of default parameters upload commands activation of the Load def...

Страница 38: ...commands are being executing the background of the button is coloured orange and the decimal value which results from the binary sequence of the sixteen bits in the Control Word 000A hex register is u...

Страница 39: ...ing to the instructions provided in this section Before installation always ascertain that the firmware program is compatible with the hardware and software of the device Furthermore never turn the po...

Страница 40: ...the page 71 NOTE If you are not confident that you can perform the update successfully please contact Lika Electronic Technical Assistance After Sale Service 5 4 2 Preliminary operations and connecti...

Страница 41: ...firmware program is compatible with the hardware and software of the device Never turn the power off during flash upgrade 4 Press the DOWNLOAD button to start the firmware upgrading process the LED fi...

Страница 42: ...nder the Transmit pattern item you can use the TAB key in the keyboard to move through the fields under Transmit pattern 2 enter the Cyclical Redundancy Check CRC value in the last two fields on the r...

Страница 43: ...a non existent output or register the exception response messages that the Server transmits to the Client will be displayed next to the Exception error field at the bottom of the page For more inform...

Страница 44: ...the Master node The Slave nodes will never communicate with each other The Master node initiates only one Modbus transaction at the same time The Master node issues a Modbus request to the Slave nodes...

Страница 45: ...ts own address in the response ADDRESS FIELD to let the Master know which Slave is responding FUNCTION CODE the function code indicates to the Server what kind of action to perform The function code c...

Страница 46: ...and usually contains information such as variable references variable counts data offsets sub function etc n bytes The Modbus Exception Response PDU is defined as exception function_code exception_co...

Страница 47: ...l be the first of a new message i e an address When baud rate 9 600 bit s the silent interval is 4 ms When baud rate 19 200 bit s the silent interval is 2 ms When baud rate 115 200 bit s the silent in...

Страница 48: ...nd cannot send a second request at the same time When the link is in Idle state each transmitted character detected on the link is identified as the start of the frame The link goes to Active state Th...

Страница 49: ...de will be unique Reserved function codes are not available for public use 6 4 1 Implemented function codes Lika SMAX Modbus series linear encoders only implement public function codes they are descri...

Страница 50: ...request to read the Preset value 0001 hex parameter register 2 Request Response Field name Hex Field name Hex Function 03 Function 03 Starting address Hi 00 Byte count 02 Starting address Lo 01 Regist...

Страница 51: ...register 2 05 DC hex 1500 dec BA 8D CRC 04 Read Input Register FC 04 04 hex This function code is used to READ from 1 to 125 contiguous input registers in a remote device in other words it allows to r...

Страница 52: ...Current position 0001 hex parameter input register 2 Request Response Field name Hex Field name Hex Function 04 Function 04 Starting address Hi 00 Byte count 02 Starting address Lo 01 Register 2 valu...

Страница 53: ...2 number of bytes 2 bytes for each register 13 C5 value of register 2 Current position 0001 hex 13 C5 hex 5061 dec 74 53 CRC 06 Write Single Register FC 06 06 hex This function code is used to WRITE a...

Страница 54: ...meters 0003 hex item register 4 we need to set the scaling function Scaling function 1 and the increasing counting when the sensor moves in the direction shown by the arrow in Figure 1 Code sequence 0...

Страница 55: ...ponse following the request to write in the Operating parameters 0003 hex item register 4 from the Slave having the node address 1 is as follows Response PDU in hexadecimal format 01 06 00 03 00 01 B8...

Страница 56: ...sters Response PDU Function code 1 byte 10 hex Starting address 2 bytes 0000 hex to FFFF hex Quantity of registers 2 bytes 1 to 123 007B hex Exception Response PDU Error code 1 byte 90 hex 10 hex 80 h...

Страница 57: ...te 9 600 bit s parity bit Even The full frame needed for the request to write the value 10 dec next to the Node address 0004 hex parameter register 5 and the value 1 dec next to the Serial com baud ra...

Страница 58: ...f failures in the communication network For this purpose the Watchdog function is implemented and can be activated as optional Watchdog function is a safety timer that uses a time out to detect loop o...

Страница 59: ...r to the 6 4 1 Implemented function codes section on page 49 Resolution 0000 hex Register 1 Unsigned16 rw This parameter is used to set a custom resolution measuring step This register can be programm...

Страница 60: ...counting preset in Control Word 000A hex 1 EXAMPLE The main and default features of the SMAX linear encoder are as follows Default resolution 0 1 mm MTAX 680 max measuring length 600 mm Max number of...

Страница 61: ...ount is decreasing count down information see Code sequence in the Operating parameters 0003 hex register and you cross the zero the value immediately after 0 will be 2N 1 where N is the overall infor...

Страница 62: ...x 0 When you set the Preset value 0001 hex and then execute the Perform counting preset command in the Control Word 000A hex system saves the current encoder position in the Offset value 0002 hex regi...

Страница 63: ...gister 3 Unsigned16 ro As soon as you send the Perform counting preset command see bit 11 in Control Word 000A hex the current position of the encoder is saved in this register The offset value is the...

Страница 64: ...of the Status word 0006 hex see on page 72 Code sequence bit 1 This is intended to set if the count is increasing count up information either when the sensor moves in the direction indicated by the a...

Страница 65: ...247 The address 0 is reserved to identify a broadcast exchange Master sends a request to all Slaves connected to the Modbus network See the 6 1 Modbus Master Slaves protocol principle section on page...

Страница 66: ...ble bit 8 Setting the Watchdog enable bit to 1 causes the Watchdog function to be enabled setting the Watchdog enable bit to 0 causes the Watchdog function to be disabled When the Watchdog function is...

Страница 67: ...11 It allows to perform a homing operation of the encoder As soon as the command is sent the position value which will be transmitted for the current position of the encoder is the one set next to the...

Страница 68: ...SMAX MODBUS NOTE Save the set values using Save parameters function Should the power be turned off all data not saved will be lost MAN SMAX MB E 1 2 Programming parameters 68 of 84...

Страница 69: ...SB LSB bit 15 8 7 0 msb lsb msb lsb The available alarm error codes are listed hereafter Byte 0 Machine data not valid bit 0 One or more parameters are not valid set proper values to restore normal wo...

Страница 70: ...ds an alarm to be triggered bits 12 15 Not used NOTE Please note that should the alarm be caused by wrong parameter values see Machine data not valid and Wrong parameters list 0003 hex register normal...

Страница 71: ...4 Operating parameters 0003 hex 5 Node address 0004 hex 6 Serial com baud rate 0005 hex 7 15 Not used SW Version 0004 hex Register 5 Unsigned16 ro This is meant to show the software version of the enc...

Страница 72: ...ight bits of Byte 0 LSB shows the currently set values of the Operating parameters 0003 hex register Byte 0 LSB while bit 8 of MSB is used to signal active alarms Byte structure of the Status word 000...

Страница 73: ...dard direction i e in the opposite direction to the one shown by the arrow in Figure 1 For any further information on setting and using the counting direction function refer to the Code sequence param...

Страница 74: ...response informing the Client about the nature of the error The exception response message has two fields that differentiate it from a normal response FUNCTION CODE FIELD in a normal response the Ser...

Страница 75: ...submitted with a starting register address of 96 and a quantity of registers of 4 then this request will successfully operate address wise at least on registers 96 97 98 99 If a request is submitted w...

Страница 76: ...failed to pass a consistency check The server attempted to read record file but detected a parity error in the memory The client can retry the request but service may be required on the server device...

Страница 77: ...address 03 03 Read Holding Registers function code 00 01 starting address Preset value 0001 hex parameter register 2 00 01 number of requested registers D5 CA CRC Response PDU in hexadecimal notation...

Страница 78: ...tarting address Current position 0001 hex parameter register 2 00 01 number of requested registers 60 0A CRC Response PDU in hexadecimal notation 01 04 02 13 C5 74 53 where 01 Slave address 04 04 Read...

Страница 79: ...ue is 0 Request PDU in hexadecimal notation 01 06 00 03 00 01 B8 0A where 01 Slave address 06 06 Write Single Register function code 00 03 address of the register Operating parameters 0003 hex item re...

Страница 80: ...of bytes 2 bytes for each register 00 0A value to be set in the register 5 00 0A hex 10 dec 00 01 value to be set in the register 6 00 01 hex 1 dec 13 9E CRC Response PDU in hexadecimal notation 0A 1...

Страница 81: ...rameters in Control Word 000A hex Perform counting preset in Control Word 000A hex 9 2 List of the Input Registers Registers list and address Description of the bits Alarms register 0000 hex 0 Machine...

Страница 82: ...This page intentionally left blank...

Страница 83: ...This page intentionally left blank...

Страница 84: ...l value characters updating general review mounting tolerances correction 1 0 1 0 1 2 13 02 2019 General review Mechanical installation section updated description of the new programming interface 1 0...

Отзывы: