The error code 12 you are referencing is about designing subroutines - this will not be your error at runtime.
Error code 12 at runtime is “Invalid table index.”
Which means the code is trying to read or write to an index which is greater than the size of the table you are using.
What does the Parameters table look like? What is the length of that table?
The parameter table is 10 which follow as the modbus tcp subroutine template
I’ve seen this before and I can’t quite remember. If you are getting 12 and not a -12 then the 12 has significant meaning. Can’t recall what it is. Like the number of the illegal register, or some other clue to what the problem is…
I saw the error code when right click and select inspect the variable ‘n04AsIntStatusChi’ and it show me error code 12.
The error code just show 12 not -12
That is not an opto error code.
Do you know how to set a breakpoint and step through the code? The only thing tricky about stepping through the modbus subs is setting a breakpoint in a way that you don’t get a ‘timeout’.
Find out where the 12 is being set.
The 12 could be the exception code returned by the slave device. I think that is where I’ve seen this before.
Ya true, the 12 should be an exception code. I do know how to use the breakpoint, can u explain further or guide me how should I tackle with this? thank you in advance
My guess is that you are asking for invalid registers for the device. I would start by just reading 1 or 2 registers, not 23. Get it so that always works. Then increase the number of registers until you get the error. Often devices have gaps in their register map and you need to separate the reads in several calls, skipping the gaps. 12 might turn out to be the index of the first invalid register.