09-12-2017 06:21 PM
Hello
I have a Modbus RTU slave set up so that I can read a pair of sensors via discrete inputs. I want to know when either goes high and use that output to trigger other modbus events in labview. They are linked so sensor 2 turns sensor 1 off etc, as illustrated below.
My problem is how to access the poll output and use it to trigger the next events as it seems to be in an array. The code Iam using is pictured below just to give people an idea of what I am writing about. Thanks
Solved! Go to Solution.
09-12-2017 08:18 PM
Lets see if I have understood you correctly - you want to read the inputs (your two sensors). You already have the Modbus function to perform the read and it returns an array based on a starting address and quantity. Presumably you knowing the starting address and that the two inputs are contiguous; therefore you need to read quantity=2. This gives you an array of booleans (Inputs), which you need to "Index" (hint hint) in order to access each element individually. Check the Array palette and see if that "Index" hint helps.
09-13-2017 10:04 AM
Done that, thanks.
I now have problems with modbus timing in the scheme below. When the coil is written starting the motor, the PLC stops it via sensor 1 or 2 after an indeterminate time perhaps a 2-3 minutes. This could happen during or after the descrete input read and cause errors. To get round this I have tried to introduce a delay but still get an error at the read node. I wonder if there is something about the modbus session that prevents this working. I have tried putting seperate sessions in a flat sequence structure but this doesnot work either. Any ideas much appreciated.
09-13-2017 01:33 PM
@EdHarris wrote:
but still get an error at the read node. I wonder if there is something about the modbus session that prevents this working.
What error do you get? Give us an error number or description.
Use the block diagram cleanup button to clean up your code, you've got a few control terminals there where the wire is coming out of the wrong side of the terminal.
09-13-2017 04:32 PM
On start up the plc works and the sensors work but the other code fails, I get the following error;
Error -1073807339 occurred at VISA Read in MB Master.lvlib:MB_ADU_RTU.lvclass:RX ADU.vi:4960001->MB Master.lvlib:MB_Master_Serial.lvclass:Querry.vi:3550001->MB Master.lvlib:Read Discrete Inputs.vi:3900001->PM basic read discrete inputs.vi.
Possible reason(s):VISA: (Hex 0xBFFF0015) Timeout expired before operation completed.
if try again get;
Error 403481 occurred at MB Master.lvlib:MB_ADU_RTU.lvclass:RX ADU.vi:4960001
Possible reason(s): Modbus slave ID mismatch.
or 403482 CRC/LRC error.
Both parts of the code work alone.
09-14-2017 07:15 AM
Regarding the errors, they disappeared when I powered off the other slave, there may be a problem with the plc firmware. I think it would be simpler to monitor the motor coil for stop condition - so will work on that.
Thanks for your help.