Itsme
In a video tutorial i saw that the frequence, the ladder is execute at, is determined by a option. Does this option define how often the inputs are read, too? Lets say the ladder should be executed every 20 ms. Are the inputs read every 20 ms too or are they read at a different rate? Maybe as fast as possible?

I'm asking since there may be inputs read via modbus. These inputs will have a way higher latency than local inputs. How do inputs of this kind fit into the whole working cycle? When looking at modbus tcp the latency depends heavily on the network traffic. This will disturbe determinism even further.

Is there any documentation about this subject? Are there any best practices when mixing local and external inputs?

Thanks for hints in advance.
Reply 0 0
thiagoralves
Modbus is not deterministic, that’s why it is read in best effort by a separate thread. You can define the periodicity of the slave devices thread on settings under slave devices poll rate.

As for local inputs, they are read once (and only once) at the start of every scan cycle. The scan cycle does not run before all local inputs are read.
Reply 0 0
Itsme
Thanks for the information about Modbus.

Just to be certain that I understand the roundtrip of the runtime: 
A scan cycle is started periodically at the frequence set in the options. A scan cycle contains the reading of the local inputs and the execution of the logic. Inputs connected over Modbus are handled asynchronous. So the logic works on the last complete reading of such an input. Correct so far?

Since external inputs depend on a working connection - serial or network - there is a chance an input can't be read. Is there signalisation about the status of an external input / output?
Reply 0 0
thiagoralves
Itsme wrote:
Thanks for the information about Modbus.
Just to be certain that I understand the roundtrip of the runtime: 
A scan cycle is started periodically at the frequence set in the options. A scan cycle contains the reading of the local inputs and the execution of the logic. Inputs connected over Modbus are handled asynchronous. So the logic works on the last complete reading of such an input. Correct so far?

Yes. Besides that, outputs are written at the end of the cycle as well.

Itsme wrote:

Since external inputs depend on a working connection - serial or network - there is a chance an input can't be read. Is there signalisation about the status of an external input / output?

Yes. Check  https://openplc.discussion.community/post/support-for-rtc-on-special-functions-9900466?&trail=15
Reply 0 0
openplc80
Is there a debounce on the inputs ?
Reply 0 0
thiagoralves
Not specifically, but the scan time usually takes care of that. The lowest value you can safely get is 1ms, so there is your debounce. =)
Reply 0 0
Itsme
Hi, i read the thread your link points to.

The point i got from it, is that there is a signal for errors on all external ios, but not for a single one. The idea was to change the runtime it self. I would like to avoid this. 

So is there a chance that the runtime will be changed this way?
Reply 0 0
thiagoralves
I don't think this particularly will be changed in the foreseeable future. But of course, patches are always welcome.
Reply 0 0
Itsme
Hi,
 
i did take a look at the code concerning the modbus errors.
 
Here my picture as far as i read the code:
 
- All modbus variables are handled by devices.
- The variables assigned to an device are read / written by an own task.
- The task uses bulk commands to read / write the registers of the modbus server.
- The task takes care of communication errors and sets the error flag for the device accordingly.
 
The conclusion is:
Since the modbus vars are read/written with bulk commands, there is no chance to generate a sperate errorflag for each modbus var. Due to the bulk commands the task is just not able to determin, if the value stored in the var is correct. This has to be handled by a separate logic in the device connected by modbus itself.
 
Now the isue is, that using a modbus var with an outdated value or outputs not written might have bad consequences for the application. To separate the management of devices and adressing from the logic itself, it is necessary to be able to get the error flag set in the device by just using the var defined in a programm. 
 
I'm aware that this is a double-edged sword, since it should be from any interest where the value workded with comes from in a pure plc. So the question is, if there already is a way to solve this?
 
One solution, i could imagine, is to create a modbus var on the connected device that contains the actual timestamp and assing it to a var on the plc. This var then could be used to determin if the stored values are valid anymore. I'm not sure if this would be the best practice, since the allocation of inputs / outputs has to be taken in account by the program itself.
 
Any hints / thoughts about the ideas would be appreciated. Thanks in advance...
 
Best regards
Gregor
Reply 0 0
thiagoralves
Hi Gregor,
 
If you simply monitor %ML1026 you will know that an error occurred, which means you can't trust the slave devices variables for that scan period. If the count continues increasing at every scan period then there is definitely a device at fault.
 
Currently there is no way to know specifically which device faulted. 
Reply 0 0
Itsme
Hi,
 
i only looked at the code for sending requests to the device. Therefore i did not get to the point where the errors for the different devices are mapped to %ML1026.
 
So if someone needs information about the device causing the problem, some extra vars generated by the device are helpful. For example a timestamp holding the DT of the last scancycle would help, due to the fact that it would remain the same over time if the communication to the device does not work.  At least the reading request can be verfied this way. If the output is written could only be verified if the corresponding register are read too and the state is compared to the state requested by the plc.
 
Ok, adding a block to the editors library would do the job too.
 
Would adding timestamps, like suggested, help?
 
Best regards
Gregor
 
Reply 0 0
Reply