Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Go Back  Xtreme Visual Basic Talk > > > Problems getting a postage scale to read into vb project


Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2012, 01:27 PM
BrianCHarlie BrianCHarlie is offline
Newcomer
 
Join Date: Jan 2010
Posts: 15
Default Problems getting a postage scale to read into vb project


I am currently working on a project for my company for a new shipping system. The project is built around Connectship by ups, currently I am down to the part of trying to get my scale to read into my program and I can't seem to get the read out from the scale. The scale we have chosen to use is a Quartzell 7620 model, I have found the Manuel for this scale @ http://www.agri-tronix.com/pdf/7600_u.pdf.

The code I am using is as follows:
Code:
  Me.SerialPort1.Close()

        Me.SerialPort1.PortName = "COM1"
        Me.SerialPort1.BaudRate = 9600
        Me.SerialPort1.Parity = IO.Ports.Parity.Even
        Me.SerialPort1.DataBits = 8
        Me.SerialPort1.StopBits = IO.Ports.StopBits.One

        Me.SerialPort1.Open()

        Me.SerialPort1.Write(Chr(87) & Chr(13))
        Data = Me.SerialPort1.ReadExisting
I know the buadrate/parity is correct I've gotten that from the scale it self. I've tried different DataBits and different Stopbits also and i've tried the different COM's.

I know in the manual it says to:
Transmits weight and scale status whenever
ASCII “W” <CR> is sent by a remote device.

I've tried different combinations for this:
Code:
        Me.SerialPort1.Write(Chr(87) & Chr(13))
        Me.SerialPort1.Write(Chr(119) & Chr(13))
        Me.SerialPort1.Write(Chr(13))
        Me.SerialPort1.Write(Chr(87))
        Me.SerialPort1.Write(Chr(119))
I do know the scale works on the computer I've been trying to capture the weight from because our current system uses it.

Any help on this would great be appreciated , thanks
Reply With Quote
  #2  
Old 06-01-2012, 02:52 PM
Cerian Knight's Avatar
Cerian KnightProblems getting a postage scale to read into vb project Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

'ReadExisting' reads all immediately available bytes. It looks as if you are not giving the device time to respond to your request.

Perhaps have a look at the 'DataReceived' event example here:
http://msdn.microsoft.com/en-us/libr...atareceived#Y0
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 06-04-2012, 01:47 PM
BrianCHarlie BrianCHarlie is offline
Newcomer
 
Join Date: Jan 2010
Posts: 15
Default

Code:
Private Shared Sub DataReceviedHandler(
    ByVal sender As Object,
    ByVal e As SerialDataReceivedEventArgs)
        Dim sp As SerialPort = CType(sender, SerialPort)
        Dim indata As String = sp.ReadExisting()
        Console.WriteLine("Data Received:")
        Console.Write(indata)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Data As String

        Try
            Me.SerialPort1.Close()

            Me.SerialPort1.PortName = "COM1"
            Me.SerialPort1.BaudRate = 9600
            Me.SerialPort1.Parity = IO.Ports.Parity.Even
            Me.SerialPort1.DataBits = 7
            Me.SerialPort1.StopBits = IO.Ports.StopBits.One
            AddHandler Me.SerialPort1.DataReceived, AddressOf DataReceviedHandler

            Me.SerialPort1.Open()
            
           
             Data = Console.Read()
            TextBox1.Text = Data

        Catch ex As Exception
            MsgBox(ex.Message & " E X")
        End Try
    End Sub
I tried your link you suggested, once adding this to my code the only thing it's done so far is returned a "-1". I know the top part is set up correctly due to we have another program that interacts with this program. *Baud. Parity, Stopits etc etc)

Also with this code I am not sending the W <CR> it requested to get the info from the code not sure if that is the problem or not.
Reply With Quote
  #4  
Old 06-04-2012, 08:19 PM
Cerian Knight's Avatar
Cerian KnightProblems getting a postage scale to read into vb project Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

Indeed, send the W<CR> after the .Open and see what happens...
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #5  
Old 06-06-2012, 09:29 AM
BrianCHarlie BrianCHarlie is offline
Newcomer
 
Join Date: Jan 2010
Posts: 15
Default

I've tried sending:
Code:
Me.SerialPort1.Open()
        Me.SerialPort1.Write(Chr(87) & Chr(13))
        Data = Me.SerialPort1.ReadExisting
I've also tried sending:
Code:
Me.SerialPort1.Open()

        Me.SerialPort1.Write(Chr(87) &  Chr(0) & Chr(13))
        Data = Me.SerialPort1.ReadExisting
The reason I did this was because a previous program that uses this scale showed what weight command it sends. It uses "570D" which when I went to a ASCII translation table, I found out this was Hex for Wnull<Cr>. So it appears they send HEX to capture the weight.

Could it matter rather I send Hex or if I am sending Dec?

Could someone show me a sample of how to send the 57 0 D hex code to the SerialPort1?

-thanks
Reply With Quote
  #6  
Old 06-06-2012, 11:14 AM
Cerian Knight's Avatar
Cerian KnightProblems getting a postage scale to read into vb project Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

570D hex out the port is the result of sending as Chr(87) & Chr(13). The 'ReadExisting' must be in 'DataReceviedHandler' (sp?). That separate event will fire (in computer time) long after the .Write and any code that follows it. You have to think asynchronously. In fact the 'DataReceivedHandler' event may fire multiple time as various size pieces of the reply come in to the port at a slow pace. This requires concatenation of the response and parsing to see if the response is complete.

A simpler solution might be to not use the DataReceivedHandler at all and force the thread to System.Threading.Sleep (syntax?) for a reasonable time between .Write and .ReadExisting. This is not a normally recommended method, but might suffice for simple query/reply situations... if only to prove the device functionality and until you can implement more sound logic.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
 
Problems getting a postage scale to read into vb project
Problems getting a postage scale to read into vb project
 
-->