التسميات

الجمعة، 30 يناير 2015

PC serial communication with KERN 572 digital balance

In the following tutorial I will show how to make data logging for digital balance KERN 572 using Excel VBA (I will be exposed to LabView later). You probably may need this feature in cases where you are interested to measure instantaneous or average inlet/outlet/net mass flow rate for a tank or container placed on the balance. Also, you may use this feature to measure evaporation rate of certain fluid at ambient temperature. Measuring forces like lift force -for example- of an airfoil at different angles of attack. 

The first application in my work where this feature was useful was a refrigerant charging station.


The second application for which I needed this feature was measuring mass flow rate of water bleeding from a Cylindrical acrylic tank used in WBT measurement device.



The following instructions are already stated in the manual of the balance with some modifications and illustrations I have added.


5. Interface RS 232 C 


5.1 Technical Data 


ƒ8-bit ASCII Code 

ƒ1 start bit, 8 data bits, 1 stop bits, no parity bit 
ƒBaud rate adjustable to 2400, 4800, 9600 (default), and 19200 
ƒMiniature DIN plug is necessary type MP-371/C 7 
ƒWhen working with an interface correct operation is secured only if the corresponding KERN-interface-cable (max. 2 m) is used. 


5.2  Description of the jack 

3 pins are only used for communication with KERN 572 digital balance




Pin 2: transmit data

Pin 3: receive data 
Pin 5: signal ground

A prolific USB to RS 232 converter may be used for modern computers and laptops. The picture below shows SIEMENS converter cable I already used successfully. 





If you don't have the driver of this converter cable you can download here

5.4  RS 232 C Data output via interface RS 232 C 


5.4.1 General information


As a condition for the data transfer between the balance and a peripheral device (for instance printer, PC ...) both devise have to be set on the same interface parameter (for instance baud rate, parity ...).


There are 4 methods for the data output via RS 232 C:


1. Data output via PRINT-key (see 5.4.2). 

2. Data output, after having loaded the balance, by setting AUTOPRINT (see 5.4.3). 
3. Continuous data output by setting AUTOPRINT PC (see 5.4.4). 
4. Data output by transfer of remote controls (see 5.4.5) 

5.4.2 Data output via PRINT-Key

The printing process can be released by the PRINT-key. In this case the settings AUTOPRINT and AUTOPRINT PC should be deselected. 

5.4.3 AUTOPRINT


The setting AUTOPRINT is in the PRINTER-routine, and there it can be selected or deselected. When AUTOPRINT is active the actual weighing value will be sent via the RS 232 interface when the balance has been unloaded and then loaded after having achieved 

the stability. 

5.4.4 AUTOPRINT PC


The setting AUTOPRINT PC is in the PRINTER-routine, and there it can be selected or deselected. When AUTOPRINT PC is active the actual weighing values will be sent continuously via the RS 232 interface. 


5.4.5 Remote Control: 


The following functions can be released by the remote controls that will be transferred as ASCII signs to the balance. 

"t" Tare. 
"w"  a weighing value (or unstable) is sent via RS 232 interface. 
"s"  a stable weighing value is sent via RS 232 interface. 

If the balance receives the command w or s, it acts without printing delay. 


5.4.6 Description of the data transfer: 


Structure of each data transfer: 


Without Numerator: 


Bit-Nr.  1   2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18

            B* B B  B  B  B  B  B  B 0    .    0    B    g   B    B    CR  LF
                               
B*:  =  Blank or %in the range of zero point. 
B, 0, ., g:  =  Blank or weighing value with unit, depending on the load on the 
weighing plate. 

CR:  =  Carriage Return 

LF:  =  Line Feed 

Each mass measurement is represented by a string buffer of 18 ASCII characters, each character is represented by 8-bits. See the animation below to see how the string buffer is composed. 


Data buffers are separated by the line feed LF character (New line or Enter).




I made the last animation using this website

6. Options 


6.1 Printer 


With the serial data output RS 232 a printer can be connected. The printout shows the weight in grams. When the counting mode is selected the number of 

pieces or the weight is printed. 

When the percent mode is selected, the percentage or the weight will be printed. Press The PRINT-key to print weighing results. Select the enumerator to number the weighing continuously. 


Turn off the balance or use the CLEAR function to Reset the enumerator to (000)


Setting sampling time in Excel VBA:


The sampling time may be adjustable or not. The following are the cases:


(A) If the PRINT key is used manually then the sample time will not be set, because if it is not pressed then nothing will be sent to PC (time out).


(B) If the AUTOPRINT mode is used then the sampling time should be more than or equal 2 seconds which is the typical stabilization time.


(C) If AUTOPRINT PC mode is activated then the sampling time will depend on Baud rate. The following formula is used to calculate the minimum sampling time based on Baud rate:


Minimum sampling time [Sec.]= Baud rate [bps]/(No. of data bytes in each measurement/string buffer * 10)


In AUTOPRINT PC MODE, in case of setting sampling time larger than minimum sampling time, each received data packet/batch will contain multiple measurements at a time.


(D) Sending "w" character to the balance (simulating the PRINT key action) then receiving measurement at the same time.


Configuring the balance:


Set Baud rate


Set the printing mode


Set enumerator



Communication procedure:


You have to set in Excel the following parameters before establishing the communication:


COM port number - No. of start bits - No. of data bits - No. of stop bits - Parity bit - Baud rate - String buffer length


Then you will open COM port (open channel)


Retrieve data - write to file


Close COM port at the end of measurement (close channel)




Communication using A&D WinCT Data Communication software:



A&D WinCT delivers technological achievements with the utmost simplicity.  A&D's new WinCT software includes two programs (RSCom and RSKey) and is specifically designed for use with A&D Balances equipped with an RS232C interface and your PC.  The software is compatible with Windows, Window 95, 98 & NT.

Addition: 

1. The software can be used successfully with KERN digital balance. 
2. The software is compatible with windows XP and windows 7.

You can download the software from here



WinCT software package has three programs: RSCom, RSWeight, and RSKey. After installation you can copy the program folder and use RSKey as a portable software on any PC.



RSKey can read only the balance without writing to it. All what you have to do is to open an Excel sheet, then open RSKey, configure serial communication parameters, and finally click "Start" button. The software will paste data directly in the Excel sheet.

Caution: Don't click "Start" button when windows explorer in the background!!!

Press "Start" button only when "MS Excel", "Notepad", "MS Word", or any text processing software is in the background. 

Fast case study:

I have tested the drainage time of water from the acrylic tank used in WBT device with the filling cap once, and without the cap another time.

With cap (small ventilation area):

Drained water: 1300 gm = 1300 mL
Drainage time: 265 seconds = 4 minutes: 25 seconds

Without cap (large ventilation area):

Drained water: 1298.1 gm = 1298.1 mL
Drainage time: 157 seconds = 2 minutes: 37 seconds

الثلاثاء، 20 يناير 2015

Refrigerator optimum loading plan

Keywords:  Optimum loading plan, Best loading plan, Loading plan optimizer, Cargo optimizer, Loading box optimizer, Store box optimizer, 2D bin packing problem, 2D box packing

In testing, frozen-food storage or food-freezers in refrigerating appliances are loaded with lean-beef simulant called "test packages". Rectangular test packages used in loading plan according to IEC 62552 - ISO 15502 have three basic sizes (with height 50 mm):

Size A (represents 1 kg): 200 mm x 100 mm

Size B (represents 0.5 kg): 100 mm x 100 mm

Size C (represents 0.25 kg): 100 mm x 50 mm

Loading plan is almost based on the two dimensional area of horizontal surface intended for loading. Once the basement of the loading plan is found, then this plan can be repeated one on the top of another in upward direction.

The following Excel toolbox which is included in cold-appliances add-in is used to calculate the optimum loading plan according to IEC 62552 - ISO 15502 standard for a given rectangular loading box because loading is an iterative procedure.



The user-form looks like the following capture:


The following are some iterations (from 63 iteration) of loading plan of box of size 480 mm x 380 mm and two round corners of radius 16 mm.

Box boundaries may be physical or load limit line. The common cases are:

- Four physical walls in chest freezers or upright freezer drawers

- Three physical walls and one load limit line, door, or flap

Iteration 1:



Iteration 28:


Iteration 61:


The last one is optimum loading plan as it has the maximum load with maximum number of 1 kg packages 200 mm x 100 mm. The following conditions are achieved according to the standard:


13.3.2.1 The food freezer compartment or cabinet and any frozen-food storage compartment or cabinet shall be filled with as many test packages as it can hold, the test packages having previously been brought to a temperature approximately equal to the classification temperature of the compartment.


13.3.2.2  On each horizontal surface intended for storage, the largest possible number of stacks of 1-kg test packages, having a base of 100 mm ×200 mm, shall be made. 


NOTE: A stack is a number of packages piled on top of one another (faces with largest surface horizontally); the term does not necessarily imply that packages form a “straight” pile. 


Stacks of packages shall be placed in direct contact with horizontal loading surfaces and vertical surfaces  (this applies to 0,5-kg as well as 1-kg packages). 

Test packages priority: If necessary, the loading may be completed by stacks having a base of 100 mm ×100 mm made up of 500-g packages laid flat, and then finally by stacks having a base 50 mm ×100 mm made up of 125-g or 250-g packages, also laid flat, or else 25 mm ×100 mm ×200 mm 500 g packages. 

13.3.2.4 Stacks of packages shall be placed in direct contact with the horizontal loading surfaces and vertical surfaces except in the following cases:
a)  When the vertical surface is the inner surface of a door, the stacks shall be loaded as follows: 

–  if there is a marked load-limit line, the packages shall be loaded up to that line (see Figure 16 a)); 

–  if there is no load-limit line, but a natural load limit, the packages shall be loaded up to that limit.

13.3.2.6 Free air spaces of 15 mm minimum (calculated from the nominal dimensions of the test packages), as far as possible equal, shall be left between adjacent stacks of test packages.

The use of spacers to maintain free air spaces between stacks of test packages is permissible provided that the spacers are of the smallest possible cross-section and of the lowest possible thermal conductivity and are placed in such a way that they do not significantly interfere with normal air circulation. 


الأربعاء، 17 ديسمبر 2014

Excel VBA: Get source data GetSourceData

After searching a lot for the solution of this problem, I want to introduce it. For charts, MS Excel does not has a native function to get the source range address for series collection, but we can -with a trick-  get some useful information about the source range using string processing.

The following two pictures show the layout of series collection formula. I noticed that sometimes I get the first layout and sometimes I get the other one (I don't know exactly when I get each one). The difference between them is just the quotation marks of sheet name. The series collection formula has four data:

(1) Data series name: represented by address or string 
(2) Independent variable (x-axis) values: represented by address or defined name
(3) Dependent variable values (y-axis) represented by address or defined name
(4) Index of data series (read only value)

The first layout (with quotation marks):
The second layout (without quotation marks):
The following code demonstrates how to get source sheet name for the second layout (Excel 2007)

Sub GetSeriesCollectionData()

' Get the formula of the first data series
SeriesCollectionFormula = Charts("Chart1").SeriesCollection(1).Formula

' Some string processing...
StartPos = InStr(SeriesCollectionFormula, "(")     'Index of first "(" found in the string
EndPos = InStr(SeriesCollectionFormula, "!")    'Index of first "!" found in the string

' Extracting the name of source worksheet using Mid function
SourceWorkSheet = Mid(SeriesCollectionFormula, StartPos + 1, EndPos - StartPos - 1)

'Display the source work sheet in a message
MsgBox ("The name of source work sheet of this chart is : " + SourceWorkSheet)

End Sub



السبت، 11 أكتوبر 2014

PLC logic operations


The following are some simple logic operations for PLC programming. X: Input, M: Output. Simulations are conducted on Fatek PLC simulator.

If X0=1 and X1=1 then M0=1

Table of probabilities:


X0
X1
M0
0
0
0
1
0
0
0
1
0
1
1
1








If only X0=1 and X1=0 then M1=1

Table of probabilities:

X0
X1
M1
0
0
0
1
0
1
0
1
0
1
1
0












If X0=1 or X1=1 then M3=1

Table of probabilities:

X0
X1
M3
0
0
0
1
0
1
0
1
1
1
1
1






 If  one only of contacts X0 or X1 equals 0 then M5=1

Table of probabilities:

X0
X1
M5
0
0
1
1
0
1
0
1
1
1
1
0





السبت، 12 يوليو 2014

Tools sorting method for 5S

In workshops and production lines we always need to sort our hand and power tools and keep them in fixed places to reach them quickly and easily without wasting time and effort in looking for them and this what is called 5S: Sort, Straighten, Shine, Standardize, and Sustain. The following are some concepts showing how to allocate a fixed place for each tool.

First of all, imagine that we have two pieces of tools or objects like in the image below.


The first method is to use a foam insert or a vacuum-formed plastic inserts. This method is the best as it provides good fixing and cushioning for tools.


The second method is to make a monochromatic color shadow for objects with high contrast (white board and black shadow). This shadow board is easy to recognize from far distances.


The third method is to make a thick outer contour lines for objects. 


The forth method is to print colored pictures for objects, so the objects will be placed on their pictures. Pictures may be 1:1 scale, or may be a reduced or enlarged scale. It is preferred to have a picture with an orthogonal view for the object as it will be viewed on the board.


The fifth method is to use name labels only, so tools will be placed above or under their labels. This method is the worst method to use for sorting tools specially if a tool has more than one name, or if there are different tools having the same name but different sizes (like wrenches, screw drivers, drill bits,... etc).  


The sixth method is stick labels on both tools and board. Each label will have a unique code.

Method number 7 is to use samples or demos. This method is almost used with consumable objects like tubes, hoses, tapes, screws, paints, electric terminals, wires, cables, plugs, blades, drill bits, ...etc. For example, in case of adhesive tapes, you can cut a small square piece of each tape and paste it on the board. 



Notice that more than one of these methods can be used at the same time. 




الخميس، 19 يونيو 2014

"CoolProp" fluid thermodynamic properties Excel add-in

After searching over the internet for "Engineering Equation Solver EES package for Excel", I came through some other alternatives for Engineering Equations Solver thermodynamic properties calculator:

RefProp: Open source (free)

CoolProp: Open source (free)


XProps: Commercial package


1. CoolProp


Download the package (zipped file) from the following link


http://sourceforge.net/projects/coolprop/files/CoolProp/


1.1. Installation in Excel:


Unpack the zip file you downloaded to any folder on your hard disk "New folder"

Open "New folder\dist_temp\windows_superpack\Excel and DLL" and copy its contents

Create a folder in your partition C: "C:\CoolProp". It should be placed in C: partition even if it is not your system (default) partition.

Paste the copied files to the folder "CoolProp" you have created

Copy CoolProp.xlam to the default directory of Excel add-ins. To know the default directory of Excel add-ins in your PC, just create a new book and save it as Excel add-in file (*.xlam). Copy the address and discard saving this file.


Open Excel options and select add-Ins



Press "Go..." button shown highlighted by the red box in the image above and you will get a window like below. Check the "CoolProp" add-In so it will be automatically loaded each time you open excel.




It is done...


This is a demo after installation of add-in (see equation in equation bar). You can use cell references instead of direct values for sure.



and this is a snapshot after I have implemented this add-in in my Ref Analysis add-in




1.2. Comparison with EES:


1.2.1 Fluid properties


For real fluids the following are the available properties in EES and CoolProp (units displayed are as displayed in EES):



Property name
EES
CoolProp
Accentric factor
●
●
Conductivity [W/m.K]
●
●
Cp [kJ/kg.K]
●
●
Cv [kJ/kg.K]
●
●
Density [kg/m3]
●
●
Dipole [debye]
●

Ek_Lj [K]
●

Enthalpy [kJ/kg.K]
●
●
Entropy [kJ/kg.K]
●
●
Fugacity [kPa]
●

IntEnergy [kJ/kg]
●
●
isIdealGas [-]
●

MolarMass [kg/kmol]
●
●
P_crit [kPa]
●
●
P_sat [kPa]
●
●
Phase$
●

Prandtl [-]
●

Pressure [kPa]
●
●
Quality [-]
●
●
Sigma_LJ [m]
●

SoundSpeed [m/s]
●
●
SpecHeat [kJ/kg.K]
●
●
SurfaceTension [N/m]
●
●
T_crit [C]
●
●
T_triple [C]
●
●
Temperature [C]
●
●
V_crit [m3/kg]
●
●
Viscosity [kg/m.s]
●
●
VolExpCoef [1/K]
●

Volume [m3/kg]
●




1.2.2 Reference state

The reference state used in CoolProp is International Institute of Refrigeration IIR reference which assumes that the specific enthalpy of saturated liquid fluid Q=0 at 0 C equals 200 kJ/kg and the specific entropy at the same conditions equals 1 kJ/kg.K . From the other side EES uses three reference states IIR, Normal Boiling Point NBP, and ASHRAE, but they can be manually-correlated by adding constants in CoolProp.

1.2.3 Properties abbreviations (names) in CoolProp

Property name
Properties CoolProp codes
w
Thermal conductivity
L
Cp
C
Cv
O
Density
D
Specific enthalpy
H
Specific entropy
S
Internal energy
U
Molar mass
molemass
Critical pressure
pcrit
Pressure
P
Quality
Q
Sound speed
A
Gibbs function
G
Surface tension
I
Critical temperature
Tcrit
Triple temperature
Ttriple
Triple pressure
ptriple
Minimum temperature
Tmin
Ozone depletion potential
ODP
Temperature
T
Dynamic Viscosity
V

Later, I will update this post and illustrate the notations, units.