MemberJuly 29, 2021 at 8:58 am
I have a question about Modbus communication. I have a sensor (OLS20-BB1118142 | Lokalisierungs- und Positionierlösungen | SICK) which is Modbus capable and a Controllino Maxi. I intend to use the Controllino as a master and have therefore already loaded the example code, from the Website, for a Modbus Master on the Controllino ( RS485 & ModbusRTU – CONTROLLINO )
Now I would like to ask if anyone is more familiar with the subject than I am, as I am unfortunately still quite new to this topic.
What I know so far is that my sensor has the baud rate 9600 and the slave address 10 (in the code, as far as I know, adapted).
I also know that the master has to send a request so that the slave can respond.
The status query in HEX, whether the sensor recognizes something or not, would be in this case:
0A 04 00 C0 00 01 30 8D
where 0A is the slave address, 04 is my function code, 00C0 is my start address, 0001 is my register count and 308D is my checksum.
If the sensor detects something (OK), it gives the answer: 0A 04 02 00 02 9D 30 and with NOK it would be 0A 04 02 00 00 10 F1.
Does anyone know how I have to change the above code to establish communication?
I have also tried to enter everything here, but unfortunately, nothing changes.
// ModbusQuery 0: read registers
ModbusQuery.u8id = SlaveModbusAdd; // slave address
ModbusQuery.u8fct = 3; // function code (this one is registers read)
ModbusQuery.u16RegAdd = 0; // start address in slave
ModbusQuery.u16CoilsNo = 4; // number of elements (coils or registers) to read
ModbusQuery.au16reg = ModbusSlaveRegisters; // pointer to a memory array in the CONTROLLINO
or do I need a simple if-else command? I would be very grateful if someone could help me with this 😀
Thanks a lot and greetings
MemberJuly 29, 2021 at 2:29 pm
MemberJuly 29, 2021 at 3:50 pm
thank you very much for your response. I would like to ask where you got those numbers from. I’ve connected my Sensor with my Computer and Software and I’ve got the start address 192.
MemberJuly 30, 2021 at 7:54 am
I’ve also tried the simple_master Code from GitHub – smarmengol/Modbus-Master-Slave-for-Arduino: Modbus Master-Slave library for Arduino but the response I get is are weird signs and question marks. I’ve changed the address etc. in the Code to the numbers I have (in DEC) but it won’t work and I don’t know what the problem is.
MemberJuly 30, 2021 at 2:16 pm
You say weird signs and question marks? Then you have something wrong with the RS845 – baudrate, or swapped +/-.
MemberAugust 2, 2021 at 6:22 am
I’ve chosen the right Baudrate for my serial monitor and swapped the wires but I still get those blank boxes and question marks. I really don’t know what the problem is
MemberJuly 30, 2021 at 2:14 pm
You have stated “0A 04 00 C0 00 01 30 8D where 0A is the slave address, 04 is my function code, 00C0 is my start address, 0001 is my register count and 308D is my checksum.“
C0 = 12.
MemberAugust 2, 2021 at 6:23 am
yes but don’t I have to get it from HEX to DEC? Because then I get C0 = 192.
MemberAugust 16, 2021 at 7:30 am
it’s working now. I had to change the parity. 🙂
MemberAugust 17, 2021 at 9:11 am
Great! Good job!
Log in to reply.