Wonderware Reading Time

Ones_Zeros

Member
Join Date
Feb 2014
Location
at work
Posts
367
Hello
I needing to have wonderware read the windows clock
I can do this but how would i get it to
read the time & have it subtract remaining hours in a day?


thanks
 
WonderWare has a system tag called "$Hour" that takes the value of the current time in military time (1:00 PM is 13:00 etc.). You can write a script that says "24 - $Hour = HoursRemaining;" or something along those lines. That way if it is 1 am, you have 23 hours left, 5 am you have 19 hours left, so on and so forth.
 
$Time displays exact Windows time format.
It will display as to how you have it set up in Windows "Region and Language" settings in control panel.

$Date is also the same date format shown in Windows.



Never mind....I read your post completely...doh
 
Last edited:
How could I script this and take it another step forward in Wonderware?

I can create a tag (24 - $Hour = HoursRemaining) as instructed

here is my formula

Value - Flow / Number hrs passed 10:00 x 24

someone will manually insert the "Value" into a memory interger tag say the value is 100.

100 - 60 = 40 / (number hours that passed 10:00) this is were i would like to insert the "HoursRemaining" tag x 24


can you Wonderware scripting genius help me with this please

thanks
 
Wonderware scripting genius

Gosh, if I wasn't so flattered I would think that was sarcasm. ;)

I am assuming that your "Value" is just a tag that someone writes to. And I am also assuming that your "Flow" is coming from a flowmeter or something like that.

So the 10:00 deal is throwing me off a little bit, because if you want to know the hours past 10:00Am the script has to be changed a little bit. The one we wrote will tell you how many hours remain in the current day.

So we don't even have to use the first script necessarily if you need it to go further, we can just include that part in the new script.

So it would look something like this.
Code:
Result = (Value - Flow)/(24 - $Hour);
If you wanted this thing to just work from 10:00 AM onward, then it would look like this

Code:
IF $Hour >= 10 THEN Result = (Value - Flow)/(24 - $Hour);
ENDIF;
If you could explain a little bit better about the end goal of what you want this to do, I might be able to get something a little more precise or cleaner or whatever.

Hope this helps!
 
Hello SandwichMagic,
I was very serious and thank you for your help
and expertise on Wonderware scripting

If you could explain a little bit better about the end goal of what you want this to do, I might be able to get something a little more precise or cleaner or whatever.


I think your spot on with your 10:00 am script, but I will explain what I'm wanting to accomplish in Wonderware & maybe you can tell me of a better way to go about this.

Here is my calculation & I will explain each portion and you critique it please
(Value - Flow) / (Number hrs passed 10:00) x(24)

1. Yes, the "Value" will be a number that will be a User Input in Wonderware that I'm assuming I would configure as a Memory Integer. the user will type this value in.

2. The "Flow" will be a I/O Real tag that I will be reading from a Flow meter

3. The flow total runs from 10:00 am to 10:00 am each day. We have a certain total we have to meet each day in a 24 hr period and I need to know at various times in the day what we have left to meet this total. It starts all over again at 10:00 am the next day and this total may change each day depending on the customer. So i thought if i could script wonderware to constantly check the windows clock if really would matter what time i check this, so if I check at 6:00 pm i would have to write the script to take the (Value-Flow) / (16 hours) this would be the remaining hours left in the 24 hour period. Then multiple this total by 24 hours,this value would give me the remaining total & i would know what i had left to meet our 24 hour total.
could i script the time in this calculation to were it wouldn't matter what time in the day it was what the check was made to see what was left in the day to me the 24 hour total?

I hope this all makes sense
I appreciate you stepping me though this script

Thanks alot
 
You are getting the very rare weekend post out of me, I can't do a lot of testing because my only way to test stuff is at work, but I can help where I can.

Alrighty, I understand what is going on much clearer now, the "Value" tag (which yes, if it's not in the PLC would be a memory integer) is your Desired Total for the day. I think that Your "Flow" tag is your current total since 10:00 AM. And you want to see How much flow total you need to meet your goal. I hope I am understanding this right.

This should get you going in the right direction, but it's pretty inelegant if that is alright.

So what you can do is Kind of create a countdown script that counts down every hour.

Type: Data Change: $Hour
Code:
HoursRemaining = HoursRemaining - 1;
IF $Hour == 10 THEN HoursRemaining = 24;
ENDIF;
This is what determines how many hours are left till 10:00AM. The only problem I can see with this is that it wouldn't be right until the next time you want to reset your totalizer, aka the next 10:00 AM. If that's not alright, you can just manually set the value of the tag when you make it to however many hours you have left. But after that, it should work just fine.

Your final code should look something like this.

Code:
Result = ((Value - Flow) / HoursRemaining) x (24);
Result is another memory integer by the by.

Note: I really hope that "Value" and "Flow" aren't your actual tag names, use something more descriptive! It will help tremendously in the future.

So now you can run that script whenever you want to in order to update the value of "Result". Be it periodically, or at the press of a button. If you just wanted to create a Display that updates live, you can use a "Display Integer" animation link on just a piece of text. For our apps if we have a live display of a value, we just make the text ####### for spacing and so we know what is supposed to be there. In that dialog box that comes up when you click "Display Integer", you can put the whole expression in the box I believe, meaning what you stick in the box is:

Code:
((Value - Flow) / HoursRemaining) x (24);
That should give you a live update on that piece of text.

I apologize for how long it took me to write this, I have to edit my posts often. I tend to make very, very long run on sentences just filled with comma splices.

I really hope this works! I've only been working with InTouch for about a year and half now, and I am mostly self taught, but I picked it up pretty quick! I guess HMI development is just my favorite little chore that we do.

If it doesn't work, Please let me know, and I'll be happy to see what's up or ask for some help from some of our real WonderWare Gurus.
 
To solve flow calculation problems with value of $Hour because of 0- 24 hour count and your shift is 10 to 10....
Why not use a "Data Change" script and just count hours?
(It will also make some of your other calculations easier to solve.)

1) Make a memory integer tag "FlowHours".

2)Make this "Data Change" script using $Hours:

FlowHours = FlowHours +1
If FlowHours = 10 THEN
FlowHours = 0
ENDIF;


Now you can use the tag "FlowHours" in your "remaining flow" calculations.


Note:
(You could also add $Minute to scripts for "FlowMinutes" for more accuracy and more active HMI display of flow rate calculations, also you can show hourly rate by making FlowHours and FlowMinutes memory real tags and scripting:

1) Make a Data Change script on $Minute

IF $Minutes = 0 THEN
FlowHours = Flow Hours +1
ENDIF;

FlowMinutes = $minute * .01;
FlowHours = FlowHours + FlowMiniutes;
 
Last edited:
Using above scripting....You can now calculate FlowHours to show "Flow Total per elapsed hours" and subtract from user entry to get remaining flow required.
 
I think I may have it, i will post back later with details.

One issue that I'm having is resetting the flow on my test machine.
when I make this live I wont have to do this script

but for testing purposes on my test machine how would I reset my flow value at a certain time, its the major piece that needs to be reset


On my condition script, i'm using this function but its not working

$Hour ==10 AND $Minute==30
condition type "on true"
FlowValue = 0

but when the time comes to reset the "FlowValue" to 0 it doesn't,
what type of tag does "FlowValue" need to be (Memory Real or Memory Integer)

like i said I won't have to do this when ai go live with this, but for testing I just wanted to make sure it worked.


Thanks,
 
If you say FlowValue = 0, it does not matter if it is real or integer, it will be set to zero.
If Flow Value is only hours then it does not need to be real tag.
Are you displaying FlowValue in your app to watch it change?

It will need to be same tag type as "Value" tag which is entered by operator.

You might also try "While True" as a test on $Hour ==10 AND $Minute==30.
 
Last edited:
Oh yea...
Are you sure you are not writing to FlowValue anywhere else? May be that is why is does not go to zero? Try resetting it to 1 instead of 0 to see change.


You can also use "Data Change" script on $Minute and write:

If $Minute = 30 and $Hour = 10 THEN
FlowValue = 0;
 

Similar Topics

Hello, I have a SLC500 Micrologix PLC that will sometimes go into a "Watchdog fault" When it does this all the data on the wonderware screen is...
Replies
11
Views
3,016
I’m having trouble reading the Allen Bradley Compact Logic ProgramTags Into my Archestra Wonderware SCADA program. I have the input source...
Replies
1
Views
1,516
Hello, I was needing to read an output bit of O:7/0 in wonderware. I can see this bit change states in the PLC but it doesn't in wonderware. Does...
Replies
7
Views
2,132
Hey Guys I'm reading the Centurion controller event Codes into my Wonderware SCADA software Program. I've setup my script to read these event...
Replies
12
Views
5,033
I configured a Historian that has 22 data sources (all remote Wonderware nodes). Some are DASABCIP, most are DASMBSerial, and one is WWRSLINX...
Replies
0
Views
1,991
Back
Top Bottom