digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring
digital weighing scale monitoring digital weighing scale monitoring
digital weighing scale monitoring
Go Back  Xtreme Visual Basic Talk > > > digital weighing scale monitoring


Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2010, 08:21 AM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default digital weighing scale monitoring


I have a digital weighing scale I need to connect to the PC using RS232 communication port. Every time I weigh an object, automatically the result/weight will display in the the texbox control in Visual Basic Application
I use to receive data via a timer for continuous looping sequence output to a textbox. Things do goes bad, as it flicking all the way. I using a indicator from AD series which read data from load cell of a truck weight bridge. It there's any way to stop this flicking without effecting the continuous loop?
can any one help me ???
vb6 or vb.net any platform no problem please help me i want just solution
Reply With Quote
  #2  
Old 11-14-2010, 10:14 AM
Cerian Knight's Avatar
Cerian Knightdigital weighing scale monitoring Cerian Knight is offline
Polymath (in disciplina)

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

A TextBox will flicker. Instead, try using a Label. If that does not help, show us the relevant code.
__________________
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 11-14-2010, 12:13 PM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default

Private Sub Timer1_Timer()
If MSComm1.PortOpen = False Then

MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True

End If
MSComm1.InputMode = comInputModeText
strabc = MSComm1.Input
text1.text= strabc

End Sub
Reply With Quote
  #4  
Old 11-14-2010, 03:49 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Interval for timer?

What is the interval for the timer? If the timer is running faster than getting the data, this might be your flicker problem.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #5  
Old 11-14-2010, 04:11 PM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default

timer interval is 100
if change to 1000 then it will show full but not real time seems delay
Reply With Quote
  #6  
Old 11-14-2010, 09:12 PM
Cerian Knight's Avatar
Cerian Knightdigital weighing scale monitoring Cerian Knight is offline
Polymath (in disciplina)

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

When the Timer fires, how do you know that MSComm1.Input will read the entire string? Do this to see my point: Add the line 'Debug.Print strabc' after the line 'strabc = MSComm1.Input'.

How many blank or partial strings are printed?

My point is that this is not the normal way to read a serial port. There are two proper ways to do it:

1. If you are reading a fixed number of characters, then set MSComm1.InputLen to that number of characters and check the value of .InBufferCount to make sure at least that number of characters are present in the buffer. Hopefully the timer fires fast enough so that you can actually succeed in emptying the buffer, which may not occur at 9600 baud unless the balance is sending less than 10 readings per second. Unfortunately, this method presumes that the device is not autosending... so when you start reading, you may have a partial string. If you can send a command to the balance to stop and start sending, this method works fine.

2. Instead, use the OnComm event. It can be programmed to fire automatically when the correct number of characters are received (so no Timer is required).

In either of these cases, you may begin reading in the middle of a stream of characters. That is why I use OnComm configured to fire when any number of characters is received. There is actually no way to know how many will be there until the event fires and you check .InBufferCount. Store the characters in your own Public or Static buffer and when there are enough, display them and remove them from your buffer (being careful to leave unused characters in the buffer, since they will be needed later).

There are many examples of using MSComm OnComm on the forums. If you care to give it a shot and run into problems, let us know.
__________________
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
  #7  
Old 11-15-2010, 08:00 AM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default

the actual output from the weighing scale is like ww000.00kg or ww000.00lb
this is the format when i change timer interval to 1000 it will showing full string like ww000.00kg but it is not real time

when i change timer interval 100 it will show real time but flicking that means showing partial string like ww0 then 00 then 00 then kgw like that

i'm newbie in this field please help me with source code
Reply With Quote
  #8  
Old 11-15-2010, 11:32 AM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Easy Fix, But Not Proper Way

I don't know much about the mscomm, but an easy fix here would be:

Code:
Option Explicit 'Declare Private strFromComm As String Private Sub Timer1_Timer() 'Keep Adding New String To The String From Comm strFromComm = strFromComm & strPartialFromComm 'Check If String Done If Instr(strFromComm, "kg") > 0 Or Instr(strFromComm, "lb") > 0 Then TextBox.Text = Replace$(strFromComm, "ww") '= 0.00kg or 0.00lb 'Empty String strFromComm = "" End If End Sub

But you should take the time to read up like Cerian Knight said, you don't need a timer. Take the time to learn or you will be asking a lot of questions. I wouldn't copy the above and really try without a timer. Once you fill the string just start with the Instr() code.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #9  
Old 11-15-2010, 12:12 PM
Cerian Knight's Avatar
Cerian Knightdigital weighing scale monitoring Cerian Knight is offline
Polymath (in disciplina)

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

Here is Timer-less code to play with... I don't expect it to work 100%, but I trust you can figure it out with some study.
Code:
Option Explicit

Private Sub Form_Load()
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.RThreshold = 1 'Enable OnComm trigger on any number of characters received
MSComm1.PortOpen = True
End Sub

Private Sub MSComm1_OnComm()
Static WeightBuffer As String 'Create a permanent procedure level buffer
Dim Weight As String 'Temporary holding buffer
Dim FinishPos As Long
Select Case MSComm1.CommEvent 'Why was OnComm triggered?
Case comEvReceive 'OnComm was triggered because characters were received
    WeightBuffer = WeightBuffer & MSComm1.Input 'one or more characters were received, so concatenate them into buffer
    Do
        FinishPos = InStr(1, WeightBuffer, "lb", vbTextCompare) 'is lb in our string?
        If FinishPos = 0 Then
            FinishPos = InStr(1, WeightBuffer, "kg", vbTextCompare) 'how about kg?
        End If
        If FinishPos > 0 Then 'if we found either one then process it
            Weight = Left$(WeightBuffer, FinishPos + 1) 'put the piece we found in a temporary buffer
            WeightBuffer = Mid$(WeightBuffer, FinishPos + 2) 'store the unused data for future use
        Else
            Exit Do 'nothing found this loop so get out
        End If
    Loop
    If Len(Weight) > 0 Then 'Did we find anything to display?
        Text1.Text = Weight 'Display it
    End If
End Select
End Sub
__________________
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').

Last edited by Cerian Knight; 11-16-2010 at 10:49 PM. Reason: Missing 'End If'
Reply With Quote
  #10  
Old 11-16-2010, 11:21 AM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default

thank you very much dear it is working

thanks

now its working correct now it showing wn00239

then how to remove wn000
just show actual weight only like 239


sorry for asking these type help bcoz i'm newbie
Reply With Quote
  #11  
Old 11-16-2010, 12:45 PM
Cerian Knight's Avatar
Cerian Knightdigital weighing scale monitoring Cerian Knight is offline
Polymath (in disciplina)

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

Have a look at how ZaCkOX used Replace$. Just change 'ww' to 'wn' and 'strFromComm' to 'Weight'. Then take that that result and use the Val() function to remove the prepending zeros. Give it a shot an see what you come up with.
__________________
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
  #12  
Old 11-19-2010, 01:18 PM
maxhunter maxhunter is offline
Newcomer
 
Join Date: Nov 2010
Posts: 6
Default

ok let me try
thank you very much dear
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
digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring digital weighing scale monitoring
digital weighing scale monitoring
digital weighing scale monitoring
 
digital weighing scale monitoring
digital weighing scale monitoring
 
-->