Help! Digital Scale on Serial With MSComm Controll

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GaryMasson
    New Member
    • Feb 2007
    • 5

    Help! Digital Scale on Serial With MSComm Controll

    Hi.

    Im pretty new to the mscomm controll and my problem is.

    Im trying to connecting a weighbridge to Com1 and when i try read the weight on the scale i get a mass of garbage coming trough.

    but when i unplug the loadcell and the indicator reads Error-02, it displays in the application but its not fixed it rolls through

    Iv bin batteling with this for a long time

    Any help or input would b much appreciated.

    Thanks

    G.Masson
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi. Is there an API that comes with this device? Is there an interface that comes with it? Is there a guide that comes with it to let you know how to format the data?

    Comment

    • GaryMasson
      New Member
      • Feb 2007
      • 5

      #3
      Originally posted by willakawill
      Hi. Is there an API that comes with this device? Is there an interface that comes with it? Is there a guide that comes with it to let you know how to format the data?
      hi.

      There are no manuals or anything that come with the device, or anything, when the mscomm reads from the device the data comes through scrambled and unreadable, as text, symbols, and numbers mixed.

      Thanks

      Comment

      • GaryMasson
        New Member
        • Feb 2007
        • 5

        #4
        I received the following information from the scale manufacturer. and i cannot make heads or tails of whats going on. as i said b4 i am totally new to the mscomm and serial communicaton. if you could please help me set up the code so the input goes into a text box via the oncomm facility. i really am green to all this.

        Merav – communication Protocol
        1. Shekel Merav models 1000, 2000, 3000, 3001, 4000 and Caesar 2000, 3000,
        3001,5000/1/3.
        Models use digital board ‘Tiger’, ‘Arnav’.

        2. The Merav has serial communication RS-232 to computer and printer.

        3. The communiction is bi directional from indicator to computer and vice versa.

        4. There are three communication modes:
        4.1 Response to weight request – “W” 57 H from host.
        4.2 Continuous weight transmmision.
        4.3 Manual transmmision – (Print).

        5. The indicator has additional 2 features.
        5.1 Zero the display in response to – Z – 5A
        5.2 Set the Tare in response to – T – 54.

        6. Programmable Baud Rate: Tiger 600 – 9600 Arnav 600 – 2400

        7. Programmable Parity: 0 - space
        1 - EVEN
        2 - Mark
        3 - ODD

        8. 7 or 8 data bits, 1 stop bit.

        9. The data is transmitted in ASCII code.

        10. Data String:
        10.1 Positive weight  (+) XXX.XXX CR
        10.2 Negative weight  (-) XXX.XXX CR

        11. Connector D type 25 : Pinout: Pin 2 - Data in
        Pin 3 - Data out
        Pin 7 - GND

        12. Commector D type9: Pinout Pin 2 - Data out
        Pin 3 - Data in
        Pin 5 - GND

        Comment

        • GaryMasson
          New Member
          • Feb 2007
          • 5

          #5
          Hi

          I sum1 directed me to a sample on the microsoft web. and received the following code:

          Const Xon = &H11
          Const Xoff = &H13

          Private Sub Form_Load()
          Form1.Caption = "App2"
          With MSComm1
          .CommPort = 2
          .Handshaking = 2 - comRTS
          .RThreshold = 1
          .RTSEnable = True
          .Settings = "9600,n,8,1 "
          .SThreshold = 1
          .PortOpen = True
          End With
          Text1.Text = ""
          Label1.Caption = "No input yet"
          End Sub

          Private Sub Form_Unload(Can cel As Integer)
          MSComm1.PortOpe n = False
          End Sub

          Private Sub MSComm1_OnComm( )
          Dim InBuff As String

          Select Case MSComm1.CommEve nt
          ' Handle each event or error by placing
          ' code below each case statement.

          ' This template is found in the Example
          ' section of the OnComm event help topic
          ' in VB help.

          ' Errors
          Case comEventBreak ' A Break was received.
          Case comEventCDTO ' CD (RLSD) Timeout.
          Case comEventCTSTO ' CTS Timeout.
          Case comEventDSRTO ' DSR Timeout.
          Case comEventFrame ' Framing Error
          Case comEventOverrun ' Data Lost.
          Case comEventRxOver ' Receive buffer overflow.
          Case comEventRxParit y ' Parity Error.
          Case comEventTxFull ' Transmit buffer full.
          Case comEventDCB ' Unexpected error retrieving DCB]

          ' Events
          Case comEvCD ' Change in the CD line.
          Case comEvCTS ' Change in the CTS line.
          Case comEvDSR ' Change in the DSR line.
          Case comEvRing ' Change in the Ring Indicator.
          Case comEvReceive ' Received RThreshold # of chars.
          Label1.Caption = "Input"
          InBuff = MSComm1.Input
          Call ParseChars(InBu ff)
          Case comEvSend ' There are SThreshold number of
          ' characters in the transmit
          ' buffer.
          Case comEvEOF ' An EOF character was found in
          ' the input stream.
          End Select

          End Sub

          Sub HandleInput(InB uff As String)
          ' This is where you will process your input. This
          ' includes trapping characters, parsing strings,
          ' separating data fields, etc. For this case, you
          ' are simply going to display the data in the text
          ' box.

          Text1.Text = Text1.Text & InBuff
          End Sub

          Sub ParseChars(ByVa l InString As String)
          Dim temp As String
          Dim x As Long
          Dim OutString As String

          For x = 1 To Len(InString)
          temp = Mid$(InString, x, 1)
          If temp = Chr$(Xoff) Then
          Label1.ForeColo r = vbRed
          Label1.Caption = "Xoff received"
          temp = ""
          ElseIf temp = Chr$(Xon) Then
          Label1.ForeColo r = vbGreen
          Label1.Caption = "Xon received"
          temp = ""
          End If
          OutString = OutString & temp
          temp = ""
          Next x
          Call HandleInput(Out String)
          End Sub


          Would this work for what am doing or are there sum modifications i need to make. i understand the basics behind the coding but im still not sure i know what im doing.

          Any help appreciated

          Thanks

          G Masson

          Comment

          Working...