Tag Archives: excel

Data logging does not have to be complicated anymore. The BRX Series PLC can log your specific data up to 32 Gigabits on a Micro SD Card. It will store your data for future data analysis in a CSV (Comma Separated Value) Txt file based on time and/or event.
This is all accomplished with just one instruction in the BRX PLC. Excel is just one program that you can import and analysis this CSV Text file.
Do-More Designer has a Browse PLC File Systems window that will allow you to copy, create and delete the files from the connected computer. This will save you from going to each controller, removing and copying the files on the Micro SD Card.
We will be looking at the data logging instruction in the BRX Series PLC and how to retrieve and view this information. Let’s get started. Continue Reading!

I have been recently asked how you can move data conditionally on an excel spreadsheet once the information has been obtained from the PLC? Monthly data was being collected from the PLC and put on an excel spreadsheet using Omron CX-Server DDE. They wanted at the beginning of each month to move the data to the appropriate month so they can track the changes.

The following three blogs were posted on how to get data into the Microsoft Excel Spreadsheet from the programmable logic controller. (PLC)

The method to move the data around the spreadsheet once the data has been obtained will be done by Visual Basic for Applications. (VBA)

Make a spreadsheet in excel as follows:

Operation:
When the current data in A2 or B2 changes, it will trigger a macro to execute. This macro will use the Worksheet_Change to trigger the code. The date in A2 is then compared to all of the dates located from A5 to A30. If a match is found then the value in B2 is placed beside the matching date found column. Example: A2 = A7 then B7 = B2
Here is a look at the VBA editor and code:

Here is the following code:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = “$A$2” Or Target.Address = “$B$2” Then For x = 5 To 30 If Sheets(“Sheet1”).Range(“A2”) = Sheets(“Sheet1”).Range(“A” & x) Then Sheets(“Sheet1”).Range(“B” & x) = Sheets(“Sheet1”).Range(“B2”) End If Next ‘x End If End Sub

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.

First Name:Last Name:Email address:

Leave this field empty if you're human:

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.

The Modbus TCP/IP or Modbus TCP is a Protocol that is used for communications over TCP/IP networks. This is done on port 502. Modbus TCP does not require a checksum calculation as lower layers already provide checksum protection. You can think of this as a letter being sent and Ethernet TCP/IP acts like an envelope for the Modbus Commands. I will not go into the details of the communication protocol but here are some links to references:Introduction to Modbus TCP/IPSimply Modbus – Modbus TCP

OstroSoft Winsock Component
OSWINSCK.dll serves as a wrapper for the Winsock API and helps programmers to abstract from the complexity of API calls and focus on application functionality. Works with programming and scripting languages supporting COM.
You will need to download and install the OstroSoft Winsock Component on your computer.
For use with .NET, Visual Basic 4 or 5, Visual C++, ASP, VBA, VBScript, JavaScript or any other language, supporting COM:
1. Download oswinsck.exe

2. Run downloaded file from Windows Explorer or command-line
Hit OK
I use the default directories where the program will be installed. Click the button to install.
Leave the program group to the default so I know what the program is after installation. Click continue.
Click OKThe OstroSoft Winsock Component is now installed.

Start Microsoft Excel.

Select ‘Developer’ along the top tabs.

If the Developer tab is not present then we must turn on the developer tab.
Select File | Options Select ‘Customize Ribbon’Check the ‘Developer’ under Main Tabs.

Under the Developer menu. Select ‘Visual Basic’The Visual Basic Editor window will now be displayed.
From the menu – Tools | References
We can now add the OstroSoft Winsock Component to our application.
Select OKSelect Sheet1(Sheet1).

‘ If TCP is not connected, try to connect again.If wsTCP.State <> 7 Then If (wsTCP.State <> sckClosed) Then wsTCP.CloseWinsock End If ‘ Open the connection wsTCP.Connect sServer, nPort StartTime = Timer ‘ Use the timer to determine if a connection cannot be made Do While ((Timer < StartTime + 2) And (wsTCP.State <> 7)) DoEvents Loop If (wsTCP.State = 7) Then Else Exit Sub End IfEnd If

Note: The program utilizes the CHR and STR functions to convert the data from binary to ASCII and back.
The highest value of a byte of data is 256. This is why we have to multiply the highest significant byte with 256

Interface:
Go back to Sheet1 and we can now put on the worksheet what we would like to see.

Start the Do-More Designer software.
Under the Project Browser select ‘System Configuration’
Make note of the IP address. If you are running the simulator then this is automatically filled in.
Ensure that the Enable Modbus/TCP Server is checked. Also make sure that the TCP Port Number is 502.

The sample PLC program will write values in the range from 0 to 4000. These values will be put in MHR 1 to MHR 10.

Here is the first couple of rungs of the PLC program. It will use clock bit flags to increment the MHR 1 channel. When it gets to the value above 4000, a move instruction will put a 0 back into MHR 1.
If input X0 turns on then the value in XW0 will be moved into MHR1 and the previous clock bit will not be in effect. Values will be between 0 and 4096. (12 bit resolution)

This is repeated with different internal clock bit flags up to MHR10.

Running the program will produce the following:

As you can see the Modbus TCP protocol is easy to implement with visual basic for applications.
Download the PLC program and Excel file.

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.

First Name:Last Name:Email address:

Leave this field empty if you're human:

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.

Utilizing the CX Server DDE Manager will allow us to provide a link to the information in the Omron PLC. This link can be placed on an Excel spreadsheet. Charts, graphs, etc. can be made from the data. We will create links on an excel spread sheet from a CQM1H and a CP1L PLC. The information will then be displayed as a bar graph comparing the first ten memory areas.

Dynamic Data Exchange (DDE) is a channel through which correctly prepared programs can actively exchange data and control other applications within Microsoft Windows. The DDE manager will allow us to set up all of the links.

This will start the DDE Manager and place an icon on your toolbar at the bottom of your screen. The application will run minimized.

Right-click on the minimized DDE Manager icon and select Project/New.

Assign a filename (ACC DDE.cdm) to the CX-Server project that you will create, and save it.

The create project will minimize to the taskbar. Right-click on the minimized DDE Manager icon and select Project/Edit.

This will call up the DDE Manager Project Editor. We can now add the PLC’s (Devices) and Points that we want to display.

Select File/New/PLC, or hit the PLC Icon on the taskbar.

Under Change PLC, we can now enter the information about how we are communicating to the programmable logic controller.

Device Name: – Name in which the DDE Manager will call the PLC
Device Type: – The model of PLC that will be connected
Network Type: – This is the communication method that we will be talking with the device.

Once we have the PLC information, we can now add points that will contain the information that we wish to retrieve from the units. Select File/New/Point or select the point editor icon to start the point editor.

On the Logical tab you can give a name (Or Change) to the point in the PLC to get. Select the Physical tab.

On the physical tab we set the following information:PLC: – This is the list of PLCs entered in the previous stepData Location: – The memory location that we want to read fromInternal Data Type: – This is the interpretation of the data that we are reading. (Example: Bit, Word, BCD, etc.)Command Modifier: – This is used if we need to Force Set / Reset the data location. This can be used to override the PLC program. Use with caution.
Press OK when finished setting the address.

Our point is now programmed. You will notice the symbols before the name of the point. This tells us at a quick glance what type of data we are looking at. Please refer to the CX Server Runtime manual for all of the symbol meanings.

Go back to the DDE manager and the points under the Project Editor. We can now select the first ten items in the list. Click the first one and then move to the last item. Hold the shift while clicking the last item will select all of them between.
Hit the DDE Link icon.

In Excel, we now paste the information onto the worksheet. (Ctrl + V) Right click the cell and select paste.

The information will now be displayed and updated on your worksheet.
The update time will depend on the interval set in the DDE Manager. Right-click on the minimized DDE Manager icon and select Update Interval…

We can also set individual point update times in the DDE link item. The default update time is set via the DDE Manager but we can also set the time in the individual points on the spreadsheet.
DDE Update Default Link:=CDMDDE|’C:\ACC DDE.cdm’!’\CP1L D0′
5 Second Update Link:=CDMDDE|’C:\ACC DDE.cdm’!’\CP1L D0,5′

In the Project Editor of the DDE Manager you can see the first 10 memory areas are being used. This is the yellow triangle with the lightning bolt symbol. (You will not be able to delete the point if it is in use.)

Calling up an excel file with the links embedded, will give you a Security Alert – Links warning. Select ‘Enable the content’ and then hit OK.

Here is an example of the finished excel file. We have 10 memory locations from each PLC listed. We have inserted a graph that will dynamically change when the values are read.Download the excel file here.

As you can see implementing the CX Server DDE Manager is not a difficult task. It provide a quick and efficient way to view the information that we need.

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.

First Name:Last Name:Email address:

Leave this field empty if you're human:

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.

In Part 1, we used VB6 to communicate from the computer to the PLC. We will now use Visual Basic for Applications (VBA) to accomplish the same task. NETComm will be the serial driver and Excel will be the program that we will use. Using Excel we will have access to the Excel Object Model so we can utilize worksheets, ranges etc.

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.

First Name:Last Name:Email address:

Leave this field empty if you're human:

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.