background image

29 

6.12  Example of LRC calculations   

Following is an example of calculating LRC with VisualBasic6.0.   
 
Variables are declared as shown below.   
VisualBasic6.0 cannot use code-free variables. It therefore uses code-equipped 16-bit integer 
variables as data. Similarly, the LRC calculation results are entered into code-equipped 16-bit 
integer variables. 
 

Dim LRC As Integer 
Dim i, arry_count As Integer 
 
Dim lrc_arry(128) As Integer 

 
Then enter calculable data into the 1rc_arry(), and enter the number of data items into the 
arry_count. After that, run the following program to cause the calculation results to enter the LRC. 
 

For i = 0 To arry_count 
        LRC = (LRC + lrc_arry(i)) And &HFF 
Next 
 
LRC = ((Not LRC) + 1) And &HFF 

 
If the error code is calculated as 12H as an example, affix a "1" or "2" at the end of the message. 
 
 

Summary of Contents for TTM-200 Series

Page 1: ...1 TOHO ELECTRONICS INC Operation Manual Communications TOHO protocol and MODBUS Model TTM 200 Series Designation Digital Controller...

Page 2: ...eed 2 7 Setting an address 2 8 Setting a response delay 2 9 Switching communications mode 3 TOHO communications control 7 3 1 Communications procedure 3 2 Message types 3 3 Composition of a request me...

Page 3: ...s product 6 9 Composition of ASCII response messages transmitted from this product to a high level computer 6 10 Description of ASCII codes 6 11 Precautions on ASCII communications 6 12 Example of LRC...

Page 4: ...commands are performed with regarding to the RAM in this product Written data can be turned back into the values before the writing the values stored on the EEPROM by turning power off and on again T...

Page 5: ...n protocol setting 0 TOHO communication protocol Communication parameter setting Communication speed setting Communication address setting Response delay time setting Communications switchover setting...

Page 6: ...te the and keys to make the settings The initial value is 1 Setting range 1 to 99 stations It cannot be set to a 0 2 8 Setting a response delay Set a time from the time when the high level computer fi...

Page 7: ...ming See 3 6 2 Interval between requests 3 2 Message types Messages are roughly divided into the following types Read request message Write request message Store request message Request message transm...

Page 8: ...mples of communications to be written 3 3 1 Composition of a read request message Start code Address Contents of the Identifier End code BCC data request read write 3 3 2 Composition of a write reques...

Page 9: ...4 2 Examples of communications to be written 3 4 1 Response message in response to a read request message Start code Address Acknowledge code Identifier End code BCC data Numerical data 3 4 2 Response...

Page 10: ...See 10 Table of identifiers codes Numerical data In writing mode you can write 5 or 6 digits of numerical data In reading you can set this product to 5 or 6 digits of numerical data Following are the...

Page 11: ...ERR type will be incorporated in the response message from this product following NAK ERR type If a request message received from this product is error ridden the error contents either of the numbers...

Page 12: ...st message is sent to this product but the latter does not return a response message at the end of an appropriate period The moment this product receives an STX it clears all codes received before tha...

Page 13: ...V data 00777 This product Read request message transmitted from the high level computer Code Code data ASCII code note 2 Start code STX 02H Address 27 32H 37H Request contents R Read 52H Identifier no...

Page 14: ...the request message has been received This product Check that it has been written by reading the data separately Write request message transmitted from a high level computer Code Code data ASCII code...

Page 15: ...ation parameter setting Communication speed setting Communication address setting Response delay time setting MODE key MODE key MODE key MODE key MODE key 4 seconds Operation mode screen MODE key at l...

Page 16: ...n the Set a communications address screen on the preceding page operate the and keys to make the settings The initial value is 1 Setting range 1 to 99 stations It cannot be set to a 0 5 8 Setting a re...

Page 17: ...Interval between requests 2 ms or more 6 2 Message types Messages are roughly divided into the following types Read request message Write request message Store request message Request message transmit...

Page 18: ...at 2 Low level 02H f Number of byte items 04H Number of registers 2 g Data for the first register a low level word High level 00H Data composition is and H represents 1 byte Low level 00H Data for the...

Page 19: ...vel A1H Data for the first register a high level word High level 00H Low level 00H e CRC 16 Low level 09H High level A8H 6 4 2 Response message for a write store request message a Slave address 01H b...

Page 20: ...error check code is for detecting message errors This transmits a CRC 16 tour redundancy code The multinomial for generating a CRC 16 used in this product is X16 X15 X2 1 To learn how to calculate the...

Page 21: ...r number will be incorporated The table below indicates the error contents and classifications Error No Error contents in the request message received by this product 01 Received an unsupported functi...

Page 22: ...erefore the high level computer transmits the necessary request message again if a request message is sent to this product but the latter does not return a response message at the end of an appropriat...

Page 23: ...j arry_count As Integer Dim c_next c_carry As LongDim crc_arry 64 As Integer Then enter calculable data into the crc_arry and enter the number of data items into the arry_count After that run the foll...

Page 24: ...e Number of registers High level 0 0 Fixed at 2 Low level 0 2 h Number of byte items 0 4 Register 2 i First register data a low level word High level 0 0 Data composition is and H represents 1 byte L...

Page 25: ...Low level 0 0 First register data a high level word High level 0 0 Low level 0 0 f LRC 5 3 g End code CR LF 6 9 2 Response message for a write store request message a Start code b Slave address 0 1 c...

Page 26: ...to be written are specified in 2 bytes For the addresses of the commands see 10 Table of identifiers codes f LRC LRC is an error check code for detecting message errors An LRC is transmitted The LRC...

Page 27: ...rgest error number will be incorporated The table below indicates the error contents and classifications Error No Error contents in the request message received by this product 01 An unsupported funct...

Page 28: ...sage is sent to this product but the latter does not return a response message at the end of an appropriate period The moment a start is received this product clears all codes received before that 6 1...

Page 29: ...re entered into code equipped 16 bit integer variables Dim LRC As Integer Dim i arry_count As Integer Dim lrc_arry 128 As Integer Then enter calculable data into the 1rc_arry and enter the number of d...

Page 30: ...ould exercise caution when making the connections for RS 485 communications and those for loader communications simultaneously You cannot conduct loader communications while data is communicated throu...

Page 31: ...Select No not this time and click Next 4 Next a screen as follows will pop up Select Install from a list or specific location Advanced and click Next 5 Next a screen as follows will pop up Select Incl...

Page 32: ...s follows pops up click Finish 7 Next a screen as follows will pop up Select No not this time and click Next 8 Next a screen as follows will pop up Select Install from a list or specific location Adva...

Page 33: ...33 9 Next a screen as follows will pop up Select Include this location in the search Click Next 10 When a screen as follows pops up click Finish The installation is now complete...

Page 34: ...34 11 To know to which number communication port the loader cable has been allocated refer to the port on the device manager...

Page 35: ...s set to it Data length Either 7 or 8 bit is selected and this product is set to it Parity No Either odd or even is selected and this product is set to it BCC check Yes or no is selected and this prod...

Page 36: ...Either odd or even is selected and this product is set to it BCC check Yes or no is selected and this product is set to it Communications address 1 99 2 MODBUS communications RTU protocols Start bit l...

Page 37: ...n the drawing The same characteristic impedance cables are used for the connections between the slave stations Attach terminating resistor to both the master station side and the farthest ones among t...

Page 38: ...e Command Remark Identifier Absolute DEC Relative hex PV1 40001 0000 Measuring temperature RLB HHHHH Overscale LLLLL Underscale At L B 00000 Displays PV alone 00001 Displays SV alone 00002 Displays PV...

Page 39: ...point RWLB 00000 0 00001 0 0 00002 0 00 00003 0 000 00004 0 0000 Input 2 setting mode set2 toho modbus Screen character Name Command Remark Identifier Absolute DEC Relative hex IN2 40513 0200 INP2 Se...

Page 40: ...e limiter rise RWLB OD1 41071 042E od1 Set a main control change limiter decline RWLB SFM 41119 045E SFM Set a main control soft start output RWLB Pay attention to MODBUS address SFT 41121 0460 SFt Se...

Page 41: ...ntion to MODBUS address LP2 41101 044C LoP2 Set an auxiliary control loop anomaly time RWLB C2 41103 044E C2 Set an auxiliary control sensitivity RWLB CP2 41105 0450 CP2 Set an auxiliary control OFF p...

Page 42: ...41 0604 E2H Set an out2 event upper limit RWLB E2L 41543 0606 E2L Set an out2 event upper limit RWLB E2C 41545 0608 E2C Set an out2 event sensitivity RWLB E2T 41547 060A E2t Set an out2 event delay ti...

Page 43: ...42321 0910 E5F4 Set an out5 event function 4 RWLB E5P 42323 0912 E5P Set an out5 event polarity RWLB Out6 setting mode set10 toho modbus Screen character Name Command Remark Identifier Absolute DEC Re...

Page 44: ...TSV 43589 0E04 tSV1 Set a timer 1 SV allowable range RWLB ONT 43591 0E06 oNt1 Timer 1 ON delay timer RWLB OFT 43593 0E08 oFt1 Timer 1 OFF delay timer RWLB TC 43595 0E0A RUN1 Set a timer 1 repetition...

Page 45: ...e Command Remark Identifier Absolute DEC Relative hex NDS 44609 1200 NdSP PV normal display color RWLB For R or W transmit signals for the password cancel command Example Host TTM 200 01WPAS00000 01ac...

Page 46: ...ttings Example INP1 screen character PR8 44879 130E PRI08 Set a priority screen 8 RWLB Read write priority screen 8 settings Example INP1 screen character PR9 44881 1310 PRI09 Set a priority screen 9...

Page 47: ...tings Example INP1 screen character B08 45135 140E bNK08 Set bank selection 8 RWLB Read write bank selection 8 settings Example INP1 screen character B09 45137 1410 bNK09 Set bank selection 9 RWLB Rea...

Page 48: ...1C SV5 Step SV 5 setting RWLB ST5 45663 161E TIM5 Step time 5 setting RWLB SB6 45665 1620 St6bK Step 6 designation bank setting RWLB SS6 45667 1622 SV6 Step SV 6 setting RWLB ST6 45669 1624 TIM6 Step...

Page 49: ...g mode for blinding only LB 008 Out4 setting mode for blinding only LB 009 Out5 setting mode for blinding only LB 010 Out6 setting mode for blinding only LB 011 Out7 setting mode for blinding only LB...

Page 50: ...c s 04h EOT DC4 4 D T d t 05h ENQ NAK 5 E U e u 06h ACK SYM 6 F V f v 07h BEL ETB 7 G W g w 08h BS CAN 8 H X h x 09h HT EM 9 I Y i y 0Ah LF SUB J Z j z 0Bh VT ESC K k 0Ch FF FS L l 0Dh CR GS M m 0Eh...

Page 51: ...hi Shinjuku Bldg 7 18 5 Nishi Shinjuku Shinjuku ku Tokyo 160 0023 Japan TEL 81 3 3363 1331 FAX 81 3 3363 3335 Osaka Office Yachiyo Bldg East Wing 7F 2 Kita1 21 Tenjinbashi Kita ku Osaka shi Osaka 530...

Reviews: