Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Skipped scans when RS-232 devices are disconnected


mwassmer Sep 28, 2014 08:00 AM

I have a CR1000 system with several different types of sensors, including some Modbus/RS-485 AC power/energy meters that are connected to the CR1000 through a RS-485/RS-232 adapter.

When the meters and adapter are connected and running, I don't have any skipped scans. However, when I disconnect the adapter from the RS-232 port, I get lots of skipped scans. I can't figure out why this is happening. Perhaps it is because the system is stuck in some kind of retry cycle when it can't connect to the RS-232 device?

This is an important issue to resolve because I don't want all my other measurements to be affected when the AC power/energy meters are disconnected or not functioning.


JDavis Sep 29, 2014 05:21 PM

Most likely you are using SerialOut and/or SerialIn which both have a timeout parameter. Without any data coming in, you will hit the maximum timeout on each of those instructions as set in your program. You can move that part of the program to a slow sequence to keep it from interfering with the timing of your other measurements, or modify the program to use SerialInRecord or SerialInBlk which don't wait for data.


JDavis Sep 29, 2014 06:33 PM

On my previous response, I missed that you are using the Modbus instructions. ModbusMaster has an adjustable timeout parameter. Without a sensor connected to respond, you will be delaying your program at that point for the maximum timeout duration you have set. You can move ModbusMaster into a SlowSequence scan to not have it delay the rest of your program.


mwassmer Sep 30, 2014 04:16 PM

Reducing ModBusMaster's TimeOut parameter did the trick! Thanks so much, Jared.

A few follow-up questions:

I have 50 consecutive ModBusMaster instructions that I'm running in my program. I assume that the ModBusMaster automatically opens the port specified in the ComPort parameter. Is this assumption correct Does this mean that the port is being opened and closed 50 times? If so, do you recommend using a SerialOpen instruction before the first ModBusMaster instruction to keep the port open? Do you recommend using a SerialClose instruction after the final ModBusMaster instruction, or am I better off omitting it so that the port stays open continuously? I guess I'm basically asking what the best practice is for handling a large number of consecutive ModBusMaster instructions.

Finally, what is the difference between using a SerialOpen instruction and enabling the "Port always on" option in Device Configuration Utility?


JDavis Sep 30, 2014 04:55 PM

If the serial port parameters are the same on all of the ModbusMaster instructions, the datalogger will leave the serial port open with the configuration specified. SerialOpen and SerialClose are unnecessary in your case.

'Port Always On' forces the RS232 port to stay powered up. Without it, the serial port goes into a low power state after about 30 seconds. In a low power state, a datalogger could miss the first incoming character on the RS232 port. Allowing the port to go to sleep does not negatively affect operation as a master device, only operation as a slave device.


mwassmer Nov 17, 2014 04:03 PM

My datalogger scan rate is 20s and it is important that all my timestamps be multiples of 20s. Can you confirm that if I put my ModbusMaster instructions in a SlowSequence, the timestamps will no longer be multiples of 20s? If this is the case, I can't use SlowSequence. Instead, I will try to minimize the timeout parameter as much as possible so that I do not have skipped scans.

Each of my dataloggers has 6 Modbus devices connected to it and I'm issuing 3 block read commands (for a total of 18 commands per datalogger) to each Modbus device every 20 seconds. My average daisy-chained cable length is very short, i.e., between 2 meters and 20 meters. What is the minimum timeout duration that I could get away with? Am I correct to multiply that timeout duration by 18 to get the total timeout duration that would occur if I lose power to all the Modbus devices? By the way, my average "Measure Time" according to the status table is about 6s for each 20s scan.

My objective is avoid having the aggregate Modbus timeouts compromise (via skipped scans) my 20-second non-Modbus sensor readings in case of a power outage that shuts down the Modbus devices. Each of my CR1000 dataloggers is connected to a PS100 power supply, so the system has plenty of backup power to read non-Modbus sensors for an extended period of time during a power outage.


JDavis Nov 17, 2014 06:37 PM

The timeout parameter you should use doesn't depend on cable length. The response time of the devices you have connected determines the optimal timeout.

If all your measurements are completing in 6 seconds, you would probably be fine with a timeout parameter of 50(half a second per ModbusMaster). If you need to further refine the timeout, you could add a timer to your program and read from it before and after instructions to see how much time each line is taking. Another method to see the response time is to use the serial comms sniffer in the datalogger terminal.

In regards to your questions regarding multiples of the 20 second timestamp for you data tables, the interval of the table must be a multiple of the scan interval of the scan which includes CallTable. So, if you call the table from your main 20 second scan it won't conflict with a slow sequence on a 30(or whatever) second scan. You can include measurements from your slow scan in the data table, the values in the table just might be a scan behind the values from the main scan. Alternatively, you could have a separate table that is called(with CallTable) from the slow sequence, containing only measurements from the slow sequence.

Log in or register to post/reply in the forum.