Now You Can Have Robust Data Logging for Free – Part 3

Now You Can Have Robust Data Logging for Free – Part 1
Now You Can Have Robust Data Logging for Free – Part 2
Now You Can Have Robust Data Logging for Free – Part 3

PLC program – Continue

We have created the program’s shift bits, shift total seconds, and shift seconds.
Here is the daily log information setup: This is where all of the current values will be stored.



Daily Log Information
MHR10 – Year (XXXX)
MHR11 – Month (XX)
MHR12 – Day (XX)
MHR13 – Weekend 12 am Meters MSW (Most significant word)
MHR14 – Weekend 12 am Meters LSW (Least significant word)
MHR15 – Weekend 12 pm Meters MSW
MHR16 – Weekend 12 pm Meters LSW
MHR17 – Weekday 12-8 am Meters MSW
MHR18 – Weekday 12-8 am Meters LSW
MHR19 – Weekday 8-4 pm Meters MSW
MHR20 – Weekday 8-4 pm Meters LSW
MHR21 – Weekday 4-12 pm Meters MSW
MHR22 – Weekday 4-12 pm Meters LSW
MHR23 – Weekend 12am Utilization % (xxx.x)
MHR24 – Weekend 12pm Utilization % (xxx.x)
MHR25 – Weekday 12-8am Utilization % (xxx.x)
MHR26 – Weekday 8-4pm Utilization % (xxx.x)
MHR27 – Weekday 4-12pm Utilization % (xxx.x)

The real-time clock can be populated by the following:
Note that the format is 2014 11 01 (yyyy mm dd). This will be important when setting up the database for the data.

We will determine the total meters per shift. Remember that our counter will give us one pulse every 0.303 meters.

Shift Meters – Weekend 12 am
For testing purposes, a 50ms internal timer is used. Also, the count input should be activated on the leading edge if the 50-ms internal timer is removed.

D19 contains the length per pulse of the counter. In our case, D19 = 303
With each pulse of the input, D20 increments by 303. Therefore after ten pulses, the value in D20 will be 3030. This would represent 3.030 meters of product.
To change this into an integer to log the data, we will divide D20 by 1000 and store the result in D30.
D30 will now contain the total meters for the shift. This is a 32-bit address location, and we want the results to be in a 16-bit location. (D vs. MHR)
Using some math, we split our total meters into the most significant four digits and the least significant four digits.
MHR13 – Weekend 12 am Meters MSW (Most significant word)
MHR14 – Weekend 12 am Meters LSW (Least significant word)

D30 divided by 10000 will be placed into MHR13. Ex. 12345678 / 10000 = 1234
D30 minus ((Int(D30/10000)) *10000) will be placed into MHR14.
Ex. 12345678 – ((Int(12345678/10000))*10000) = 12345678 – 12340000 = 5678
The same calculation will be used for the other four shifts.
The shift percent will now be calculated. This is for the weekend 12 am shift. Remember that D0 contains the total seconds passed on the change, and D10 contains the total seconds the machine was running.
MHR23 – Weekend 12am Utilization % (xxx.x)
To determine the shift percent to one decimal, we will do the following math:
(D10 * 1000)/D0
If we want one decimal place in the output register, then looking at 75%, this should be equal to the value of 750 in the output channel.
(75 *1000)/100 = 75000/100 = 750
The same calculation will be used for the other four shifts.
Now that we have all the data in the registers, we are ready to log this information when the day changes. That is when the weekend 12 am or weekday 12-8 am shift bit turns on.
 
Daily Production Log Pointer
MHR1 is the pointer for the daily production log. It will point to the location to store the next series. (Next Day of Data)
MHR1 = 30 means that we are all data has been retrieved.
MHR1 = 650 means that we have 31 days of data to be retrieved.
A visual basic program will read MHR1. If it is greater than 30, then the data will be read and written into a database. It will then write the value of 30 back into MHR1 to reset the pointer.
Current values are located here:
MHR10 – MHR27 – As shown above.
Information will be logged for 31 days without communication from the computer program to reset the log pointer.
These are all the requirements for logging the daily information in the PLC. We will now log minute-by-minute information in the next part.

We will finish the PLC programming in part 4 and then continue to get the information out of the PLC.
If you have any questions or need further information, please get in touch with me.
Happy Programming,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimals, Hexadecimal, ASCII, and Floating Points.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.


Leave a Comment