Public Holiday in Controlgix

Join Date
May 2020
Location
brisbane
Posts
1
Hi,

Would like some help on how to determine a public holiday in the controllogiox calendar or other methods that have been used successfully in the past?
 
Welcome to the PLCTalk forum !

ControlLogix has a "Wall Clock Time" function, which will give you the Year, Day, and Month.

But a schedule of public holidays would have to be hard-coded, or determined by some other sort of middleware, generally one that has access to the Internet.

Because it's my quarantine-time tech toy, I would probably automate something like this in Node-Red on a small Linux box.
 
Hi,

Would like some help on how to determine a public holiday in the controllogiox calendar or other methods that have been used successfully in the past?


Public holidays for what country? (y) I think you could program easily for those holidays that are on same day in the calendar. I don't know how you would guess when is Easter this year.


Maybe you have some HMI or some computer communicating with PLC? Probably you could make a script that could tell to the PLC when is public holiday.
 
Raspberry Pi using Python, the holidays library, and our very own dmroeder's PyLogix library.


Code:
#!/usr/bin/env python3

# Write to a Logix PLC tag named 'Holiday_Flag' whether the date is a holiday or not.

from datetime import date
import pylogix, holidays

ipAddress = '192.168.141.126'
tagName = 'Holiday_Flag'

# Create the holiday object for a particular locale.
holidayObject = holidays.UnitedStates()

# Test if today is a holiday
holidayFlag = date.today() in holidayObject

# Write the holiday status to the PLC tag
with pylogix.PLC() as comm
	comm.IPAddress = ipAddress
	comm.Write(tagName, holidayFlag)
 
First use GSV to get the WallClockTime object into a UDT tag with elements containing two-digit year, month and day of month in INTS. Call them YR, MO and DY.

The holiday calendar is then easily done with another tag of type DINT in an array of [100,13,1]. The Dimension 2 represents the two-digit year, Dimension 1 is month (1-12) and Dimension 0 DINT bits represent the day of month, 1-31.

You'll need to code the bits in the array to represent the calendar you desire. In my case logic 1 represented an 'on-peak' day for the local electric utility, M-F except American holidays; so the Wednesday May 13, 2020 bit represented by array location [20,5,0].13 would be logic 1. Somewhere in the past I came up with an Excel calculator to provide the DINT values for each month in the array automatically (i.e, value 1014823410 was for May 2020) but since lost it. I'm in the process of writing a one-time Ladder Routine to index through my array and automatically fill in all 99 years. That looks like it will be fairly easy for my utility using American holidays.

Once the array values are set, a single rung of indirect referencing the array bits using your WallClockTime tag can be used to check if today is a holiday (or whatever):

XIC calendar_tag[YR,MO,0].[DY] OTE is_holiday_tag
 
Last edited:
seasoned advice ...

not certain exactly what you're attempting to accomplish with this project - but whatever you come up with - make SURE that you have an automatic "override" available ...

I've personally run into several situations over the years where the computer running things has been programmed to shut everything down - regardless of any "emergency" orders that have to be processed ...

I've been locked out of the office building that I rented because the computer system had Labor Day programmed as an official "holiday" - so no one should need to get into the building ... (wrong answer ... Ron still had to labor - even on Labor Day) ...

I've sweated buckets while rolling all of my training lab equipment into a cavernous automotive plant - since the computer had decided to turn off the air conditioning system over the weekend ... (no one knew how to bypass the stupid thing) ... even the fans were off ...

I could go on - but I've made my point ... feel free to ignore me if you like ...

party on ...
 
First use GSV to get the WallClockTime object into a UDT tag with elements containing two-digit year, month and day of month in INTS. Call them YR, MO and DY.

The holiday calendar is then easily done with another tag of type DINT in an array of [100,13,1]. The Dimension 2 represents the two-digit year, Dimension 1 is month (1-12) and Dimension 0 DINT bits represent the day of month, 1-31.

You'll need to code the bits in the array to represent the calendar you desire. In my case logic 1 represented an 'on-peak' day for the local electric utility, M-F except American holidays; so the Wednesday May 13, 2020 bit represented by array location [20,5,0].13 would be logic 1. Somewhere in the past I came up with an Excel calculator to provide the DINT values for each month in the array automatically (i.e, value 1014823410 was for May 2020) but since lost it. I'm in the process of writing a one-time Ladder Routine to index through my array and automatically fill in all 99 years. That looks like it will be fairly easy for my utility using American holidays.

Once the array values are set, a single rung of indirect referencing the array bits using your WallClockTime tag can be used to check if today is a holiday (or whatever):

XIC calendar_tag[YR,MO,0].[DY] OTE is_holiday_tag

How do you get it to UDT with 2 digit year without intermediate step?
 
Sorry, I thought that part was obvious. Math.

<DateTime_tag.Year> - 2000 = <TwoDigit_Year_tag>

I put in an ABS instruction to protect against a negative value at <TwoDigit_Year_tag> since it's used as an indirect addressing pointer. That can happen if the RTC is at it's default value (1999-something).
 
Sorry, I thought that part was obvious. Math.

<DateTime_tag.Year> - 2000 = <TwoDigit_Year_tag>

I put in an ABS instruction to protect against a negative value at <TwoDigit_Year_tag> since it's used as an indirect addressing pointer. That can happen if the RTC is at it's default value (1999-something).
Or you could use
Code:
DateTime_tag.Year MOD 100
which would cover you for the negative result and work indefinitely, instead of breaking in the year 2100 when I'm six feet under.
 

Similar Topics

hello dear forum, About DELTA DIAView SCADA I defined a variable in Timescript VBscript I want access this variable from within a window For...
Replies
0
Views
578
Hi all- I have an application where: - I have a fixed system with a pre-determined, static, network (say, 192.168.2.0/24). - That system...
Replies
13
Views
4,234
Hello everyone, I face a problem with setting connection between my computer and PLC using NAT addressing. I configured NAT. In private network...
Replies
2
Views
1,972
Hello all, I have two identical cells. Each have a PLC, HMI, Laser etc. The IPs are also identical so for instance both PLCs are 192.168.10.1...
Replies
10
Views
4,495
For remote monitoring of solar energy systems, we've been using Multitech eCell (MTE) modems which our monitoring supplier furnishes bundled with...
Replies
10
Views
2,889
Back
Top Bottom