reading a scale through a com port....
-
I need some help trying to capture a weight on a scale that is hooked to the PC via a COM port.
I would like to be able to have the user click a button and have the weight captured. Anyone done this before and could offer some code examples.
Your help would be greatly appreciated.
-
Have you installed an OPOS driver for the scale? If so then you can get a library of OPOS command objects, including a scale, from here.
-
Here's some code of mine used to claim and release an OPOS scale:
Public ReadOnly Property Scale() As OPOSScale
Get
Return Me._scale
End Get
End Property
Private Function ClaimScale() As Boolean
Dim result As Boolean = False
Me._scale = New OPOSScale
If Me._scale.Open(Me.BusinessRules.Register.ScaleName) = 0 Then
Dim retry As Boolean
Do
retry = False
Me._scale.ClaimDevice(1000)
If Me._scale.Claimed Then
Me._scale.DeviceEnabled = True
result = True
Else
Select Case MessageBox.Show(String.Format(My.Resources.ClaimScaleErrorString, _
Me.BusinessRules.Register.ScaleName), _
"TouchScreen Plus", _
MessageBoxButtons.YesNoCancel, _
MessageBoxIcon.Warning)
Case DialogResult.Yes
'Try again to claim the scale.
retry = True
Case DialogResult.No
'Continue without integrated weighing.
result = True
End Select
End If
Loop While retry
ElseIf MessageBox.Show(String.Format(My.Resources.OpenScaleErrorString, _
Me.BusinessRules.Register.ScaleName), _
"TouchScreen Plus", _
MessageBoxButtons.OKCancel, _
MessageBoxIcon.Warning) = DialogResult.OK Then
'Continue without integrated weighing.
result = True
End If
If Not Me._scale.Claimed Then
Me._scale = Nothing
Me.BusinessRules.Configuration.IntegratedWeighing = False
End If
Return result
End Function
Private Sub ReleaseScale()
If Me._scale IsNot Nothing AndAlso Me._scale.Claimed Then
Me._scale.ReleaseDevice()
End If
End SubHere's some code used to read the weight from the scale:
Private Sub scaleTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim scaleWeight As Integer = Me.GetScaleWeight()
If scaleWeight <> -1 Then
Me.Weight = scaleWeight / 1000
Me.weightText.Text = Me.Weight.ToString("f3")
End If
End Sub
Private Function GetScaleWeight() As Integer
Dim weightData As Integer = 0
My.Application.Scale.ReadWeight(weightData, 5000)
Return weightData
End Function -
Where and How can i find out if i have a OPOSScale Driver. Any other help you can provide on using this code would be great.
-
If you haven't installed one then you won't have one. Where did you get your scale from? The supplier should be able to provide the driver for you.
-
Scale is made by weighttronix and will be used for weighing packages in a pack application. It looks like your code is dealing more with Point of Sales systems so i am not even sure if mine is capable of having an OPOS driver. Could be wrong. If you have any other advice please let me know......Thanks
-
My advice, as it would be for any piece of hardware, is to speak to the supplier and ask them what interface(s) is available to speak to their hardware. If it doesn't support OPOS then they will tell be able to tell you. They will also be able to tell you what protocol(s) the scale supports and if there are any other drivers or components you can use to interface with the hardware. If you need to listen directly to the serial port then .NET provides a SerialPort class. That doesn't help you if you don't know what you're listening for though.
-
Just wanted to say thanks for the feedback. It was my frist time communicating with a scale, so it was a bit of a learning process which turned out to be alot easier then i thought with the built in commands the scale comes with. I was able to get the exact results i needed and now have a much better understanding of the product and the process of communicating with such objects.
-
hi all, how about if i want to read a scale through com port by using PHP?if anyone ever tried this? thanks a lot
-
The command to request the weight from a scale weight-tronix is: W[ENTER] *** ascii value of [ENTER] is 13 To save time ... You can easily do this with the software BillRedirect http://www.billproduction.com/billscalebalance/ This software inputs your Weight-Tronix scale data directly into your Windows applications or in MS Excel, MS Access. Jack
-
Hi all, I am using WTCOMM.OCX and having problems coding it in ASP.NET. I am using it with an
.NET forum discussion
-
edmonton female escort services near me
by canadapleasure (0 replies)
-
Bagaimana memenangkan $ 1,54 miliar dalam Mega Jutaan
by gametogelan (0 replies)
-
input integer from text file and output text file
by shmilon (0 replies)
-
cSharp stuck at exercise
by xander_Michiels (0 replies)
-
Need help in selected the Tax Audit Year from drop down menu and displaying results for the selected year
by citymumbai (0 replies)
Quick links
Recent activity
- arif ahmad replied to How to receive data in web ...
- William Thompson replied to What is the name of the Win...
- Sameera Piyadigamage replied to Point of Sale Developers: H...
- Scott Carline replied to 4 x C# Developers for large...
- Rajendra Dhakal replied to Restore SQL Server text dat...
- cloud rainda replied to How to convert between TS f...
-
Contribute
Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!
Web Development
Developer Jobs
Our tools
We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.