Modbus RTU protocol parameter

Hi Tom,

The sketch get compiled now.

I have another problem

I want to set the Modbus RTU parameter. in your windsensor example the parameters are set like.

modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, , 1, 0);

modbus_configure(&Serial, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
                                                                                // Serial1 = INDUSTRUINO RS485

 

I want to set  Stopbit 2,parity  none baud rate 9600.

My sensor is giving some float value. so I must read Register 40001

So how to set this 

Please help.

 

Jagroop Singh
Jagroop Singh
17
| 2 1 2
Asked on 8/22/18, 11:37 AM
0
vote
2143 Views

Hi, if your sensor gives a float value, then you probably need to read 2 16-bit registers and combine them to a float, see https://industruino.com/blog/our-news-1/post/modbus-tips-for-industruino-26

But first you have to find those registers; if your doc says address 40001 then start looking with 

modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 2, 0);

That means: slave register index 0 for slave address 40001; 2 registers to read; store in master index 0 (and 1, as you're reading 2 registers)

 

Tom
Tom
5675
| 1 1 3
Answered on 8/23/18, 12:57 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

46 follower(s)

Stats

Asked: 8/22/18, 11:37 AM
Seen: 2143 times
Last updated: 8/23/18, 12:57 AM