You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old March 13th, 2018, 06:51 PM   #1
defcon.klaxon
Lifetime Supporting Member
United States

defcon.klaxon is offline
 
Join Date: Feb 2015
Location: Far NorCal
Posts: 401
Using MOD function in Wonderware to run conditional script

Hey guys,

I'm working on an existing system where the old programmer (from like 25 years ago) used a bunch of conditional scripts in Wonderware to execute said scripts once a minute. Programmer did this by using "$Second MOD 59 == 0" as the condition. Seems like it would work, but doesn't this condition become true twice a minute (when $Second == 59, but also when $Second == 0)?

The problem is, the operators aren't aware of what is new and what is old, so when they notice something not working, they assume it's because of my new work, and not something that has literally been around for 25 years (and I've already fixed a few bugs they've been complaining about for literally 25 years!).

I'm going to remove the conditional scripts and create the same code in LD (flow totalizers and ETM) but for future reference, was wondering if the $Second MOD xx == 0 code is valid, or if it should be avoided.
  Reply With Quote
Old March 13th, 2018, 07:30 PM   #2
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,535
I think the script is probably triggered on the transition of the expression from false to true. There is no false to true transition when the value of $Second goes from 59 to zero.
  Reply With Quote
Old March 13th, 2018, 07:49 PM   #3
defcon.klaxon
Lifetime Supporting Member
United States

defcon.klaxon is offline
 
Join Date: Feb 2015
Location: Far NorCal
Posts: 401
Quote:
Originally Posted by Steve Bailey View Post
I think the script is probably triggered on the transition of the expression from false to true. There is no false to true transition when the value of $Second goes from 59 to zero.
Ahhhh, I bet that's exactly it, and that's why I'm having issues...apparently older versions of Wonderware allowed multiple instances of identical condition scripts (there are four to five instances of the same condition in the existing program) and as it exists, it's ok...but if you want to make a change to any of the scripts, it'll throw an error, saying there's already another script with that condition. What I did was I took some of the code from the MOD 59 == 0 and cut/pasted into a new script with MOD 58 == 0. BUT, MOD 58 == 0 will false to true transition twice instead of once, which would explain why the totalizers in question are reading double what they should. Thanks for the help Steve!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
WinCC Flex. Run script based on value of Internal tag smcmanus LIVE PLC Questions And Answers 4 July 9th, 2007 08:42 AM
Wonderware Simple Script geniusintraining LIVE PLC Questions And Answers 5 March 2nd, 2007 01:36 PM
Protool question (VB script related) Johnny T LIVE PLC Questions And Answers 6 March 2nd, 2007 04:57 AM
Wonderware Script Issue ControlLogix LIVE PLC Questions And Answers 2 October 24th, 2005 11:56 AM
WinCC Webnavigator, run script on server? goblin LIVE PLC Questions And Answers 0 August 9th, 2005 02:24 AM


All times are GMT -5. The time now is 03:39 PM.


.