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 our shift bits, shift total seconds, shift seconds for the program.
Here is the setup for the daily log information: 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 12am Meters MSW (Most significant word)
MHR14 – Weekend 12am Meters LSW (Least significant word)
MHR15 – Weekend 12pm Meters MSW
MHR16 – Weekend 12pm Meters LSW
MHR17 – Weekday 12-8am Meters MSW
MHR18 – Weekday 12-8am Meters LSW
MHR19 – Weekday 8-4pm Meters MSW
MHR20 – Weekday 8-4pm Meters LSW
MHR21 – Weekday 4-12pm Meters MSW
MHR22 – Weekday 4-12pm 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 12am
For testing purposes a 50ms internal timer is used. Also the count input should be activated on the leading edge, if the 50ms 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. There for after 10 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 address location. (D vs MHR)
Using some math we split our total meters into the most significant 4 digits and the least significant 4 digits.
MHR13 – Weekend 12am Meters MSW (Most significant word)
MHR14 – Weekend 12am 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 4 shifts.
The shift percent will now be calculated. Remember that D0 contained the total seconds that have passed on the shift and D10 contains the total seconds that the machine was running. This is for weekend 12am shift.
MHR23 – Weekend 12am Utilization % (xxx.x)
To determine the shift percent to one decimal we will do the following math:
(D10 * 1000)/D0
Ex. 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 4 shifts.
Now that we have all of the data in the registers we are now ready to log this information when the day changes. That is when the weekend 12am or weekday 12-8am shift bit turns on.
 
Daily Production Log Pointer
MHR1 is the porinter 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 then 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.
This is 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 onto getting the information out of the PLC.
If you have any questions or need further information, please contact me.
Happy Programming,
Garry



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

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.

It's only fair to share...Email this to someoneShare on LinkedInShare on FacebookShare on Google+Digg thisPin on PinterestShare on StumbleUponShare on TumblrTweet about this on TwitterShare on RedditPrint this page

Leave a Reply

Your email address will not be published. Required fields are marked *