Receiving data from a weighing scale using RS232 with VB 6 App

You will need the Pyserial serial port library. If you are using Linux, it is usually in your repository, so you can install it from your package manager. (The Debian package name is python-serial, which of course will be the same for Ubuntu).

If you are using MS Windows, you can download it from here:
http://sourceforge.net/projects/pyserial/

The Linux version may work on Mac OS/X, but I don't anything about that.

Documentation is here:
http://pyserial.sourceforge.net/

The documentation is very good, so make sure to have a close look at it.

A brief summary though is you need to do the following:

First, configure the serial port. See the examples for that. The details of the configuration will depend on what you are trying to do.

Next, you read the serial port. How you do that depends on whether you are doing a "blocking" or "non-blocking" read. A blocking read will wait until it reads the specified number of bytes. A non-blocking read will just read what is currently available in the buffer. You make it blocking or non-blocking by how you set the time-out value (no time-out waits forever, a specified time-out will stop waiting after the set time).

If you are writing a simple command line program that just waits for input, then prints it and exits, then you may want to use blocking reads.

If you are writing a GUI program, then you want to use non-blocking reads and use a timer to "wake up" the program on regular intervals to check the serial port. When you are using non-blocking reads you need to check if the data is complete so you can if necessary concatenate the reply fragments until you accumulate a complete reply. The best way to do this depends on what the data is supposed to look like.

If you have more questions, then provide some more detail of what you are trying to do so I can direct the answers more precisely. It's actually pretty easy, but the details will depend on things like:

1) what the data looks like (fixed length, variable length, binary, ASCII, known delimiter or not, etc.),

2) how the overall program is supposed to work (simple script, large GUI program, log to a file, etc.).
 
Hi Dear

My name is AHmad from South Africa, I am also trying to use DS-788 weighing scale, in my vs 2003 vb.net application I can read the data in continous mode, now I want to read the data using some hand shaking signal.

pls tell me what is format should I send to computer to read the data
from DS-788 weighing scale. THx

Rgds
AHmad
 
A

abhijeet roy

Hi,

I am able to get continues data from digitizer to pc through RS232. I need to get data in request mode. I mean whenever i will press enter key the digitizer data will come to the system....for that what is the vb6 code. pl. help me.

Regards
Abhijeet
 
sir,

i want to know how can i connect my weigh scale such that if the certain weight is reached my motor stops working..???
 
E

Eamonn Wallace

> i want to know how can i connect my weigh scale such that if the
> certain weight is reached my motor stops working..???

Some indicators have limits relays or setpoint relays you could use those if your indicator has them.

With an app you need to read the weight value from the indicator and when it "hits" a predetermined level you send a "signal" to the motor or interrupt the power supply

How you read the weight value depends entirely on the type of indicator

---
Regards
Eamonn Wallace
 
While it can be done through PC it works out much more expensive. It would be best if you buy an indicator with relay contacts and setpoint facility which can be easily used by you . We do manufacture these acuweigh at g mail .com
 
Hi M Griffin
I am trying to get a reading from my weiging scale using Python GUI.
I am using a Kern pfb weighing scale with the following specs: baudrate : 9600, 8 bit, parity_none. And it displays in ASCII.

Would you be able to send me your code, so I could refer to it and work on it please ?

Anish
 
This is how to read data on serial port.

Can you please tell me how could we send data through RS 232 serial port to out door display unit by using vb 6 code.
thanks and regards
rizwan

>Start searching for specific scale serial output format.
>Using MSCOMM32 control from VB6 like:
>
>MSComm1.CommPort = 1
>MSComm1.Settings = "9600,N,7,2"
>MSComm1.InputMode = comInputModeText
>MSComm1.InputLen = 0 'all buffer from port
>MSComm1.NullDiscard = True
>'Use in Sub MSComm_OnComm() all string conversion and port
>reading.
 
I have done weigh scales with Python rather than MS-VB, so I can't give you cut and paste code examples. However, I assume from your description of your problem in your first sentence that you don't know how to extract the number from the ASCII text output.

With the type of scales I have worked with, the text output before and after the weigh reading is not always exactly the same, so it required a pattern matching algorithm to extract the weight. I used a regular expression to find and extract the weight, which was then easy to convert from text to an integer. I don't know what sort of regular expression library support you have in MS-VB6, but in Python it took only half a dozen of lines of code to read the scale.

One other point is that the scale output didn't have any message delimiters, so the only way to tell if the scale was done sending was to wait for a fixed period of time and then try to extract the weight. This worked fairly well provided you wait longer than the minimum time you really need. You probably need to set up a test to print out the exact message from the scale, and then try shorter and shorter time delays until you start cutting the message off (then double this time to have a margin).
Hi sir,
I'm getting weight from com port by using pyserial library, i got the weight in utf-8 text on command prompt output but i want to get the weight output in text box can you help me with that i know for adding text box i had to use tkinter library but i need the little trick
Your help in this regard is really appreciated
 
Top