在VB.Net中使用RS232需要关于称重软件的帮助 [英] Need Help about Weighing Software using RS232 in VB.Net

查看:153
本文介绍了在VB.Net中使用RS232需要关于称重软件的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人的好日子



我正在为我们的论文的附加功能开发数字秤。现在我在我的程序中遇到问题,串口工作正常但我收到了很多数据。我正在使用e-Gizmo的RS232称重传感器。有关硬件的文档,请访问: https://docs.google.com/file/d/0BxdLxDCD6HidMEs4ZVBRRWN0WVU/edit [ ^ ]



这是我拥有的实际硬件:

http:// i.imgur.com/4co1dVT.jpg

http://i.imgur.com /gG7uYFO.jpg





在我的简单程序中(只是为了看看我的设备发送给我的东西)我有这个输出:

http://i.imgur.com/Bnxv17j.png?1



我还想在可能的情况下删除设备给出的数字末尾的ES。



我只是希望标签在我从我的设备接收数据时持续改变,就像在这个视频上一样:

https://www.youtube.com/watch?v=W-d1TvMlBUs





现在这是我的代码



Good Day Everyone

I was developing a digital weighing scale for the additional features for our thesis. Now i am having a problem in my program, the serial port was working just fine but i receive many data from it. I am using an RS232 Weighing Sensor by e-Gizmo. Documentation about the hardware is here: https://docs.google.com/file/d/0BxdLxDCD6HidMEs4ZVBRRWN0WVU/edit[^]

Here's the actual hardware that i have:
http://i.imgur.com/4co1dVT.jpg
http://i.imgur.com/gG7uYFO.jpg


In my simple program (just to see what my device is sending me) im having this output:
http://i.imgur.com/Bnxv17j.png?1

I also want to remove the "ES" on the end of the number given by my device if possible.

I just want the label consistently change when i recieve data from my device like on this video:
https://www.youtube.com/watch?v=W-d1TvMlBUs


Now Here's my Code

Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim incomingByte As String = ""
Dim sec As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With SerialPort1 'Connection for my serial port
.Close()
.PortName = "COM3"
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.DtrEnable = True
.RtsEnable = True
.ReceivedBytesThreshold = 1
End With
SerialPort1.Open()
Label1.Text = SerialPort1.ReadExisting() 'read data from device

Timer1.Interval = 1000
Timer1.Enabled = True
sec = 0

End Sub

Private Sub readport()
Label1.Text = SerialPort1.ReadExisting() 'declaration for calling data in timer tick
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Call readport()
sec = sec + 1
Label2.Text = sec
End Sub
End Class







我使用的是Visual Basic 2013我的计划。

我希望有人可以帮助我,我非常渴望完成这个计划。 :(

先谢谢〜!




I am using Visual Basic 2013 for my program.
I hope someone can help me, im so desperate to finish this program. :(
Thanks in Advance~!

推荐答案

使用计时器migth不是最佳方法。使用听众方法 [ ^ ]。请注意缓冲区和使用的流量控制因此你可能需要将incomming数据视为chunk,并使用internak缓冲区.ES和空间可能是你需要在这个缓冲区中寻找的终结符。删除它是简单的文本处理。

将它放在Windows窗体应用程序中只是简单明了。
Using timer migth not be the best approach. Use listener approach[^] instead. Be aware of the buffer and the flow control used by the link. So you might need to treat incomming data as chunk, and use an internak buffer. ES and the space will be probably the terminator you will need to look for in this buffer. Removing it is simple text processing.
Putting this in a windows forms application is just straightforward.


这是使我的程序工作的代码〜!



Here's the code that makes my program works~!

Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim incomingByte As String = ""
Dim sec As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With SerialPort1 'Connection for my serial port
.Close()
.PortName = "COM3"
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.DtrEnable = True
.RtsEnable = True
.ReceivedBytesThreshold = 1
End With
SerialPort1.Open()
Label1.Text = SerialPort1.ReadExisting() 'read data from device

Timer1.Interval = 1000
Timer1.Enabled = True
sec = 0

End Sub

Private Sub readport()
Label1.Text = SerialPort1.ReadExisting() 'declaration for calling data in timer tick
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Call readport()
sec = sec + 1
Label2.Text = sec
End Sub
End Class





i想要那些帮助我的人!



关于这个问题的讨论可以在这里查看: http://www.dreamincode.net/forums/topic/370788-need-help-about-weighing-software-using-rs232-in-vbnet/ [ ^ ]


这篇关于在VB.Net中使用RS232需要关于称重软件的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆