如何使用我的 C# 应用程序重置我的 Arduino Mega2560? [英] How do I reset my Arduino Mega2560 with my C# application?

查看:26
本文介绍了如何使用我的 C# 应用程序重置我的 Arduino Mega2560?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 Arduino IDE 在启动/退出时由内置串行应用程序自动重置,原因是

I noticed the Arduino IDE automatically resets on startup/exit by the built in serial application due to

FT232RL 的硬件流控制线 (DTR) 之一通过 100 纳法拉电容器连接到 ATmega1280 的复位线.当这条线被置位(拉低)时,复位线下降足够长的时间来复位芯片.

one of the hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega1280 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip.

我注意到我的串行 C# 应用程序不会发生这种行为.我希望重置功能与我的 C# 应用程序一起使用.我没有做什么让我的 Arduino Mega 被我的 C# 应用程序重置?

I noticed that behaviour does not happen with my serial C# application. I would like the reset feature to work with my C# application. What am I not doing to get my Arduino Mega to reset by my C# application?

Arduino 和 C# 的工作代码:

通过将一根电线从 PWM 端口 12 连接到 RESET 端口,我在大约 5 分钟内使其工作.在 Arduino 上,我检查了传入的 SerialEvent3 上的文本 RESET.当找到 RESET 时:

I got it working in about 5 minutes by hooking up a wire from PWM Port12 to the RESET Port. On the Arduino, I checked for the text RESET on the incoming SerialEvent3. When RESET is found do:

pinMode(7, OUTPUT);  
digitalWrite(7, LOW);

至于 C#,它很简单:

As for as the C# it was as simple as:

if (serialPort1.IsOpen)
{ 
    serialPort1.Write("RESET"); 
}

重置似乎按预期工作.

推荐答案

从 .NET SerialPort 类开始,DTR 对我来说效果很好.

DTR works fine for me from the .NET SerialPort class.

只需设置属性:

port.DtrEnable = true;

如果您在 WinForms 设计器中使用 SerialPort,我注意到了不同的默认值,但是 DtrEnable 实际上是 true(默认情况下)从控制台应用程序使用它时.

I have noticed different defaults if you use the SerialPort in the WinForms designer, but DtrEnable is in fact true (by default) when using it from a console app.

这篇关于如何使用我的 C# 应用程序重置我的 Arduino Mega2560?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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