Access Balance Standalone Program Version: 1.0 (for DOS) Files: fgscale.c (main), fgscale.h, mettler.c, sartorius.c, getopt.c scale16.exe (executable) readme.txt Date: January 6, 1999 Description: This program is to read the weight of clod on balance. The balance is hooked up to PC computer through serial port. The communication protocol between PC and balance is dependent on the different model and type of balance, so the communication module for balance is created from separate files. Currently, this package includes modules for balances of Mettler PM300 and Sartorius LC420. The operator can select balance (default Mettler), port (default COM2), unit (default gram), and measured range (default 1 - 5). The weight value will be recorded in a file (default filename "weight.dat"). The operator can give the file name on the command line. For the inquiry of usage, enter /?, followed the executable command. Compiler: Watcom C_C++ version 10.6. Operation: The main program contains the parameter selections for the command line which include: /b balance: m for Mettler scale (default), and s for Sartorius scale; /c port #: 1, 2, 3, and 4 for COM1, COM2 (default), COM3, and COM4, respectively; /f file: user's filename for weight record (default weight.dat); /u unit: weight unit (default grams); /L bound #: lower bound for weight (default 1); /U bound #: upper bound for weight (default 5). These parameters selected follow the command line. After hit the return key, the display is as follows: ----------------------------------------------------------------------------- | OPERATING INSTRUCTIONS: | | | | 1. Put clod on scale. The unit is g. | | 2. Enter the can number. | | 3. Press , and wait for weight. | | (clod must weigh between 1.00 and 5.00 (g)) | | | | To quit press 'q' or . | | READY TO HIT ENTER KEY | ----------------------------------------------------------------------------- After hit the return key, the PC prompt the user for sample #. Then hitting the return key again, the sample number and weight value are displayed. Configuration: The main program calls a function of get_mass corresponding to a specific balance which is hooked up to the PC on serial port. This function returns the value of weight. There needs an individual module for a balance configuration. The initialization settings for the balances are put in fgscale.h file, so force the balances in the same settings: SETTINGS_1 (_COM_9600 | _COM_EVENPARITY | _COM_STOP1 | _COM_CHR7). For Mettler (PM300), the data format of balance interface is 1 start bit, 7 data bits, 1 parity bit, and the stop bit automatic (1 RX/2 TX). The balance setting is: S. ALL (momentary value for data output, factory setting Stb: next stable value) b. 9600 (factory setting 2400 baud) P. -E- (factory setting even parity) PAUSE 1 (factory setting 1 second transfer rate to data receivers) AU off (factory setting off) The routine for interfacing Mettler PM300 first initializes the specified COM port and settings as mentioned above, then enables the register of data available interrupt. After pulsing the balance handshake line and sending a print command (control word "ACK"), the routine goes into a loop to read characters from the balance. During running in the loop, if getting an interrupt for a new charcter available, the routine takes the character in the array. Otherwise, the routine waits for the next character coming in until timeout break from the loop. If the transmission errors happen associated with the COM port, the data from the balance would be retransmitted. Because some unwanted spaces and possibly other unwanted characters may be taken or 'D' is received if the data on balance is not stable, the routine finally checks the characters received to strip the unwanted characters from the array or retransmits the data if 'D' is found. The final correct string transmitted is converted into the float type for the return value. For Sartorius (LC420), the data format of balance interface is the same as that of Mettler PM300 except the stop bits (1 or 2) defined by user. The balance setting is the factory settings except: 9600 baud (code 517) Even parity (code 524) W/o stability for data output (code 611). The routine for interfacing Satorius LC420 is the same as that for Mettler PM300 except the control word of "ESC P CR LF" and data stable sign which can be obtained by ckecking wether the unit characters are received. If all the characters in locations 12, 13 and 14 of the array are empty, the data is unstable. Wiring Diagram for COM connector: The handshake modes both for Mettler and Sartorius are working in hardware handshake. After the PC asserts DTR and sends a control command to the balances, the balances transmit the weight data to the PC. There are a couple of wiring diagrams for DTE device. The following are the COM wiring diagrams for Mettler PM300: Diagrams of Figures 1(a) and (b) are provided by the manufacturer. Both diagrams are working properly by testing. The wiring diagram currently used (Figure 1(c)) is the one modified according to Figure 1(a). It also works well as follows: Mettler "Standard" RS-232 Connector DB25 Connector ---------------------------------------------------------------- Description Pin # Pin # Description Brown Tx Data 12 -----------------> 3 RxD Input Green Rx Data 2 <----------------- 2 TxD Output White Signal 13 <----------------> 7 Signal Ground Ground Yellow handshake 3 <----------------- 20 DTR Output |<---- 4 RTS |----> 5 CTS |----> 6 DSR +----> 8 DCD ---------------------------------------------------------------- (a) Connection between DB25 and DB25 Mettler "Standard" RS-232 Connector DB25 Connector ---------------------------------------------------------------- Description Pin # Pin # Description Brown Tx Data 12 -----------------> 3 RxD Input Green Rx Data 2 <----------------- 2 TxD Output White Signal 13 <----------------> 7 Signal Ground Ground Yellow handshake 3 <----------------- 4 RTS Output |<---- 20 DTR |----> 5 CTS |----> 6 DSR +----> 8 DCD ---------------------------------------------------------------- (b) Alternative connection between DB25 and DB25 Mettler "Standard" RS-232 Connector DB25 Connector ---------------------------------------------------------------- Description Pin # Pin # Description Brown Tx Data 12 -----------------> 3 RxD Input Green Rx Data 2 <----------------- 2 TxD Output White Signal 13 <----------------> 7 Signal Ground Ground Yellow handshake 3 <-----------|----- 20 DTR Output +----> 5 CTS ---------------------------------------------------------------- (c) Currently used connection between DB25 and DB25 Figure 1. Mettler Data-output Cable Digrams The wiring diagrams for Sartorius scale are shown in Figure 2. The diagram currently used is Figure 2(b) for DB9 connector of COM. Sartorius "Standard" RS-232 DB25 Connector DB25 Connector ---------------------------------------------------------------- Description Pin # Pin # Description TxD output 2 -----------------> 3 RxD Input RxD Input 3 <----------------- 2 TxD Output Ext. Signal 4 <----|-----------> 7 Signal Ground Ground 14 <----+ CTS Input 5 <----------------- 20 DTR Output DTR Output 20 ------------+----> 5 CTS Input |----> 6 DSR +----> 8 CD Chassis Ground 1 <------ ** No connection ---------------------------------------------------------------- (a) Connection between DB25 and DB25 Sartorius "Standard" RS-232 DB25 Connector DB9 Connector ---------------------------------------------------------------- Description Pin # Pin # Description TxD output 2 -----------------> 2 RxD Input RxD Input 3 <----------------- 3 TxD Output Ext. Signal 4 <----|-----------> 5 Signal Ground Ground 14 <----+ CTS Input 5 <----------------- 4 DTR Output DTR Output 20 ------------+----> 1 CD |----> 6 DSR +----> 8 CTS Input Chassis Ground 1 <------ ** No connection ---------------------------------------------------------------- (b) Connection between DB25 and DB9 Figure 2. Sartorius Data-output Cable Digrams ** CAble shield should be connected to one side only, usually the transmitting side.