Gville

Unity Pro XL Get Time of Day

6 posts in this topic

Posted (edited)

Hi, very new to PLC programming and desperately looking for some help to finish my project!

I need to program a pump to run based on the level in a holding tank. The start/stop set points change throughout the day based on the time. For example, function for the start set point is 1.15372×10^-6 x^6 - 0.000114068 x^5 + 0.00448866 x^4 - 0.0883477 x^3 + 0.877893 x^2 - 3.57417 x + 7.5, where x is in hours. How can I access the PLC time (current hour and minute) so I can use them to calculate the set points? Does Unity Pro XL have pre-defined variables for these?

Edited by Gville
vague title

Share this post


Link to post
Share on other sites

See help about %SW51

%SW51 = 16#HHMM

1 person likes this

Share this post


Link to post
Share on other sites

Yes, I did find that last night though now I'm running into another issue. I would like to separate the hours and minutes so that I can have a single Real value for the hour of day. I found the LEFT_INT and RIGHT_INT blocks to separate the the data from the string, but when I change from Integer to String I get some additional data in front of my number (+0) which is making it hard to get to the hour value. How can I either remove or ignore the +0 prefix?

Share this post


Link to post
Share on other sites

MinutesHours := BCD_TO_INT(%SW51);
Hours := INT_TO_REAL(MinutesHours/100);
Minutes := INT_TO_REAL(MinutesHours MOD 100);

1 person likes this

Share this post


Link to post
Share on other sites

Got it, thanks a lot!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now