필터 지우기
필터 지우기

Industrial communication toolbox (R2022a): function code for Modbus multiple holding registers write

조회 수: 8 (최근 30일)
I wish to write an uint16 integer value to Fanuc CNC controller using the ModBus write function of the industrial communcation toolbox.
The FANUC controller only accepts 'multiple holding register write' (modbus function code 16).
If I run
m = modbus('tcpip', '192.168.1.10');
write(m,'holdingregs', 2, 100, 'uint16'); % other 'precision' formats, uint64, not work neither.
a communication error will occur.
Using other modbus program to issue the 'multiple register write' command work just fine.
How to force the matlab modbus write function to generate a function-code-16 write ?

채택된 답변

Sivapriya Srinivasan
Sivapriya Srinivasan 2023년 10월 6일
편집: Sivapriya Srinivasan 2023년 10월 9일
Hello,
I understand that you want to force the MATLAB Modbus write function to generate a function-code-16 write, you can use the following steps:
  1. First, make sure you have the Industrial Communication Toolbox installed in MATLAB.
  2. Create a Modbus object by specifying the communication type and the IP address of the FANUC controller. In this case, you are using TCP/IP, so the code would be:
m = modbus('tcpip', '192.168.1.10');
Set the 'FunctionCode' property of the Modbus object to 16, which corresponds to the "multiple holding register write" function code:
m.FunctionCode = 16;
Use the write function to send the data to the FANUC controller. Specify the register address, the value to be written, and the data type ('uint16' in this case):
write(m, 'holdingregs', 2, 100, 'uint16');
By setting the 'FunctionCode' property to 16 before calling the write function, you can force the MATLAB Modbus toolbox to generate a function-code-16 write command.
Make sure to check the documentation of the Industrial Communication Toolbox and the specific requirements of the FANUC controller to ensure proper configuration and communication.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Mobile에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by