Developer Friendly USB: A Detailed Look At How Easily A USB-based Device Can Be Developed

2024-07-24 FTDI CHIP Official Website
USB-UART chip,USB chip,FT232BM,FT245BM USB-UART chip,USB chip,FT232BM,FT245BM USB-UART chip,USB chip,FT232BM,FT245BM USB-UART chip,USB chip,FT232BM,FT245BM

As the popularity of USB continues to increase, so does the desire and need for easier ways to develop USB-based products. Lots of integrated circuit manufacturers are now offering USB serial engines and integrated USB/Microcontroller chips. The use of these devices assumes you will take on the burden of all required software development. 


The development of most new USB-based products begins with the laborious and frustrating task of writing a device driver. This task can easily consume the bulk of a developer’s free time (nights and weekends that is) trying to stay on schedule. This task can be simplified somewhat by using the Human Interface Device (HID) class, or it can be eliminated altogether by using FTDI’s royalty-free drivers. The only catch with using FTDI’s drivers is that they only work with FTDI’s chips. FTDI offers two versions of their USB chips (USB to UART and USB to parallel FIFO) as well as two versions of their drivers (Virtual Com Port and DLL). 


This article will describe a complete USB-based product design--start to finish-- for acquiring temperature data from two digital temperature sensors. The USBUART version of the FTDI device (FT232BM) will be used as well as their Virtual Com Port drivers


Microcontroller

As mentioned above, FTDI (www.ftdichip.com) makes both a parallel and a serial version of their USB chip. Connection to the parallel version (FT245BM) requires 8 data lines and 4 handshaking lines to properly implement the interface. What if you only have 2 free port pins on your microcontroller? The serial version of their chip presents an industry standard RS232 interface (RX, TX, CTS, RTS, etc.) for easy connection to a legacy RS232 device. All that is typically needed to connect a legacy RS-232 device to the FT232BM is a garden-variety receiver/driver IC (MAX-232, HIN232, etc.) and a DB9 connector. Using the 2 FT232BM USB-UART chip instead of the parallel version frees up 10 micro port pins for use in your project.


For this project, we will interface the FT232BM directly to an 8-pin, PIC 12F629 Flash-based microcontroller. Two of the micro’s pins connect to a 20MHz crystal, two are used for power and ground, two for communicating with a host PC (TX and RX), and two for talking to a pair of Dallas Semiconductor DS18B20 digital temperature sensors. 

Fig.1

The micro only has 1K of ROM and, surprisingly, the firmware for this project only required 54% of the available ROM thanks to PCM, a highly-optimized C compiler from CCS (www.ccsinfo.com). Since the micro is Flash based and a programming header is included in the design, the firmware can be easily updated (or replaced by your own code) without having to remove the micro from the board. And that’s significant for this design since the micro we’ve selected is in an SOIC8 surface-mount (i.e. no socket) package.


All that is needed to interface to each DS18B20 is a single port pin and a pull-up resistor. Neither the micro nor the DS18S20 ever drive the port pin high. The only time it is high is when neither is driving it low. An open collector (or in this case, open drain) port pin on the micro would be perfectly suited for this application. However, since this design doesn’t have one available, the software will have to pick up the slack. The functionality of an open drain output can be easily simulated by toggling the port pin between input and output-low. When the port pin is configured as input, the pull-up resistor pulls the data line high.


The design presented in this article shows how to interface two temperature sensors to the USB port. It could have just as easily demonstrated how to interface two switches, two outputs (for driving relays, LED’s, etc.) or a mix of the two. Also, a larger micro like the 16F84A could have been used for more port pins.


Programming the 12F629 Flash-based micro is accomplished via a 5-pin header that consists of power and ground, clock, data, and a programming voltage of about 12.5 volts. For this project, I used the EPIC Plus Programmer (www.melabs.com). You will have to make your own programming cable using both 5-pin and 10-pin headers in order to make the connection to the programmer. Keep in mind that Sensor 2 must be disconnected from the board during firmware upload so that it does not interfere with the programming process.


Virtual Com Port Drivers
The Virtual Com Port (VCP) drivers make your USB-based product appear to your Windows application as though it is connected to an RS-232 port. Your application simply opens a com port and sends data as though it was going to the DB9 connector on the back of the PC. If your application opens a com port that is assigned to the VCP drivers (via the Device Manager window), then the data bytes sent are redirected to the USB scheduler and then out the USB port. Any data returned to the host via USB simply appears in the buffer that was created when your application opened the RS-232 port.


Some things you won’t have to worry about are USB related details like endpoints, token packets, data packets, handshake packets, ACK’s, NACK’s… the list goes on and on. The VCP drivers do a splendid job of hiding these details from the user. The desired baud rate, number of data bits, stop bits, and parity selection for the data sent from the FT232BM USB chip to the target electronics can be set by the host application. Setting these parameters in the host application has no effect on transmitted USB data packets.


The maximum data rate that can be expected using the FT232BM is somewhere in the neighborhood of 1-3 megabaud (depending on how your circuit is configured), and all standard baud rates are supported. Applications that require data rates approaching 8 megabits per second fall more under the purview of the FT245BM and DLL drivers.


Firmware
The complete microcontroller C source code listing for this project can be downloaded from www.dlpdesign.com/usb/temp.html. The main() function is shown in Figure 2. As you can see, in this implementation there are only two commands for communicating with the microcontroller. The first is a “ping” command for detecting the presence of the board and microcontroller. This command can be used by the host application to help locate the COM port to which the micro is connected. The second command calls a function that reads the temperature data from both of the temperature sensors, sends 18 bytes of temperature data back to the host, and calls another function [start_convert()] that starts the next temperature conversion. Note that the start_convert() function is called at power up so that temperature data is ready for read the first time the “R” command is issued.

Fig.2 Source code for main()

The code in main() will wait, continuously resetting the watchdog timer, until Port Pin GP3 is pulled low by the USB chip indicating the start of an incoming serial character. The getc() function is then called to receive the character. Error correction (crc, checksum, etc.) could be added if desired to make the interface more bulletproof.


The DS18B20 temperature sensors take up to 750 milliseconds to perform a full 12-bit temperature conversion and write the data to their internal scratch pad memory. For this reason, there is no reason for the host application to issue the “R” command more than about once per second. Additional firmware could be added to the micro to allow for 9-bit temperature conversions so that much faster temperature measurements (less than 95 milliseconds) can be performed in the DS18B20. Keep in mind that faster readings come at a price. As the speed goes up, the accuracy goes down. (Refer to the DS18B20 datasheet for details.)


Windows Software
The source code for simple Visual C++ and Visual Basic programs that demonstrate how to read the temperature data from the 12F629 micro can be downloaded for free from the dlpdesign.com website. The code will request the temperature data once per second, convert the 9 bytes of data returned from each sensor to a floating point value, and display those values. Figure 3 shows a screen shot of this program:

Fig.3 Visual C++ and Visual Basic Demonstration Program

Also available is a Windows application that will read the data and both chart the data graphically and log the data to the hard drive. This program can be purchased for a shareware level fee of $20 ($13 with another purchase). Figure 3 shows a screen shot of this software

Fig.4

Fig.5 DLP-TEMP1 

PCB Figure 6 shows the printed circuit board for this project and just how small a complete USB product can be made using the USB chips from FTDI. The bottom layer of this 2-layer board is mostly a ground plane to help keep the noise and EMI to a minimum. The board comes with one sensor. The sensor is not soldered to the board so that the user has the option of locating the sensor at a distance from the board using Category 5 cable. This design has been successfully tested with both sensors located 200 feet (Figure 5) away from the board using Category 5 cable.

Fig.6 Tested with 200 feet of Cat 5 cable

Two pairs of wires in the Cat 5 cable are required for the connection; one pair for power and ground, and the other pair for data and ground. If using both sensors, you can either connect them to the board using one cable for both sensors (since the cable has 4 pairs), or 2 cables if the sensors are to be placed in different locations.


Since this design incorporates a male Type A USB plug, it can be directly plugged into the PC’s USB port. If you want to bring the board up to your workbench while still communicating with the board, then a USB extension cable can be used.


Power Considerations
The 5 volts from the USB port is used to power both the circuitry on the PCB as well as the two temperature sensors. This does not mean to imply that the USB port can supply unlimited current to your external circuitry. The maximum current that can be drawn from the port is 500 milliamps. This assumes that the board has been configured as a high-powered device. This also assumes that the board is connected to a port on the PC or powered hub. If connected to a selfpowered hub, then the maximum power available for use is reduced to a total of just 100 milliamps. 


 When the board is first connected to the host PC, the maximum current that can be drawn is 100 milliamps. After enumeration is complete the board can draw the full 500 milliamps. To prevent drawing excessive current before enumeration, this design includes a MOSFET transistor to switch the power 8 going to the micro and sensors. The switch is controlled by the PWREN# signal from the FT232BM. 


Conclusion
While FTDI’s drivers and chips do relieve the developer of having to learn 95% of what can be learned about USB, I still recommend getting a good book on the topic like Jan Axelson’s USB Complete Second Edition (www.lvr.com) if for no other reason than to become familiar with the complexity of USB and to develop realistic expectations of USB’s capabilities. For instance, USB Specification 1.1 proclaims a data rate of 12 megabits per second. In reality, the actual data throughput for a full speed device in bulk transfer mode is closer to a maximum of 8 megabits per second once you add all of the overhead involved in making USB usable and reliable. 


 If your project calls for higher data throughput or if you would prefer working with a parallel interface and have the required number of micro port pins available, additional reading on using the FT245BM is available on-line at dlpdesign.com/pub.shtml. 


USB-based product development really is within reach for those of us (myself included) who don’t have the ability to develop device drivers. While I’m almost always intrigued by the challenge of learning something new, the ever-approaching deadline always seems to win out over my desire to take on a new grand venture. So if you want to learn how to write device drivers (a noble venture indeed, and one that might well increase your salary once mastered!), then pick up a book on the topic of WDM device drivers and start reading. If you want to get your new USB-based product to market on time, then have a look at FTDI’s chips. 

授权代理商:世强先进(深圳)科技股份有限公司
技术资料,数据手册,3D模型库,原理图,PCB封装文件,选型指南来源平台:世强硬创平台www.sekorm.com
现货商城,价格查询,交期查询,订货,现货采购,在线购买,样品申请渠道:世强硬创平台电子商城www.sekorm.com/supply/
概念,方案,设计,选型,BOM优化,FAE技术支持,样品,加工定制,测试,量产供应服务提供:世强硬创平台www.sekorm.com
集成电路,电子元件,电子材料,电气自动化,电机,仪器全品类供应:世强硬创平台www.sekorm.com
  • +1 赞 0
  • 收藏
  • 评论 0

本文由三年不鸣转载自FTDI CHIP Official Website,原文标题为:方便开发者使用的USB,本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。

评论

   |   

提交评论

全部评论(0

暂无评论

相关推荐

MULTI-PROTOCOL USB: An All-Serial Data Acquisition System – No Microcontroller Required!

In the arena of “easily-implemented USB“, the folks at FTDI have done it yet again by releasing their new, dual-channel FT2232C IC. This new chip offers two interfaces for connection to user electronics as compared to its predecessors (the FT232BM and FT245BM) that only have one. Instead of being fixed in hardware as only serial (USB-UART) or parallel (USB-FIFO), both channels of this new chip are configurable for either serial, parallel, or one of several other new interface modes of operation.

设计经验    发布时间 : 2024-08-30

Bit-bang USB--Perhaps The Easiest USB Interface Yet!

Considering the complexity of the USB interface, using a USB port to toggle an LED is alittle like using a sledgehammer to drive a small nail. But that is exactly what this articleis going to show you how to do.

设计经验    发布时间 : 2024-07-20

Silicon Labs(芯科科技) CP2104 单芯片USB转UART桥接器数据手册(英文)

型号- CP2104-B01-GM,CP2104,CP2104SX0805GMR,CP2104-F03-GM,CP210X,CP2104-B01-GMR,CP2104EK,CP2104-F03-GMR

数据手册  -  SILICON LABS PDF 英文 下载

FT232BL/BQUSB UART IC

型号- MAX3245CAI,MIC2025-2BM,SP481,ADM213E,IRLML6402,MI0805K400R-00,SP213EHCA,FT232BM,240-1035-1,FT232BL,93C46,FT232BQ,FT232BQ-XXYY,93C56,93C66,MCP1700,FT232B,93LC46B,MAX213CAI,SP491,FT232BL- XXYY,SP213ECA,MAX3245,NDT456P

数据手册  -  FTDI CHIP  - Version 2.2  - 07th Nov 2011 PDF 英文 下载

FT245BM USB FIFO ( USB - Parallel ) I.C.

型号- MIC2025-2BM,TC55,IRLML6402,FT245BL,FT232BM,240-1035-1,FT8U245AM,FT245BQ,93C46,93C56,93C66,FT245BM,CSTCR6M00G15,93LC46B,NDT456P

数据手册  -  FTDI CHIP  - Version 1.7  - December 2005 PDF 英文 下载

EVAL232R FT232RL USB to RS232 Evaluation Module

型号- FT232RQ,FT232R,EVAL232R,MM232R,FT232BM,FT232RL

数据手册  -  FTDI CHIP  - Version 0.90  - 2018/01/02 PDF 英文 下载

FTDI Drivers Installation Guide for Windows 10/11 Application Note

型号- FT4232HP,FT4232H,FT4222H,FT-X SERIES,FT232R,FT245RN,FT4233HP,FT245R,FT232HP,FT232BM,FT232H,FT233HP,FT2232D,FT245BM,FT232B,FT4232HA,FT245B,FT2232H,FT-X,FT232RN,FT2232HP,FT2233HP

应用笔记或设计指南  -  FTDI CHIP  - Version 1.2  - 21-11-2023 PDF 英文 下载

Silicon Labs(芯科科技) CP2102/CP2109 USB连接桥 数据手册

型号- CP2102-GM,CP2109,CP210X,CP2109-A01-GM,CP2102-YM1,CP2102-GMR,CP2109-A01-GMR,CP2102

数据手册  -  SILICON LABS  - Rev. 1.8 1/17  - 2017年08月15日 PDF 英文 下载

FTDI integrated circuit devices RoHS2 - 2011/65/EU & (EU) 2015/863 Compliance Statement (FT_000223)

型号- FT245BM,FT2232D,FT2232C,FT8U100AX,FT8U232AM,FT245BL,FT232BM,FT232BL,FT8U245AM

测试报告  -  FTDI CHIP  - 03-05-2024 PDF 英文 下载

FTDI RoHS2-2011/65/EU& (EU) 2015/863 Compliance Statement

型号- FT245BM,FT2232D,FT2232C,FT8U100AX,FT8U232AM,FT245BL,FT232BM,FT232BL,FT8U245AM

测试报告  -  FTDI CHIP  - 2019/05/06 PDF 英文 下载

FT232BM USB UART IC

型号- MAX3245CAI,MIC2025-2BM,FT8U232AM,ADM213E,IRLML6402,MI0805K400R-00,SP213EHCA,FT232BM,240-1035-1,FT232BL,93C46,93C56,FT232BQ,93C66,MCP1700,FT245BM,93LC46B,MAX213CAI,FT2232H,SP491,FT232BM-XXXX,SP213ECA,NDT456P,MAX3245

数据手册  -  FTDI CHIP  - Version 2.0  - 21st September 2010 PDF 英文 下载

UM245R USB -Parallel FIFO Development Module Datasheet

型号- FT245RQ,MCP17XX,FT245BM,FT2232D,MIC2025-2BM,FT232R,UM245R,FT245R,IRLML6402,FT245RL

数据手册  -  FTDI CHIP  - Version1.05  - 2017-11-10 PDF 英文 下载

Future Technology Devices International Ltd FT2232D Dual USB to Serial UART/FIFO IC

型号- MAX3245CAI,FT2232,ADM213E,IRLML6402,SP213EHCA,FT232BM,FT2232D,FT245BM,213,CSTCR6M00G15,HCPL-2430,MAX213CAI,SP491,MAX3187,SP213ECA,CSTLSM00G53,MAX3245

数据手册  -  FTDI CHIP  - Version 2.05  - 18/04/11 PDF 英文 下载

UM232R USB -Serial UART Development Module Datasheet

型号- FT232RQ,FT232R,FT2232C,UM232R,FT232BM,FT232RL

数据手册  -  FTDI CHIP  - Version 1.2  - 2017-11-10 PDF 英文 下载

MM232R USB -Serial UART Development Module Datasheet

型号- FT232RQ,MIC2025-2BM,FT232R,FT2232C,MM232R,TC55,IRLML6402,FT232BM,FT232RL

数据手册  -  FTDI CHIP  - Version 1.1  - 2010-03-12 PDF 英文 下载

展开更多

电子商城

查看更多

品牌:FTDI CHIP

品类:High Speed USB Bridge with Type-C

价格:¥49.3850

现货: 0

品牌:FTDI CHIP

品类:USB 4-BIT IC

价格:¥19.5671

现货: 0

品牌:FTDI CHIP

品类:Dual High Speed USB to Multipurpose FIFO IC

价格:¥43.4824

现货: 0

品牌:FTDI CHIP

品类:USB to FULL HANDSHAKE UART IC

价格:¥19.5671

现货: 0

品牌:FTDI CHIP

品类:USB to FULL HANDSHAKE UART IC

价格:¥19.5671

现货: 0

品牌:FTDI CHIP

品类:USB to BASIC UART IC

价格:¥18.8982

现货: 0

品牌:FTDI CHIP

品类:USB I2C SLAVE IC

价格:¥18.8982

现货: 0

品牌:FTDI CHIP

品类:USB I2C SLAVE IC

价格:¥18.8982

现货: 0

品牌:FTDI CHIP

品类:USB I2C SLAVE IC

价格:¥18.8982

现货: 0

品牌:FTDI CHIP

品类:High Speed USB Bridge with Type-C

价格:¥42.4987

现货: 0

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

现货市场

查看更多

品牌:FTDI CHIP

品类:集成电路

价格:¥93.0244

现货:26

品牌:FTDI CHIP

品类:USB 3.0 to FIFO Bridge

价格:¥69.3000

现货:15

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

服务

查看更多

SMT贴片加工

可贴PCB板厚范围:0.6~2.0mm,也支持生产软硬接合板,拼板长宽:50*50mm~550*500mm,PCBA快速贴片支持01005CHIP元件。

最小起订量: 1片 提交需求>

信号完整性测试

深圳市启威测实验室,面向所有企业提供信号完整性测试服务,主要包括USB、HDMI 、DP、MIPI、PCIe 、SD/EMMC、DDR接口信号测试。测试手段有波形测试、眼图测试、抖动测试等。

提交需求>

查看更多

授权代理品牌:接插件及结构件

查看更多

授权代理品牌:部件、组件及配件

查看更多

授权代理品牌:电源及模块

查看更多

授权代理品牌:电子材料

查看更多

授权代理品牌:仪器仪表及测试配组件

查看更多

授权代理品牌:电工工具及材料

查看更多

授权代理品牌:机械电子元件

查看更多

授权代理品牌:加工与定制

世强和原厂的技术专家将在一个工作日内解答,帮助您快速完成研发及采购。
我要提问

954668/400-830-1766(工作日 9:00-18:00)

service@sekorm.com

研发客服
商务客服
服务热线

联系我们

954668/400-830-1766(工作日 9:00-18:00)

service@sekorm.com

投诉与建议

E-mail:claim@sekorm.com

商务合作

E-mail:contact@sekorm.com

收藏
收藏当前页面