Posted 10 May 2006 Hi, Has anybody used the date compare instructions in CS1? I am trying to check if the system date is between some HH:MM:SS and set some flags. The instruction is not working, and instruction help is not very clear. I'm a bit confused about the mask. it says : "Set 1 for bit 0 to bit5 in C to mask seconds, minutes, hours, days, months, or years when comparing dates." In first word, I'm comparing MM:SS in 4 digit hex format, next word I'm comparing 00:HH. Any ideas? Share this post Link to post Share on other sites
Posted 11 May 2006 Use the fuction ANDW. ANDW #00FF A352 D2501 will place the hours into D2501. Share this post Link to post Share on other sites
Posted 11 May 2006 Here's the logic that i usually use.... Clock.PDF Share this post Link to post Share on other sites
Posted 11 May 2006 Sorry Guys, I think in a hurry I didn'y put up the question properly. I'm getting the MMSS and HH data from the system and from HMI properly (UINT_BCD), or so do I think (sample attached) but the compare function that should give me an output when the time is within H1:M1:S1 and H2:M2:S2 is not working. Questions are, 1. The instruction help says Masks can be created by putting 1 in bits 0 to 5 in mask word!, however in pictorial presention of the instruction, it doesn't show where I can put the mask and what values it can take, hex or BCD? 2.If one bit is for one BCD digit, only 4bits are required, why six? 3.when I put a masking bit, does the instruction compare that digit or ignore it? I have attached the .doc file of the image of my code, obviously mask settings are not what it should be. I'm trying... Date_Compare_Image.doc Share this post Link to post Share on other sites
Posted 11 May 2006 I scrapped date compare, used the ZCP instruction instead and its working! Thought how to use date compare remains as an open issue! Thanks for your posting anyway. Share this post Link to post Share on other sites
Posted 11 May 2006 I use ANDW as a mask all the time and then a straight compare function and it works. Will post some code from a recent job a little later. Share this post Link to post Share on other sites
Posted 12 May 2006 (edited) I had a day to look at this, it seems that you are trying to use the date compare the wrong way, i have attached a copy of the maual that might help explain thier use. The first word of the instruction is for what type of data to compare i.e. seconds, minutes..... The second is the current time: a351 and this looks at the next 3 words. The third is your data and the next three words. I have also made an example and i will try and attach that too. It shows a bit turn on if the plc's clock is after 5:00 pm. Whats tricky about this is in the control word the data you want to compare is marked by a "0" rather than a "1"..... i was confused on this in the begning, but i got it working based on just the caption in the doc i attached. so for every dt compare that you use you need to allocate 3dm areas for each one! you had 4 of them in your trial so 4 sets of 3 are needed for each one. Hope this helps! And sorry its to late! ~Andrew time.doc time_example.cxp Edited 12 May 2006 by Andrew Ticknor Share this post Link to post Share on other sites
Posted 13 May 2006 Sorry I have not been back sooner. Had to wait till I got back from site. Attached is a routine I use to turn on a fuel circulation pump at 10AM each day Monday to Friday. Time_Clock.pdf Share this post Link to post Share on other sites
Posted 15 May 2006 well your way works too! At least we know how the dt function works now. ~Andrew Share this post Link to post Share on other sites