CL 5380 RTC vs Timer.ACC, question

JZerb

Member
Join Date
Oct 2016
Location
Here
Posts
423
I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO is accumulating until completion which then triggers logic to capture the time that the event stops. I use a GSV instruction that is executed from a one shot to capture the started and finished date and time from the PLC's RTC. I then take the timers .ACC value and divide that by 1000 so that I can display the duration of the event in seconds. What I am running into is the fact that it seems regardless of what the .ACC value is from the timer, when dividing by 1000 it rounds down. For example 22999 rounds down to 22 and the tag that I am using as the DEST for the DIV instruction that I just mentioned is a DINT data type.

My question is in regards to the PLC's RTC and the GSV instruction. When the GSV is triggered and the seconds are read from the PLC's RTC, is the seconds value rounded as well? I assume the seconds value is based on the microseconds value from the RTC for the rounding. There are times where the GSV shows the correct elapsed time from the Start and Finished triggers, but when I do the math on the .ACC from the timer, its off by one second. Which makes sense based on the rounding of the timers .ACC DINT value.
 
22999 / 1000 = quotient 22, remainder 999.

The ControlLogix integer Divide does not "round down" when the arguments and results are all integers: it truncates and delivers only the quotient as the result. If you want the remainder, use the Modulo (MOD) command to obtain it. Or, use a REAL tag as one of your arguments.

Since you have a 5380 series controller it should support firmware that lets you do math on LINT datatypes, so you can GSV the WallClockTime's CurrentValue at the beginning and end of the event, and subtract the end from the start to get elapsed microseconds. You don't need an RTO at all.

The Seconds value of the Wall Clock Time is definitely not rounded. It goes up by 1 when the Microseconds value goes up by 1,000,000 but not until then.
 
Ken, thank you for your response. I did think about doing the math on the two GSV instructions like you mentioned, however there may be an interruption(s) to the process so just taking the captured start and finished times and then doing the math on those values would leave me in a bit of a jam math wise there. Since the "pause" of the process would then be accounted for within that math.

What I didn't want to get jammed up with was rounding the calculated value up, 22999 / 1000 = quotient 22, remainder 999, so that would go to 23 but then having the wall clock values be 'off' by a second in the opposite direction. Throughout all of my testing of the code here the WallClockTimes for the start and finish of the process are all accurate and depict the PRE time from the RTO for the process, its just been the calculated elapsed time value that's been off by a second here and there. But now knowing that seconds value will not round itself in the controller but only increment when the microseconds value goes up by 1,000,000, I think I will be ok there.
 

Similar Topics

gents, I am trying to configure communication with EMERSON PK300 controller through port A1 using generic ethernet communication module . I could...
Replies
0
Views
125
I want to factory Reset my 5380 (5069-L310) I have here in home lab. Reason being I want to make a Internal How-To video for Setting the IP...
Replies
2
Views
571
I had a comms fault between my VFD and Controller (5069-L320ERS2) that started about a month ago and happened maybe once a day to now where it...
Replies
1
Views
308
Hello, Just want to share my "experience" with newly received CompactLogix 5380. It's the first time I'm going to use this one. (I've been using...
Replies
10
Views
1,395
:shoot: Hi, I am looking for a little bit of help : I have Cognex DM 280 barcode reader connected through ethernet to CompactLogix 5380 and...
Replies
3
Views
2,487
Back
Top Bottom