开发者

Scale Interface to VB Application

开发者 https://www.devze.com 2023-01-09 08:41 出处:网络
I have a few different scales that I\'m building a VB app for.Is there a universal serial port language that is common among weight scales that I can use to开发者_JAVA百科 import real-time weight into

I have a few different scales that I'm building a VB app for. Is there a universal serial port language that is common among weight scales that I can use to开发者_JAVA百科 import real-time weight into VB?


Yes, there's a standard protocol, formulated by the Scale Manufacturer Association. The spec download is here. Whether your actual scales follow that standard is an open question, check the small print in the datasheet or programming manual for them. It is rarely a real problem, these protocols are easy with simple command/response strings.


This is what i found reading the ZBI 2/ ZPL Manuals of Zebra. very usefull!!!!

1 rem ********************************************************
05 for i = 1 to 9 step 1
10 close #i
20 next i
30 open # 2 : name "SER"
40 open # 1 : name "ZPL"
1 rem ********************************************************
1 rem main program; send serial port a 'W' in order to get a weight
1 rem ********************************************************
50 do
60 do
70 sleep 1 ! sleep so scale is not bombarded with incoming
1 rem data
80 print # 2 : "W" ; ! semicolon ends sent W without a CRLF
1 rem ********************************************************
1 rem get response from scale; note that input requires a CRLF to be
1 rem entered
1 rem ********************************************************
90 input # 2 : a$
100 if a$ = "EXIT" then! back door exit - if EXIT is received, ZBI ends
110 close # 2
120 print #1: "^XZ"
130 close #1
140 end
150 end if
1 rem ********************************************************
1 rem loop until valid weight is received, then print on label
1 rem ********************************************************
160 loop while pos ( a$ , "000.00" ) = 1 or pos ( a$ , "?" ) = 1
170 print # 1 : "~SD25^XA^FS";
180 print # 1 : "^LH0,0^FS";
190 print # 1 : "^FO56,47^A0N,69,58^FDThis weighs^FS";
1 rem ********************************************************
1 rem print weight on label; & character concatenates strings
1 rem ********************************************************
200 print # 1 : "^FO56,150^A0N,69,58^FD" & A$ & " lbs^FS";
210 print # 1 : "^PQ1,0,0,N";
220 print # 1 : "^XZ"
1 rem ********************************************************
1 rem loop until weight is off scale, then repeat for next item
1 rem weighed
1 rem ********************************************************
230 do
240 print # 2 : "W" ;
250 input # 2 : A$
260 loop until pos(A$ , "000.00") = 1 or pos(A$ , "?") = 1
270 loop
0

精彩评论

暂无评论...
验证码 换一张
取 消