Dani
Dani

Reputation: 21

Minimalmodbus function code 0x46 and sub function 06

I am communicating with an irradiation sensor using minimalmodbus in Python 3.x. I can stablish a communication and read the registers of the sensor. The Baudrate of the sensor is 9600 but I want to change it to 38400.

The datasheet of the sensor says that it can be done by using the function code 0x46 and the subfunction 06.

datasheet

I've found that minimalmodbus only uses function codes 1,2,3,4,5,6,15 and 16, and I haven't found any possibility to use sub function.

Is there any option for me to change the baudrate or should I change minimalmodbus for another library as pyModbus?

Upvotes: 0

Views: 805

Answers (1)

Marker
Marker

Reputation: 977

Looking at the Minimalmodbus documentation, you can "extend" it to handle more function codes by using the _performCommand() function. The documentation says that it will take care of the CRC generation.

Link: https://minimalmodbus.readthedocs.io/en/master/develop.html#extending-minimalmodbus

I did a quick search and it looks like you are using a Tamb485 sensor. Based on that documentation, To set the BAUD rate to 38400 and the parity/stop bits (both are set at the same time) to 8E1 on a device you would do:

_performCommand(0x46, '0x05,0x04,0x02')

0x46 - function code

0x05 - sub function code
0x04 - baud rate 38400
0x02 - parity/stop bits 8E1

Upvotes: 0

Related Questions