RS232 通信 - 我可以用它来创建稳态信号吗?

发布于 2024-07-08 00:58:31 字数 140 浏览 8 评论 0原文

老实说,我认为答案是“不”。 不过,我想听听第二个意见。 基本上,我需要一个微控制器设备向另一个微控制器设备发送稳定的信号,但它们之间的通信使用 RS232。 所以我认为我必须创建/更新通信消息才能让它执行我想要的操作。

你怎么认为?

In all honesty, I think the answer is "no;" however, I want to get a second opinion. Basically, I need one micro-controller device to send a steady signal to another one, but the communicate between them is using RS232. So I think that I have to create/update the communication messages to get it to do what I want.

What do you think?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

極樂鬼 2024-07-15 00:58:31

您应该能够将 DTR(数据终端就绪)、引脚 20 或 DSR(数据集就绪)、引脚 6 等设置为高电平,并将其保持为稳态信号。 这就是调制解调器/终端检测另一端是否有准备通信的设备的方式。 这完全取决于您通过驱动程序对硬件的访问级别。

[编辑] 这不涉及发送数据,尽管您仍然可以使用 TX/RX、引脚 2 和引脚 2 来执行此操作。 3.

维基百科上的 RS-232 参考

You should be able to set something like DTR (Data Terminal Ready), pin 20, or DSR (Data Set Ready), pin 6, high and keep it there as your steady-state signal. This is how modems/terminals detect that there is a device on the other end that is ready to communicate. It all depends on what level of access you have to the hardware through your driver.

[EDIT] This doesn't involve sending data, although you could still do that using TX/RX, pins 2 & 3.

RS-232 Reference on wikipedia

海未深 2024-07-15 00:58:31

你的意思是固定电压? 不是方波吗? (字母 U)中断命令怎么样(如果你想称其为命令)?

当然,如果有帮助的话,您可以使用其中一根控制线...或者您是否专门在 TX 中寻找某些东西?

You mean a fixed voltage? Not a square wave? (the letter U) What about a break command (if you want to call it a command)?

Certainly you can use one of the control lines if that helps...Or are you specifically looking for something out of the TX?

别闹i 2024-07-15 00:58:31

如果问题是“我可以改变 Tx 线路的 DC 状态”,那么答案是可以要求许多 uart(包括 PC 中的 uart)创建“中断”条件,这与正常空闲相反线路的状况。

因此,您可以打开和关闭“break”并像这样切换线路。

If the question is "can I alter the DC state of the Tx line", then the answer is that many uarts (including the ones in PCs) can be asked to create a 'break' condition, which is the opposite to the normal idle condition of the line.

So you can turn 'break' on and off and toggle the line like that.

樱娆 2024-07-15 00:58:31

如果您不介意类似突发的界面,那么也许可以做类似的事情。 一个微控制器可以传输一个字节,另一个微控制器可以对该字节执行某些操作并将其作为响应发送回来。

It might be possible to do something like that, provided you don't mind a burst-like interface. One micro could transmit a byte and the other could do something to that byte and send it back as a response.

窗影残 2024-07-15 00:58:31

如果您可以控制线路的两端,则可以将 rs-232 tx 和 rx 线路转换为常规逻辑线路以提供该信息。

然而,在大多数情况下,每一端都会定期发送一个状态信息字节,其中包含 8 个可能的数字值 - 提供更多的状态信息。

每次收到消息时,接收端的计时器都会重置,如果计时器超时,则说明消息花费的时间太长,您可以对丢失的状态消息采取行动。

正如其他人指出的那样,如果您使用硬件流控制,您也可以使用一些状态行,尽管在许多情况下这些行没有实现,因此这可能不是一个选项。

-亚当

If you can control both ends of the line, you may be able to turn the rs-232 tx and rx lines into regular logic lines to give that information.

In most situations, however, each end periodically sends a byte of status information that contains 8 possible digital values - gives much more status information.

A timer on the receiving end is reset everytime a message is received, and if the timer times out then the message has taken too long and yo can act on missing status message.

As others have pointed out, if you're using hardware flow control you have some status lines available as well, though in many cases those lines aren't implemented so that may not be an option.

-Adam

小糖芽 2024-07-15 00:58:31

稳定信号可能意味着:

  • 稳定的字符突发: 保持发送缓冲区整
  • 行保持高电平或低电平: 不发送任何内容或发送连续中断

Steady signal could mean:

  • steady burst of charaters: keep the send buffer full
  • line held high or low : send nothing or send continual breaks
樱花落人离去 2024-07-15 00:58:31

I think it depends to a large extent on the UART that you are using, e.g. link text, and the level of access you have to it under software. If you check the data sheet there are often ways of controlling most of the pins directly for testing purposes, but you will need to go at it from a pretty low level.

At a higher level, tvanfosson's answer is pretty much the way i'd do it.

无畏 2024-07-15 00:58:31

虽然第一个答案是正确的,但可能无法在许多微控制器上使用此技术(使用 DTR 或 DSR),因为它们可能没有这些信号(许多微控制器可能只有基本的 RX/TX 线路,并且您经常会遇到如果您需要额外的控制/状态线,请使用其他 I/O 端口 但是,一切都不会丢失,许多 RS232 控制器允许您将 TX 线设置为“标记”或“空间”(即将 TX 线设置为逻辑高电平)。或低)。这样您就可以检查接收器上的 RX 线是否处于标记电平或空白电平。

While the first answer is correct it may not be possible to use this technique (using DTR or DSR) on many micro controllers as they may not have those signals (many micro controllers may just have the basic RX/TX lines and you would often have to use other i/o ports if you wanted extra control/status lines. However, all is not lost, many RS232 controllers allow you to set the TX line to 'mark' or 'space' (i.e set the TX line to logic high or low). This would allow you to get your steady state signal. The RX line on the receiver can be checked to see if its at mark or space level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文