How to populate large array of UDT RS Logix 5k

paulB

Member
Join Date
Apr 2003
Posts
171
I need some programming help. This is RS Logix 5K program. There is UDT TemperatureRecord, which has members:
Year,
Month,
Day,
Hour,
Minute
Temperature1
Temperature2.
There is array of this UDT tags [35040]. Every 15 minutes temperature is stored in this array. Size of the array is enough to hold one year worth of data (4*24*365).
For testing purposes I would like to populate this array with meaningful data like:
TemperatureRecord[0].year = 2011
TemperatureRecord[0].month=1
TemperatureRecord[0].day=1
TemperatureRecord[0].hour=0
temperatureRecord[0].minute=0
TemperatureRecord[0].temperature1=100
TemperatureRecord[0].temperature2=115
.
TemperatureRecord[1].year = 2011
TemperatureRecord[1].month=1
TemperatureRecord[1].day=1
TemperatureRecord[1].hour=0
temperatureRecord[1].minute=15
TemperatureRecord[1].temperature1=100
TemperatureRecord[1].temperature2=115
.
.
.
TemperatureRecord[35039].year = 2011
TemperatureRecord[35039].month=12
TemperatureRecord[35039].day=1
TemperatureRecord[35039].hour=23
temperatureRecord[35039].minute=45
TemperatureRecord[35039].temperature1=100
TemperatureRecord[35039].temperature2=115

I don't like to do it manually, but I am struggling to write program, which will initiate this array with data.
Any idea, anybody?
Maybe Excel can be used somehow. I do not have controller to test, but I can use RS Emulate 5k.
Thank you in advance.
PaulB
 
Obviously the somewhat difficult part is getting the month and day correct.

Create a 12 element array month_day[]. The 0 element is not used.
Initialize them as:

month_day[0] = 31
month_day[1] = 28
month_day[2] = 31
month_day[3] = 31
month_day[4] = 30
month_day[5] = 31
month_day[6] = 30
month_day[7] = 31
month_day[8] = 31
month_day[9] = 30
month_day[10] = 31
month_day[11] = 30

Begin your 365 increment with your first contents

On each increment add 15 to the minute.

If Minute is greater than 59 then minute = 0 and increment the hour.

If hour is greater than 23 then hour equals 0 and increment the day.

If the day is greater than Month_day[month] then add 1 to the month and set the day to 1.

You can keep the initialization subroutine or run it once then save the program and its data with the array already initialized and toss the subroutine.
 
Leap Year??

Any thought about leap year? Pesky extra day every four years.

Am I missing something Bernie or are the number of days incorrect if you skip the [0] element?
 
Get time and date thru a GSV instruction, with minutes from GSV then trigger a fifo every 15 minutes (0 seconds). the fifo (35040 positios) of your udt with your data i.e. year, month, day, hour, minute,temp1 and temp2. If you send me a PM I will send you a sample.
 
Bernie,

Thank you, I'll give it a try.

Widelto

What you are suggesting is what I am trying to do to populate array in during machine operation. I'll send you PM to check if I am doing it correct. But I need to do some testing with this array of data. And I would like to have meaningfull data, not all 0.

Dskohio,

For this application it is irrelevant if year is leap. This array of data will be updated every record with FIFO.
 
I messed up the first couple of the month array. I corrected it
0 isn't used. '1' is January

month_day[1] = 31
month_day[2] = 28
month_day[3] = 31
month_day[4] = 30
month_day[5] = 31
month_day[6] = 30
month_day[7] = 31
month_day[8] = 31
month_day[9] = 30
month_day[10] = 31
month_day[11] = 30
 
I am not sure I would use a FIFO...just taking out the complication of it makes sense to me.

I would:

1 - Create another tag of the same type to house the "current" data. Call it CurretData AS TemperatureRecord

2. Continuously load the CurrentData tag with the relavent external data tags. I would have this as it's own sub routine.

3. At 15 minute intervals, create a trigger to COPy CurrentData to TemperatureRecord[Index]

4. Notice the tag Index, my method will use indirect-addressing to load the proper TemperatureRecord element. Index is used as a pointer to the proper TemperatureRecord element. Each time you trigger a COP of CurrentData to TemperatureRecord you increment the index. If Index > 35040 reset.


Just curious, why not record this data to a database?

If you want to put data into all elements of the array to initialize it, you could use the above method and use a FOR loop to populate it with data. The FOR loop would do all of your indexing in 1 scan, you could get creative and index the data as well so you have a unique value in each element.
 
Last edited:
Paully's5.0

We are OEM and we are providing data, which are stored in PLC memory. It is up to customer to retrieve these data and store them in database. This is replacement of hardware temperature chart recorder. I would like to have that array populated in order to check how to visual portion (PanelView+) working.

PaulB
 
Paully's5.0

We are OEM and we are providing data, which are stored in PLC memory. It is up to customer to retrieve these data and store them in database. This is replacement of hardware temperature chart recorder. I would like to have that array populated in order to check how to visual portion (PanelView+) working.

PaulB

Makes sense.

For testing, if you are familiar with VBA, and writing data to a PLC through RSLinx you could write a quick routine to fill directly with test data. Use excel generate your test data and just download the data to the tags.

Just another idea to ponder..
 
Last edited:

Similar Topics

Hello Everyone. I am working on a project where I need to scan in 2 Barcodes to populate 2 different tags. A glue Batch and a product serial...
Replies
12
Views
3,095
Here is what I have done: We have a VersaView on the line and from what I know you cant do transfer utility for IPCs. So I got the MER file...
Replies
0
Views
1,131
I need to have an array tag that contains string data from a csv file. The csv file needs to be imported once per day. Is there any simple way to...
Replies
3
Views
1,809
Is it possible to auto populate descriptors of bits through multiple layers of UDTs? For example, I want the Highlighted bit in the attached pic...
Replies
7
Views
1,885
Is it possible to auto populate descriptors of bits through multiple layers of UDTs? For example, I want the Highlighted bit to be descripted as...
Replies
0
Views
994
Back
Top Bottom