Data to Server processing serial modbus with triggered measurement shows random spikes in data

Hi

Setup
I have a sensor connected to a TRB145 with serial modbus communication. The sensor is from Ponsel which measures in this case conductivity. We are using two packages the Serial Modbus master to read and the Send data to server to send the read data.

What is special about the modbus commands of this sensor is that in order for the sensor to take a measurement it is necessary to send a trigger signal to it and wait for a few seconds. We have set up two modbus slave device configs with offset periods.

Problem
For the most part, this setup works fine, but occasionally the values returned from the sensor have massive spikes (3000-5000). I suspect this is due to the periods of the two overlapping as time passes.

Question
I would think the solution to this would to set up a sequential serial command, but i can’t really find a way to do that with this tool.

Anyone know if this would be possible to do or if there is another cause of this?

Hello,

I am not sure if this is the issue, but, f it happens rarely, that can be because of the frequency (period) as you have mentioned. The Trigger request is set to every 57 seconds, while the ReadValues requests are set to 60. Thus, when you send the trigger, and then 3 seconds later read those values, the ‘read values’ timer is at 60 seconds again, while ‘trigger’ is at 54 seconds already. Next time when it triggers after 54 seconds, there is 6 seconds left til ReadValues. After read values, the trigger is at 51 (57 - 6) seconds.

So both actions are executed at the same time roughly each 20 minutes. This can cause issues on the sensor when it receives a Trigger and ReadValues requests in quick succession.

Hence, could you please tell how often does this happen?

Also, I assume that if you configure the Trigger request in the same slave configuration as ReadValues, but put this request as the first request, the sensor is unable to react and provides inaccurate information when ReadValues requests are sent. Is that correct?

Kind Regards,

Yeah, the frequency is roughly each 20 minutes. It sometimes skips one peak event so it isn’t consistent.

I haven’t tried putting trigger and the reader in the same handler as I assumed it wouldn’t work, but I could give.it a try at least.

Hello,

Sure. Let me know how it goes.

Another option would be to completely remove the Modbus Trigger request from the Modbus service and, instead, create a script using crontabs to send it to the Modbus slave every minute. By doing this, the frequency will be precisely 60 seconds per minute. The script will consistently send the request at the exact one-minute mark, while the Modbus service will have a different starting time. This ensures that the requests won’t overlap.

Here’s an example of the Modbus command:

ubus call modbus_master tcp.test '{"ip":"127.0.0.1","port":502,"id":1,"timeout":1,"function":3,"first_reg":1025,"reg_count":"1","data_type":"16bit_int_hi_first","no_brackets":1}'

You can find other scripting examples on the forum. For example, the following post here can be useful.

Another thing you can do is to change the frequency so that the issue occurs less often. For example, 53 and 60 seconds. With this frequency, it should be ~53 mins before it overlaps.

Kind Regards,

Thanks for the info. It looks like the script is possibly the way to go in the long run.