Tag Archives: plc examples

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.

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

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

PLC program 

The programmable logic controller PLC will log the data in the PLC memory using indirect addressing for the data log. Information will be collected based upon shifts.
We will use the following shift schedule. Midnight, Afternoon and Days for the weekday and have two weekend shifts. Each shift will show amount of product made, utilization of the machine and rate of product made.
Also we will log a minute by minute account of the machine. This will log the amount of product made and the rate at which it is made. We can then graph the machine performance to determine if it is running correctly.

Hardware:
Do-More Designer
https://www.automationdirect.com/adc/Shopping/Catalog/Programmable_Controllers/Do-more_Series_(BRX,_H2,_T1H)_PLCs_(Micro_Modular_-a-_Stackable)
We will demonstrate everything in the PLC simulator, but the hardware would be the following:

  1. Qty 1 – H2-DM1E – Do-more PLC H2 series CPU module, three built-in communications ports: (1) RS-232 port; (1) USB port; (1) Ethernet port
  2. Qty 1 – D2-03B-1 (110/220 VAC) 3-slot base (includes power supply)
  3. Qty 1 – D2-08ND3 – 8 pt. 12-24 VDC current sinking/sourcing, 1 common (2 common terminals), removable terminal

Software:
The software will be broken down into several elements. Understanding each element and how it relates to the program is important.

Shift Bits- These are the shifts that employees will work.
C0 – Internal Bit – Weekend – 12 – 12am
C1 – Internal Bit – Weekend – 12 – 12pm
C2 – Internal Bit – Weekday – 12- 8am
C3 – Internal Bit – Weekday – 8 – 4pm
C4 – Internal Bit – Weekday – 4- 12pm

Total Shift Seconds – This is the number of seconds that have elapsed on each shift. If the PLC was not in run mode then this would not function. This will be used to determine the percentage of the shift that the machine was running.
D0 – Total Shift Seconds – Weekend 12-12am
D1 – Total Shift Seconds – Weekend 12-12pm
D2 – Total Shift Seconds – Weekday 12-8am
D3 – Total Shift Seconds – Weekday 8-4pm
D4 – Total Shift Seconds – Weekday 4-12pm
Note: 8 hour shift = 8 x 60 x 60 = 28800 seconds
         12 hour shift = 12 x 60 x 60 = 43200 seconds
Shift Seconds Reset – Use the leading edge of the shift bit to reset the shift seconds and the total shift seconds.

Next we have to determine if the machine is running or not. If it is running then count the number of seconds for the shift.
The input X0 is a signal off of a proximity sensor for a length counter. Every pulse of the input will represent 0.303 meters of product.

Machine Running Bit:
Determine if the machine has stopped. If the count input stops counting for 2 seconds then the output stop bit turns on.
Timers are used for both the on and off condition of the input. The input can stop when the input is on or it can stop when the input is off.
Stop Bit – C10 – Will be on if the machine has stopped counting

Shift Seconds – This is the total number of seconds that the machine has run for each shift.
D10 – Shift Seconds – Weekend 12-12am
D11 – Shift Seconds – Weekend 12-12pm
D12 – Shift Seconds – Weekday 12-8am
D13 – Shift Seconds – Weekday 8-4pm
D14 – Shift Seconds – Weekday 4-12pm

We will stop here and continue the PLC program in part 3.
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.

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

Robust PLC Data Logger
 
With traditional loggers, software will read the memory of the PLC and store in a local computer. If the network stops or the PLC communication fails then the logging will stop.
Creating a robust PLC data logger allows the communication to be stopped for a period of time without losing any of the data for collection. This is accomplished by storing the data locally on the PLC until communication is restored. All of the data is then read without loss. The amount of time that the connection can be lost will be dependent on the memory size of the PLC and the frequency of the data collected.
This series will walk you through the steps to create and implement a robust PLC data logger using the following equipment and hardware.
  • Automation Direct – Do-More – H2-DM1E PLC (Ethernet Modbus TCP)
  • Do-more Designer 1.3 (Simulator instead of PLC mentioned above)
  • Windows based computer running IIS
  • Visual Basic 6

The following steps will be explained in details and sample programming.

PLC program
The programmable logic controller PLC will log the data in the PLC memory using indirect addressing for the data log. Information will be collected based upon shifts.
We will use the following shift schedule. Midnight, Afternoon and Days for the weekday and have two weekend shifts. Each shift will show amount of product made, utilization of the machine and rate of product made.
Also we will log a minute by minute account of the machine. This will log the amount of product made and the rate at which it is made. We can then graph the machine performance to determine if it is running correctly.

Data Collection
Visual Basic 6 will be used to log the data into a database. The information will be collected using Modbus TCP communication to the Do-More PLC and/or Simulator of the Do-more Designer. This will use an Ethernet communication cable to the PLC. The program will read the indirect address pointers in the PLC. It will then read the information collected and store the information into an Access Database. The indirect address pointers will then be reset by the program.

Data Distribution
We will set up a web server (IIS). This will allow the access database containing the information from the PLC to be available to all of the computers on the local network. (Intranet)
We will use Active Server Pages (ASP) and HTML to create programs to access this database information. Web browsers will call our ASP and HTML program so the information can be displayed on the device. This will be universal when we look at it with computers, tablets and phones.

Advanced Data Distribution
Using Raphael and SVG programming, we will graph using line graphs. We will also see how we can use dials to create dashboards on our web server.

This may sound like allot of work to do, but it is not. What we are doing is breaking down the fundamentals to display information. Using a robust logging system from the PLC ensures the reliability and your confidence of the data collected. Once the basic principles are applied, your system can expand rapidly.

Are you ready?

If you have any questions or need further information please contact me.
Thank you,
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.