ohaldi Posted October 5, 2012 Report Share Posted October 5, 2012 Hello, I’m new with VisiLogic. I have to compare a MI and a SI value. In fact I don’t understand why I have in a HOUR function a big value in MI “to” time and a small value in SI 31 for “System time” for the same time? Example: I have to switch something off at 23:15. The MI show in debug the value 8981, but the SI 31 shows me for 23:14 the real time like 2314! How can I compare this two value? Regards Otto Link to comment Share on other sites More sharing options...
MVP 2014 Simon Posted October 7, 2012 MVP 2014 Report Share Posted October 7, 2012 Firstly, to answer your immediate question, the HOUR function and SI31 use a different format. SI31 is simple decimal representation, whilst the HOUR function uses a BCD format. See the help file for details. Changing the display format on your HOUR MIs to HEX should make it look right, but that still won't allow you to use a direct compare function, which leads to the second point: You don't need to perform a manual comparison when the indirect clock functions will do this for you (search "indirect clock" in the help). If you still have a reason to use the manual comparison, I think the BCD to NUM function would work to convert the indirect clock format to system time, or the NUM to BCD would convert the system time to indirect clock format (but I haven't tested this) Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted October 8, 2012 MVP 2023 Report Share Posted October 8, 2012 As usual, I read the other post first and replied before reading this one. Otto - do you need the ability for the operator to change the value in MI 151? As Simon pointed out, SI 31 is in its own format: HHMM. This is not a standard conversion from anything but rather a way to display the time in an easily human-readable way. If you need to set this time from within your program then you need to have separate MIs for hours and minutes. Multiply the hour MI by 100 and add it to the minute MI - the result will be in the format needed to compare to SI 31. Joe T. Link to comment Share on other sites More sharing options...
ohaldi Posted October 8, 2012 Author Report Share Posted October 8, 2012 Many thanks for your help. Yes, the solution was to use the function NUM to BCD. Now I can compare the current time to a MI variable. Regards Otto Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now