Giorgio

logging a power-on power-off timestamp

2 posts in this topic

OK getting my feet wet with datalogging, have enough understanding to be dangerous, took me forever to figure out the sample datalogging code with the @ symbols in front of memory-locations. Anyways I finally got the datalog and filewrite code logging to the EM0 memory area working after it kept truncating the logged word off my first record, recording the timestamp but not the word of data that changed;  btw for anyone using that sample program needs to change the "MOV #7FFF @D1100" log pointer to "MOV#8000 @D1100" if you're logging to EM0, at least for the CJ1M & CJ2M I haven't tried it on anything else. It seems like EM0 can be treated like an extension of D-memory, so D8000 is an alias for the first word of EM0_00000

Aaaanyways, so we have people shutting machines down so the andon-lights power down, so I gotta log power-up and power-downs. Datalogging the power-on time I'm thinking use the A200.11 first-cycle flag bit to write 0000 0000 0000 0000 or something to the next word in the EM0 log at the pointer, along with the A351 mmss, A352 ddhh , A353 yymm timestamps (in addition to writing it to the "compare for changes" D-Word)

OK now datalogging the time of a power-off has got me chasing my tail. Found the "Power OFF Interrupt task", it seems a bit sketchy to try to MOV the 3 timestamp words to EM0 in the 3-5ms you get, is this how the rest of you do it?

Does anyone have any sample logic? I'm trying to picture the sequencing. Another option looks safer, "CJ2 Programming Manual" Section 6-6 page 329 shows "Auxiliary Area Flags and Words" A512 and A513 as the "Power Interruption Time" (doesn't say, but I'll assume its A512 = ddhh & A513 =mmss ), so since we still need yymm to timestamp (and  my normal datalogs would be 1 logged word + 3 timestamp words),  I could log it at power-up instead, use the same A200.11 first-cycle flag to first write "0000 0000 0000 1111" or something into the EM0 log at the pointer, then A512 , A513 power-interrupted timestamp flags, then  A353 the current mmyy as the power-down mmyy since OMRON decided not to store a full "Power - interrupt" timestamp. Would this work? I think I'd only have a messed up log if the PLC was powered down more than a month .... dammit no it wouldn't work, machine powers down 15:30:06 9/30/17 so the CJ2 stores the mmss (3006) hhdd (1530) it powers down, next day on 10/1/17 at first cycle its going to log power-interrupt day correctly as the 30th, but the month will be logged as October. 

I'd have a faithful 1 bad timestamp a month doing that.

Did OMRON only have a power-fail timestamp-flag for the mmss and ddhh to screw with us? Would it have been that hard to log the yymm too? I'd rather not try to log the timestamp using the "Power OFF Interrupt task" in case that just so happens to be the end of the pointer-buffer and the normal "logging" section tries to do a FWRIT from EM0 to the memory card...

Edited by Giorgio

Share this post


Link to post
Share on other sites

 

I guess I could find an instruction to mask the 1st 8 bits, then compare the last 8 bits of power-down timestamp A512 ddhh (3015 30th of the month in this example) with the last 8 bits of current time timestamp A352 ddhh (0108 if its the 1st of the month at 8AM) and as long as the last 8 bits of A512 are >= A352 we're good timestamping A353 current yymm as power-down time, as long as we haven't been powered down > a month.

If the last 8 bits of A512 are < A352 then find some way to subtract 1 day from A353 current yydd, would  " --B A353 D2103" decrement the month by 1? Then "XFER #1 D2103 @D1100" to datalog my decremented-by-1 yymm timestamp to the EM0 pointer memory-location.

All that hoop-jumping for a power-down yymm timestamp, and its still gonna be a mess if a machine is down > a month.

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