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

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
Now You Can Have Robust Data Logging for Free – Part 4

PLC program – Continue

In part 3 we finished logging the daily information in the PLC. We will now log minute by minute information in the PLC memory for retrieval. Similar steps will be taken, but we no longer have to track shift by shift information.
This is where the amount of memory used in the controller can be great. The Do-More PLC will allow you to allot more memory to areas in the configuration menu.

We will leave this at the default setting in our project. Remember that this can be modified at any time if you wish to increase the amount of information logged.

Run Minute_Logger
MHR2 – Pointer – Value 670 to 2000
MHR660 – MHR669 – Current logged values
MHR660 – Year – xxxx   MHR661 – Month – xx   MHR662- Day – xx
MHR663 – Hour – xx   MHR664 – Minute – xx   MHR665- Second – xx
MHR666 – MHR667 – Current Meters – xxxxxxxx
MHR668 – Current Rate – xxxxx mpm
Internal used bits –
D40 – D49 / V2

We will start off by looking at the log pointer.

Minute Log Pointer
MHR2 is the porinter for the minute production log. It will point to the location to store the next series. (Next Minute of Data)
MHR2 = 670 means that we are all data has been retrieved.
MHR2 = 2000 means that we have 133 minutes of data to be retrieved.
A visual basic program will read MHR2. If it is greater than 670 then the data will be read and then written into a database. It will then write the value of 670 back into MHR2 to reset the pointer.
Current values are located here:
MHR660 – MHR667

After 133 minutes (~2 hours) without communication to the programmable logic controller, the data will be lost. You may wish to increase the memory area as mentioned above. This will change the MHR area so your reset value will have to change from 2000 to your new setting.

Log Time Parameters
MHR660 – Year
MHR661 – Month
MHR662 – Day
MHR663 – Hour
MHR664 – Minute
MHR665 – Second

This area sets up the real time clock. (RTC) The format is as follows: YYYY MM dd hh mm ss.

Meters
For testing purposes a 50ms internal timer is used. The count input should be activated on the leading edge if you remove the 50ms internal timer.

D19 contains the length per pulse of the counter. In our case D19 = 303
With each pulse of the input, D40 increments by 303. There for after 10 pulses the value in D40 will be 3030. This would represent 3.030 meters of product.
To change this into an integer to log the data we will divide D40 by 1000 and store the result in D41.
D41 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.
MHR666 – MHR667 – Current Meters – xxxxxxxx
D41 divided by 10000 will be placed into MHR666. Ex. 12345678 / 10000 = 1234
D41 minus ((Int(D41/10000)) *10000) will be placed into MHR667.
Ex. 12345678 – ((Int(12345678/10000))*10000) = 12345678 – 12340000 = 5678


Rate
This is the rate per minute. (MPM)
Samples are taken once per minute.

D40 – Current Meters
D42 – Last Minutes Meters
D43 – Meters passed since the last minute
MHR668 – Meters per minute (Rate)
If the current meters is greater than the last minute meters then subtract the last minute meters from the current meters and store it in the meters passed since the last minute.If not do the opposite. This will ensure that a negative number is not obtained. The meters passed since the last minute are then divided by 1000 so we are only looking at the integer of the number.

This finishes the PLC programming. In part 5 we will continue by getting the information out of the PLC.
If you have any questions or need further information, please contact me.
Regards,
Garry

To get a copy of the entire program. Please contact me in the contact section. I will be more than happy to send you the program. Put ‘Robust Logger’ in the subject line.




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.

Leave a Reply

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