如何通过USB总线将数据发送到微控制器 [英] How to send data over USB bus to a microcontroller

查看:98
本文介绍了如何通过USB总线将数据发送到微控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我有两个主要问题要问专家.现在,这是情况.

我有一个微控制器,它是pic 18f2550. 18f2550支持USB,可通过PC进行高速数据传输.

首先,我想问的问题是:

我如何将数据通过数据发送到pic,以便它可以进行简单的I/O操作(如led闪烁)……据我所知,.Net框架不支持轻松实现代码的类.那我该怎么办?

第二个问题:例如,如果我想制作一个数据采集卡通过USB来获取数据,我是否需要为该设备编写驱动程序?如果是这样,我该怎么做?用C ++创建库并将它们嵌入C#项目中?

我需要任何建议,所以任何想法都会受到赞赏.

最好的问候...

Hey everyone.

I have 2 main questions to ask to the experts. Now, here is the situation.

I have a micro controller which is a pic 18f2550. 18f2550 supports USB to communicate in high rates of data transfer over PC.

First, question I want to ask is:

How can I send data over data to pic, so that it can make simple i/o operations such as led blinking... As far as I know, the .Net framework doesn''t support a class to implement code easily. So What should I do?

Second question: if I want to make, for example a data acquisition card, that gets data over USB, do I have to write a driver for that device? if so, How can I do that? Making libraries in C++ and embed them in C# project?

I need any kind of suggestions guys, so any idea will be well appreciated.

My best regards...

推荐答案

某些PIC确实直接支持USB,但是如果您能够修改硬件,则可以使用FTDI设备.它可以通过并行8位端口或PIC COM端口(通常为RC6,RC7)连接到PIC,两种方法都有FTDI器件.此解决方案的好处是,对于大多数常见的O/S,都有出色的USB设备驱动程序.在Windows方面(我相信也可以使用Linux驱动程序),有简单的API函数可以将数据读取/写入设备(FT_Open(),FT_Read(),FT_Write()等).在同一驱动程序中也有COM端口仿真,因此您可以像Windows COM端口一样与USB设备通信.在PIC端,使用中断从并行端口或COM端口读取数据.

参见www.ftdichip.com

问候,

geoff
Some PICs do support USB directly, but if you are able to modify the hardware, then use a FTDI device. It can connect to the PIC by a parallel 8 bit port or by the PIC COM ports (usually RC6, RC7), there are FTDI devices for both methods. The good thing about this solution is there are excellent USB device drivers for most common O/S. On the Windows side (I believe Linux drivers are also available), there are simple API functions to read/ write data to the device (FT_Open(), FT_Read(), FT_Write(), etc). There are also COM port emulation in the same driver, so you can talk to the USB device like it was a Windows COM port. On the PIC side, use interrupts to read the data from the parallel port or COM port.

See www.ftdichip.com

regards,

geoff


FTDI是USB设备.它们提供了出色的设备驱动程序.
如果使用异步接口(RC6,RC7)将FTDI芯片连接到PIC,由于波特率的原因,它将比并行接口慢. FTDI网站上有一篇文章介绍了如何优化数据速率,但是您无法获得完整的USB速率,因为我认为它将受到片上缓冲存储器和PIC时钟速度的限制.
FTDI are USB devices. They are supplied with excellent device drivers.
If you connect the FTDI chip to the PIC using the async interface (RC6, RC7) it will be slower than a parallel interface, due to the baud rate. There is a paper of the FTDI website that tells how to optimize data rate, however you will not get full USB rates as I think it will be limited by the on-chip buffer memory and the PIC clock speed.


这篇关于如何通过USB总线将数据发送到微控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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