Libary to controll a Nanotec Controller via Modbus RTU

Hi Community,

I’m looking for a library to talk to a Nanotec motor controller via Modbus RTU. Is there anybody how has done a project like this or do I have to start from scratch?

In detail I’d like to use the motor controller in torque mode. This is not possible with basic BR Hardware so far.

Thank s for your response.

Marc

The DRV_mbus library can be used to control devices over Modbus RTU.
That library itself also includes a sample for how to use it.

1 Like

Hi Andrew,
thx for your response. Do you know if the library is creating the CRC by itself?
Marc

Hi Marc,

as I know a 2 byte CRC is defined in the Modbus RTU protocol specification (while Modbus TCP does not have such a CRC, because ethernet specification already includes a 4 byte CRC).

So I assume DRV_mbus also implemented the CRC since it’s part of the protocol itself.

Best regards!

2 Likes

Hi Community,
I’d like to share my knowledge with you about the communication between a BR PLC and a Nanotec controller via Modbus RTU today .
In use is the DRV_mbus library and the sample given with AS 4.12.
I use MBMOpen(), MBMCmd(), MBMClose() as function blocks.

OPEN
Master.MBMOpen_0.enable := TRUE;
Master.MBMOpen_0.pDevice := ADR(‘SL1.IF1.ST2.IF1.ST9.IF1’); (* Device description string )
Master.MBMOpen_0.pMode := ADR(‘/PHY=RS485 /PA=E /DB=8 /SB=1 /BD=19200’); (
Mode description string )
Master.MBMOpen_0.pConfig := ADR(‘datamod’); (
Data object name )
Master.MBMOpen_0.timeout := 2000; (
Timeout in milliseconds (the value must be a multiple of 10 and >250ms) )
Master.MBMOpen_0.ascii := 0; (
0 = RTU / 1 = ASCII *)
Master.MBMOpen_0();

COMMUNICATE READ FROM CONTROLLER
Master.MBMCmd_0.enable := TRUE;
Master.MBMCmd_0.ident := Master.MBMOpen_0.ident;
Master.MBMCmd_0.node := 5; (* default Adress for Nanotec controller )
Master.MBMCmd_0.data := ADR(VAR_to_store_read_data);
Master.MBMCmd_0.mfc := 3; (
Modbus function call read )
Master.MBMCmd_0.offset := 6000 ; (
Nanotec status word 0x6041 mapped th Modbus regsiter 6000*)
Master.MBMCmd_0.len := 1;
Master.MBMCmd_0();

COMMUNICATE WRITE TO CONTROLLER
Master.MBMCmd_0.enable := TRUE;
Master.MBMCmd_0.ident := Master.MBMOpen_0.ident;
Master.MBMCmd_0.node := 5; (* default Adress for Nanotec controller )
Master.MBMCmd_0.data := ADR(VAR_where_send_data_is_stored);
Master.MBMCmd_0.mfc := 16; (
Modbus function call read )
Master.MBMCmd_0.offset := 5000 ; (
Nanotec control word 0x6040 mapped to Modbus register 5000*)
Master.MBMCmd_0.len := 1;
Master.MBMCmd_0();

The B&R Modbus RTU library does not support the direct object access called the encapsulated mode [function code 43 (0x2B)]. This is the reason why Nanotec Objects had to be mapped to a specific Modbus address. The mapping can be done with the Plug & Drive studio from Nanotec.

3 Likes