Serial data acquisition in the Checkweigher Management Information System. Tutorial.
Serial data acquisition in the "Checkweigher Management Information System"
We require a "Checkweigher Management Information System" compatible software to acquire the serial data from our present checkweighers completely automatically without the need for operator intervention.
We would like reports to be viewed and printed on demand at any time based upon products, batches, production runs, lines and time periods.
We would like the software to hold a copy of the original data in raw format, to make the system "Trading Standards" friendly format to provide us with trace ability and a paperless environment to view current production and historical analysis.
We would like information from the multiplexor to flow into either Microsoft Access or Microsoft Excel fields in a systematic order.
Fig.1. Serial data acquisition. Hardware overview
Fig.2. Serial data acquisition. Raw data captured in the HyperTerminal
It is assumed that:
You have configured all communication parameters (baud rate, number of data bits, flow control etc) in the data logger and you are able to receive all data without communication errors.
The image (Fig.1) above shows a data flow. As an example, for a single report, all non-printable characters with a code less than 20 Hex are selected for display. The indicated radio buttons are set as shown below.
Fig.3. Serial data acquisition. Serial data view setup
If your data flow is fast, then ASDL will not split your data into separate lines and you will get one long line on the screen. For this reason, it is necessary to tick the "Wrap words" tick box. This effectively adjusts the line length to the width of the window (Fig.4, pos #1)
Fig.4. Serial data acquisition. Data logger window view setup
Click the "OK" button and attempt to receive data from a serial port. You should get something like the image below.
Fig.5. Serial data acquisition. Raw data blocks.
This is the other view of the data received. Notice that all non-printable characters were replaced with their code i.e. #1E, #1F and #1B. It is clear from the data screen above, that the data block (within the green rectangle) begins with #1E#1F#1B (underlined by blue) ends with #0D#0A#0C (underlined by red).
We are now ready for configuring of the modules. First, select the "ASCII data query and parser" plug-in (Fig.6a, pos. #1) from a drop-down list. Then, enable a parsing option for data received (Fig.6a, pos. #2) and select the necessary data export plug-ins. The DDE server (Fig.6b, pos. #3) will help to check the accuracy of the parser's configuration. The "Local database" plug-in will write the data to a Microsoft Excel file (Fig.6b, pos. #4).
Pic.6a. Serial data acquisition. The data parser plug-in.
Pic.6b. Serial data acquisition. Data export plug-ins.
Now, please, open a configuration window of the ASCII parser and query plug-in (click the "Setup" button near a drop-down box fig.6a, pos.1). The dialog window will appear on the desktop (fig.7).
Fig.7. Serial data acquisition. Parser configuration window.
The configuration process should be very simple if you have examined your data flow in the data logger window (Fig.5). You should type in the same as in the data logger window in fields 1 and 2. Field #1 marks the beginning of the data block and the field #2 marks the end. In the example, our start marker is #1E#1F#1B, and the end marker is #0D#0A#0C. The values to be typed in here are as underlined in red in Fig.5 above. Because the report in this example is very long, then we should increase the "Timeout" value (pos.#3) to prevent losing of reports.
You can simply add a date/time start to your data export. You need to activate the "Add date/time stamp" option in the pos. #4.
The next tab is a very important part of the parser configuration. The data parser uses this information for data extraction from the data block. In the example, the report contains 23 data items (see Fig.2) namely: BATCH NO, date and time, unit no and so on, which should be separated out to different variables. Later, these variables will be used in the data export and will be placed in different columns of our Excel spreadsheet.
Fig.8. Serial data acquisition. Parser items.
Any new items may be added by clicking the "Add item" button (Fig.8, pos.#7). Before adding an item the program will ask you about an item description. You can type any characters here, which will help you to remember a variable's content. For this example all 23 variables with their corresponding descriptions have been added. You can import all data parsing items from a file by clicking the button at pos. #8 on Fig.8. The file with all variables you can download here (right-click over the link and select the "Save target as..." menu item).
Each parser item has a number of properties:
All other items have identical parameters, except a data type and a regular expression.
In the next tab, you can specify basic format options as per (Fig.9). If you had specified the data type "String" in the item's parameters, then the first two options allow you to remove blank spaces from a value. Our called and caller number contain blank spaces at the start of a value. The second option allows you to convert the date time string to a field with the date time data type. We specified YYMMDDHHNNSS here, according to the specification above. For a detailed description of formatting characters, please, see the help file.
Fig.9. Serial data acquisition. Format of items.
Other options are unnecessary in our case, because all our items do not have the date or time data type.
Click the "OK" button and close the parser configuration window. Then click the "OK" button in the options window.
Now that our parser is ready it is time for testing it. Connect your device and power it on if necessary. Check to see if you are able to receive a data block from the specified serial port. If the parser had been correctly set up, then you should see All parser items names and their values (Fig.10) in the DDE server window below.
Fig.10. Serial data acquisition. DDE server window.
All parser items are now ready for export to an Excel file.