我在它们之间使用两个Pic16f877a Mcus和Can总线接口。如何使用Microsoft Visual Studioc ++控制第二个Mcu? [英] I Am Using Two Pic16f877a Mcus And Can Bus Interface Between Them. How Can I Control Led On Second Mcu With Microsoft Visual Studioc++?
本文介绍了我在它们之间使用两个Pic16f877a Mcus和Can总线接口。如何使用Microsoft Visual Studioc ++控制第二个Mcu?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
第二个mcu有3个LED连接到它。我想用pc app控制它们并通过串口获取数据
请帮忙!
提前谢谢
解决方案
我们真的,真的,不能告诉你!
问题是双重的:首先是第二个mcu位 - 这意味着你将PC连接到第一个(并与第二个连接)或两者(和你需要理清你要解决的问题。
第二个问题是我们不知道PC和mcu之间会有什么样的通信 - 而且没有通用的通过串行端口发出命令的方法。多年来我用了几百种不同的方法,这只是表面上的问题! :笑:
所以首先要看看你对mcu(s)的说到底是什么以及你需要如何说它 - 这将是取决于物理连接和mcu内的软件。然后你可以使用像HyperTerminal这样的终端程序对它进行测试,以便在开始考虑将其编码为C ++(或任何其他语言)之前确保它可以正常工作。在这样的时候,创建一个CLR C ++应用程序,以便可以访问.NET Framework,并查看SerialPort类。
假设您正在连接PC
通过一个(可能是虚拟的)串口到第一个MCU
,你首先要确保这样的通信正确发生,因此我建议你先试试在第一个MCU上切换
。ON / OFF
aLED
一旦PC
与第一个MCU
之间的'串行通信'可靠,你就可以了可以完成第二项任务:通过CANBUS
在PIC
之间进行通信。您可以查看Microchip的应用笔记,以便完成这项工作。但请注意,据我所知,PICF877
微控制器没有集成的CAN
控制器,因此您可能需要额外的硬件
the second mcu has 3 leds connected to it. i want to control them using pc app and get data through serial port
please help!
thanks in advance
解决方案
We really, really, can't tell you!
The problem is twofold: first there is the "second mcu" bit - which implies you are connecting the PC to the first one (and it talks to the second) or both of them (and you need to sort out which you are addressing).
The second problem is that we have no idea what kind of communications between the PC and either mcu is going to be used - and there is no one universal way to issue commands over a serial port. I've used several hundred different ways over the years, and that's just scratching the surface! :laugh:
So start by looking at exactly what you need to "say" to the mcu(s) and how you need to "say" it - this will depend on the physical connection, and the software inside the mcu(s). Then you can test it using a terminal program like HyperTerminal to make absolutely sure it works before you start even thinking about coding it into C++ (or any other language). When you so, create a CLR C++ app so you can access the .NET Framework, and look at the SerialPort class.
Assuming you are connecting thePC
to the firstMCU
via a (possibly virtual) serial port, you have first to be sure that such communication happens correctly, hence I suggest you to first try to switchON/OFF
aLED
on the firstMCU
.
Once the 'serial communication' between thePC
and the firstMCU
is reliable you can accomplish the second task: the communication between thePIC
via theCANBUS
. You may check out Microchip application notes in order to make this work. However, please note, as far as I know thePICF877
microcontroller has no integratedCAN
controller, so you might need additional hardware.
这篇关于我在它们之间使用两个Pic16f877a Mcus和Can总线接口。如何使用Microsoft Visual Studioc ++控制第二个Mcu?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文