Can we use DTR to get a week pulse in Rockwell ?

RockyNivas

Member
Join Date
Mar 2019
Location
United Kingdom
Posts
57
Hi All,

I'd like to know can we use DTR instruction to get a week pulse ? Could anyone please help me to understand that one ?
I've managed to get an one second pulse by masking "255" with source and reference values as PLC clock second.

Let's say I generate a midnight pulse and 1 for every pulse and get a pulse when it comes equal to 7. But here's the tricky part. If they start the site on mid of the week then it's not going to be the whole week. It'd be great if I get some advice on that.

Thanks in Advance.
 
That's an interesting one. I remember doing something in a SLC 5/04 once where I calculated the current Julian Date (day of year) and day of week. I may have a copy of that somewhere. It's been almost 20 years, so I don't remember if I used a lookup table for the Julian date of the first Sunday of the year or if I calculated it somehow. Maintenance used the Julian Date of the preceding Sunday as the password but only one guy would change it and if he was out or forgot it would take a couple of tries to log in so I automated it.
My first thought, assuming you're in the Logix 5000 world...probably start with a GSV of the LocalDateTime atribute of the WallClockTime Class and then calculate current day of year and see if it's more than 7 days since the last time your week pulse happened. If so, fire a week pulse. Or more than one if more than one week has passed. Log the current day of year for comparison next week.
Or something like that...
 
The CurrentValue attribute of the WallClockTime GSV glass is the count of µs since 1970-JAN-01 00:00:00. 1970-JAN-01 was a Thursday. So if you divide that divide that 64-bit CurrentValue by 86400000000µ/d (truncated down, not rounded) to get the offset in days from 1970-JAN-01, then reduce that days offset result modulo 7, that modulo result will be the offset in days from Thursday i.e. 0 is Thursday, 1 is Friday, ..., 6 is Wednesday.

So if you want a pulse on Monday, you can keep track of the that [GSV=>DIV by 8.64E10 => MOD by 7] value from the previous scan, and when it changes from not 4 to 4 (Monday is offset from Thursday by 4d), generate that weekly pulse.
 
The only tricky bit is accounting for times that the machine is powered off on Mondays. Or for a whole week. That can be handled for sure and your approach is probably a simpler starting point for calculating the Julian date. Or similar...
 
Rockwellsoftware.com has a free add on instruction to give you the day of the week.
They also have some nice date add/sub etc add on that would be useful when the machine powers on to see how long it has been off.
 

Similar Topics

The DTR requires a DINT This is a PLC5 conversion to Controllogix without altering the HMI So the N files must be Ints not Dints Here I have moved...
Replies
5
Views
2,655
Hi, What I wonder that 43f28000 meaning because I know that 1e5 = 485 decimal value but I say nothing about 43f28000. for example how can I...
Replies
2
Views
2,249
Hi, How can i activate DTR pin in channel 1 of an Allen Bradley Micrologix 1500 using Ladder Logic???? Thanks in advance, lectularius
Replies
1
Views
1,755
I currently trying to figure out what a petiular DTR instuction is doing in a RSlogix 5000 program. The instruction is using a tag value and then...
Replies
4
Views
2,492
If anyone can give me an example of using this instruction I would be happy. I have tried and failed. Lets say I want to track a preset value on...
Replies
6
Views
5,277
Back
Top Bottom