»Ê³þµÛ123
¼‰(j¨ª)„e: *
¾«ÈAÖ÷î}: * ƪ
°l(f¨¡)Ìû”µ(sh¨´)Á¿: * ‚€(g¨¨)
¹¤¿ØÍþÍû: * üc(di¨£n)
ÏÂÝd·e·Ö: * ·Ö
ÔÚ¾€•r(sh¨ª)ég: (С•r(sh¨ª))
×¢ƒÔ•r(sh¨ª)ég: *
×îºóµÇä›: *
²é¿´»Ê³þµÛ123µÄ Ö÷î} / »ØÙN
˜ÇÖ÷  °l(f¨¡)±íÓÚ: 2016-12-13 21:53
ß@ÊÇÕÒµ½µÄºêÖ¸ÁîÄ£°å
// Read Holding Registers
macro_command main()
char command[32], response[32]
short address, checksum
short read_no, return_value, read_data[2], i
FILL(command[0], 0, 32)// initialize command[0]~command[31] to 0
FILL(response[0], 0, 32)
command[0] = 0x1// station number
command[1] = 0x3// read holding registers (function code is 0x3)
address = 0// starting address (4x_1) is 0
HIBYTE(address, command[2])
LOBYTE(address, command[3])
read_no = 2// the total words of reading is 2 words
HIBYTE(read_no, command[4])
LOBYTE(read_no, command[5])
CRC(command[0], checksum, 6)// calculate 16-bit CRC
LOBYTE(checksum, command[6])
HIBYTE(checksum, command[7])
OUTPORT(command[0], "MODBUS RTU Device",8)// send request
INPORT(response[0], "MODBUS RTU Device",9,return_value)// read response
if (return_value > 0 and response[1] == 0x4) then
read_data[0] = response[4] + (response[3] << 8)// 4x_1
read_data[1] = response[6] + (response[5] << 8)// 4x_2
SetData(read_data[0], "Local HMI", LW, 0, 2)
end if
end macro_command

ͨß^485ßBëŠÄX£¬Óô®¿ÚÖúÊÖ×xµ½µÄ”µ(sh¨´)“þ(j¨´)…sÊÇ
7F DF EB FF FB 5D 6D 00  

²»ÖªµÀÊÇʲôԭÒò£¿
„‚½ÓÓ|ß@‚€(g¨¨)–|Î÷£¬Íû´óÉñÖ¸½Ì£¡
tyw123456
¼‰(j¨ª)„e: ¼Òˆ@³£¿Í

¾«ÈAÖ÷î}: 1 ƪ
°l(f¨¡)Ìû”µ(sh¨´)Á¿: 113 ‚€(g¨¨)
¹¤¿ØÍþÍû: 797 üc(di¨£n)
ÏÂÝd·e·Ö: 313 ·Ö
ÔÚ¾€•r(sh¨ª)ég: 256(С•r(sh¨ª))
×¢ƒÔ•r(sh¨ª)ég: 2016-09-13
×îºóµÇä›: 2022-07-13
²é¿´tyw123456µÄ Ö÷î} / »ØÙN
1˜Ç  °l(f¨¡)±íÓÚ: 2016-12-14 08:25
Äã485µÄA B¾€ÊDz»ÊÇ·´ÁË
±¾Ìû×î½üÔu(p¨ªng)·Öӛ䛣º
  • ÏÂÝd·e·Ö:+1(snails) Ò»ÕZµÀÆÆÌì™C(j¨©)£¬…–º¦£¡
  • ìoË®ÉîÁ÷