儀器modbus RTU通訊問題

看板Python作者 (草草)時間1年前 (2022/10/21 21:49), 1年前編輯推噓4(404)
留言8則, 4人參與, 1年前最新討論串1/1
各位大大、前輩好 我想要使用python來與儀器進行通訊,設備商有提供modbus RTU指令集, 內容包含modbus RTU通訊設定,以及通訊地址,如下 https://imgur.com/rJcfijX
https://imgur.com/pR0FF4o
https://imgur.com/9kRTjdg
我使用三種方式進行通訊,但不知道為什麼都無法將值讀取出來 方式1:使用pymodbus 結果1:地址輸入40051或40062或其它值,拋出AttributeError例外 https://imgur.com/1oxM1YD
結果2:地址輸入40051或40062或其它值,出現Modbus Error訊息 https://imgur.com/DlXnY8m
方式2:使用modbus_tk 結果:地址輸入40053或40062或其它值,出現Response length invalid 0 訊息 https://imgur.com/Sf4KgLR
https://imgur.com/Sf4KgLR
https://imgur.com/Sf4KgLR
https://imgur.com/Sf4KgLR
https://imgur.com/Ag851s9
https://imgur.com/pbTOQVQ
方式3:使用minimalmodbus 結果: 地址輸入40053或40060或其它值,拋出ValueError例外 https://imgur.com/lIDf1tH
https://imgur.com/Dz1Bblk
不知道我哪裡寫錯或設定錯誤,研究好久了..懇求前輩幫忙, 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.73.221.228 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1666360191.A.DD4.html

10/21 23:13, 1年前 , 1F
連怎麼錯誤都還沒弄清楚,就換其他package...
10/21 23:13, 1F

10/22 10:55, 1年前 , 2F
我家lab儀器都是gpib接頭. 然後用pyvisa控制。
10/22 10:55, 2F
請問貴家的儀器是?

10/22 16:20, 1年前 , 3F
minimalbus有一個能試試看,你填的40060變成了0x40060
10/22 16:20, 3F

10/22 16:21, 1年前 , 4F
也就是錯誤裡寫的262240
10/22 16:21, 4F

10/22 16:21, 1年前 , 5F
也就是錯誤裡寫的262240
10/22 16:21, 5F
了解,40060是16進制,轉成10進制就是262240了, 所以我地址要輸入9C7C(16進制),輸出才會是40060(10進制)嗎? ※ 編輯: popo14777 (118.161.145.189 臺灣), 10/22/2022 22:26:48 我剛看了API,read_register()方法第一個參數輸入10進位的值, 第二個參數輸入小數位數,第三個參數輸入有無符號, read_register(40096, 1, 3, signed = False) 不曉得這樣正不正確? API網址https://minimalmodbus.readthedocs.io/en/stable/apiminimalmodbus.html ※ 編輯: popo14777 (118.161.145.189 臺灣), 10/23/2022 00:07:31 ※ 編輯: popo14777 (118.161.145.189 臺灣), 10/23/2022 07:43:25

10/23 10:55, 1年前 , 6F
我家儀器功能可能跟你不同。但我以為gpib是通用的…
10/23 10:55, 6F

10/23 22:08, 1年前 , 7F
前面的400不要呢? pymodbus的unit是站號
10/23 22:08, 7F

10/23 22:08, 1年前 , 8F
client.read_holding_registers(61, 1, unit=3)
10/23 22:08, 8F
文章代碼(AID): #1ZKgD_tK (Python)
文章代碼(AID): #1ZKgD_tK (Python)