- First, make sure you have the Industrial Communication Toolbox installed in MATLAB.
- 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:
Industrial communication toolbox (R2022a): function code for Modbus multiple holding registers write
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chuan-Shen Chen
el 29 de Abr. de 2022
Editada: Sivapriya Srinivasan
el 9 de Oct. de 2023
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 ?
0 comentarios
Respuesta aceptada
Sivapriya Srinivasan
el 6 de Oct. de 2023
Editada: Sivapriya Srinivasan
el 9 de Oct. de 2023
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:
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Mobile en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!