与vb.net中的微控制器进行串行通信 [英] serial communication with microcontroller in vb.net

查看:145
本文介绍了与vb.net中的微控制器进行串行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用COM端口1将vb.net程序中的整数发送到微控制器.
我已经在vb中编写了以下代码,但无法正常工作.微控制器端口上没有任何显示.微控制器一次接受8位.

I want to send integers from a vb.net program to my microcontroller using COM port1.
I had written the following code in vb but it is not working.Nothing appears on microcontroller ports.Microcontroller accepts 8 bits at a time.

SerialPort1.Open()
SerialPort1.WriteLine(xco)


xco是我的整数变量.在串行窗口的属性中,我已将baud rate设置为9600,将timeout设置为500,将stop bit设置为1. 有人可以帮我吗?


xco is my integer variable.In properties of serial window i had set the baud rate as 9600 and timeout as 500 and stop bit as one.
Can someone please help me...

推荐答案

要做的第一件事:

打开超级终端(或类似端口),设置com端口,波特率,bpc和停止位.
尝试使用键盘与您的微控制器对话.如果可以,请继续执行第二步.如果不起作用,请先找出原因.可能是控制线(RTS/CTS等),可能是速度问题,可能是微控制器未通电!首先开始工作.

然后使用完全相同的参数设置一个SerialPort对象.尝试发送字节(不一定是整数)并获得一些合理的响应.然后,您可以从那里开始.

不要尝试立即进行编码:请确保您可以先谈谈.否则,您将引入不确定的因素!
First thing to do:

Open HyperTerminal (or similar) set up the com port, the baud rate, bpc and stop bits.
Try to talk to your microcontroler using the keyboard. If that works, then move on to step two. If it doesn''t work, then find out why first. It may be control lines (RTS/CTS etc.) it may be speed problems, it may be the microcontroller isn''t powered on! Get that working first.

Then set up a SerialPort object with exactly the same parameters. Try sending bytes (not an integer, necessarily) and get some sensible response. You can then work on from that.

Don''t try to code immediately: make sure you can talk first. Otherwise you are introducing factors you aren''t sure about!


这篇关于与vb.net中的微控制器进行串行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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