Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
84649members
353989posts

[Imported] Reading a Digital input bit to toggle InService flag of Modbus Scanner.

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

sbeadle
Janeway Janeway
Janeway
0 Likes
0
291

[Imported] Reading a Digital input bit to toggle InService flag of Modbus Scanner.

>>Message imported from previous forum - Category:ClearSCADA Software<<
User: florian, originally posted: 2018-10-24 18:14:04 Id:189
This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.

-----------------------

**_BCRadlink:_**
**_Good day to all, I am using 2 Modbus scanner to poll for two sets of digital input register of an ADAM module. 1st Modbus scanner will poll every 2seconds to find out if the DIN bit is set to 0 or 1. If the DIN bit is 1, the 2nd Modbus scanner will be InService=1 , else when the it DIN bit is 0, the 2nd Modbus scanner will be InService = 0._**

**_At the moment , I have tried to use a VB script to run on a loop by the call function, to self "call" the sub-routine.
following is my code :_**

**_call Check_point()
Sub Check_point()
value = Server.GetOPCValue(".adam4055.DinStatus.CurrentValue")
IF value = 1 THEN
Server.SetOPCValue ".scada_project.adam4055.Din_Scanner.InService" , 1
Else
Server.SetOPCValue ".scada_project.adam4055.Din_Scanner.InService" , 0
END IF
END Sub_**

**_The issues I am encountering is that, in Run Mode, the ViewX will crash after running for awhile. I noticed when I remove the self "call" function. The ViewX will run normally without crashing. Can anyone suggest another way of performing the same function as I have described? Is there a event trigger function in ClearSCADA? Thank you all for your time, your response will be well appreciated._**

--------------------------

AWoodland:
You should do this in IEC logic, not scripting, as scripting runs on the client and only whilst the mimic is on display. Logic always runs and runs on the server so it doesn't matter if a client can connect.

You can set logic to run on input-processed, which just means that when one of the points used as an input (but not an output) updates it will trigger an execution. The program is pretty straight forward, you could use a FBD to do this graphically but something like the following will work:

PROGRAM CheckPoint
VAR
Current AT %M(.adam4055.DinStatus.CurrentValue) : DINT;
ScannerStatus AT %M(.scada_project.adam4055.Din_Scanner.InService) : BOOL;
END_VAR
IF Current = 1 THEN
ScannerStatus := TRUE;
ELSE
ScannerStatus := FALSE;
END_IF;
END_PROGRAM;

(You may need to fix the VAR block to point to the correct location depending on where you put the logic). In the properties for this program set the execution to be on input-processed. There is plenty of information in the help on logic should you need any more help.

---------------------------

Applez00800:
My reply is only vaguely relevant, but it's something to consider when using VBScripting for other purposes:

Adding to what Adam said, VBScript is also single threaded meaning that only one script may run at a time on a particular client. Therefore, calling another script while one is already running will terminate the first. If you need to use VBScripts, try to make them run for as short a time as possible to avoid them being terminated prematurely by either the user closing/navigating from the mimic, or by running another script too quickly. This has caught me out before!

-----------------------------

**_BCRadlink:
Hi AWoodland and Applez00800,
Thank you both for the helpful advise and quick response. I have managed to implement the Logic Structure program as suggested, and it is working as it should. Cheers. Have a great weekend mate._**

-----------------

Andrew:
I know it is not recommended but how would I script to disable a point. I have some 500 points that I want to take out of service and a simple script seems to be the best way.

sub Alarm
set rs = server.query("SELECT FULLNAME CADVOPCDIGITAL WHERE FULLNAME LIKE 'Test.%'")
recs = rs.rows
for i = 0 to rs.rowcount - 1
on error resume next
call server.setopcvalue(recs(i,0) & ".InService", ? )
next
on error goto 0
end sub

-----------------------

Andrew:
I know it is not recommended but how would I script to disable a point. I have some 500 points that I want to take out of service and a simple script seems to be the best way. This is my script so far

sub inoutService
set rs = server.query("SELECT FULLNAME CADVOPCDIGITAL WHERE FULLNAME LIKE 'Test.%'")
recs = rs.rows
for i = 0 to rs.rowcount - 1
on error resume next
call server.setopcvalue(recs(i,0) & ".InService", ? )
next
on error goto 0
end sub

not sure what i need to change the value to . I tried FALSE, "FALSE", 0, "0". What am i missing.

Thanks

----------------------------

AWoodland:
For this purpose scripting is fine, if it is a one-off or user driven function. The original question was for a 24/7 automated solution.

As for what you're trying to achieve, a much simpler way given you're using CAdvOPCDigital rather than any of the more abstract tables like CDBPoint, just use:

set rs = server.query("UPDATE CAdvOPCDigital SET InService = FALSE WHERE FullName LIKE 'Test.%'")

Then you can ditch the rest of the code (although I do recommend checking rs.Error and rs.ErrorMessage after the Server.Query for any errors returned, also if you continue to use your original code then also add that in).

A perhaps better way would just be to run the query directly from querypad rather than via script (run querypad.exe from the Program Files folder). The answer your actual question, afaik those four should all work. Remove the two 'On Error' lines and see if you get a runtime error.