• 沒有找到結果。

H ARDWARE D RIVER

CHAPTER 5 HOST APPLICATION

5.2 H ARDWARE D RIVER

As shown in Figure 5-1, the device driver plays a role of connecter between Windows and hardware. But USB driver doesn’t talk directly to USB hardware; it talks to Microsoft USB driver called USBD.sys. In EZ-USB, Cypress Semiconductor had provided a driver called: ezusb.sys, so that we can use it directly.

as a HID, so that we don’t have to make our own INF file. Windows will recognize the device by using its own INF (in Windows 98, it will use

“hiddev.inf”. in Windows 2000, it will use “input.inf” for HID device.).

Figure 5-6 The HID device shows up in the device manager when we plug device into USB port.

Figure 5-6 HID device shows up on Device Manager.

Chapter 6 Conclusion

6.1 Transfer rate calculation

Now we will test our device and its performance. As we know, for the full-speed of HID, the maximum transfer speed is 64KB/s. We should consider the hardware constrains: the ADC’s conversion time, and the Start pulse. For ADC0809, the conversion time is 100 µs, and we set the Start pulse to about 0.6 µs (the minimum time that EZ-USB’s internal 8051 can reach). Because the EZ-USB’s interrupt endpoint buffer is 64 bytes, so we set the 8051 to get 64 data from AD converter. We use double buffers to save the AD data. When one buffer is full then sent by USB core, 8051 can still save the data to another. The process will continuously repeat when another buffer is full. Each buffer is 64bytes.

The USB core polling interval is set to 1 millisecond.

I set the program to run 100 loops and record the total spending time form “Timer1” in my program. The data what EZ-USB transferred will be output to file, “data”. The graph display is done with the assist of EXCEL.

6.2 Experiment Result

Testing environment:

Operation System: Windows XP Professional;

PC: P4-1.3G, 512M DDR Ram;

USB Host: USB 2.0;

In report size: 64 bytes;

Out report size: 64 bytes;

Packet size: 64 bytes;

Polling interval: 1ms;

Testing results are illustrated as below figures. All figures are marked down 100 samples.

100Hz Signal

0 1 2 3 4 5

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Time(millisecond)

Output(Volt)

Figure 6-1100Hz signal

100Hz Signal

0 1 2 3 4 5

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Time(millisecond)

O u tput (V ol t)

Figure 6-2 100Hz signal (2)

1Khz Signal

0 1 2 3 4 5

0 1 2 3 4 5 6 7 8 9

Time(millisecon)

Output(Volt)

Figure 6-3 1 KHz signal

1KHz Signal

0 1 2 3 4 5

0 1 2 3 4 5 6 7 8 9

Time(millisecond)

O u tput (V ol t)

Figure 6-4 1 KHz signal (2)

2KHz Signal

0 1 2 3 4 5

0 1 2 3 4 5 6 7 8 9

Time(millisecond)

Output(Volt)

Figure 6-5 2 KHz signal

2KHz Signal

Figure 6-7 3 KHz signal

3KHz Signal

From the results of my experiment, we can calculate the transfer speed. The transfer speed is approaching 6Kbytes/s. it means that the system can sample 6000 points within a second. Therefore, the input signal frequency must be under 3 KHz. As Figure 6-7 shows, when the input signal frequency is 3 KHz, the output has committed an error.

Furthermore, we found there is a non-continued point in every 64 points (a packet). That is due to the HID report whereas there ought to be a Report ID in each report. In the program setting, we can easy skip this byte, that is, we have skipped this byte while making the graphs.

Digital-to-Analog output result as below figure shows, I let my Windows program to generate a sine wave and capture the photography

Figure 6-9 Digital-to-analog Output test (1)

Figure 6-10 Digital-to-analog Output test (2)

6.3 Conclusion

In section 6.2, we can comprehend that the transfer speed is approaching 6 Kbytes/s, but the report ID byte will reduce the transfer rate of the useful data. In my experiment, there are 100 packets transferred.

There will be 100 bytes for report ID, hence the useful data transferred will be 6400 bytes (6500 – 100 = 6400). And the total data transferred into host is 6500 bytes/s.

Constrained by the Windows program and the AD converter’s conversion time, the performance can’t reach the utility to the best of HID ideal value, 64Kbytes/s. To improve the performance, there are some ways to do. In the software part, we can use multi-thread or DirectX to increase the software performance. In the Hardware part, we can change the AD converter for better performance.

Nevertheless, there is a main problem that the USB is a master-slave system. That is, the device cannot send the data unless the host makes request. In USB, HID class is usually used to implement on moderate device. In data acquisition, it provides an easy-used way, but not a fast sample rate. In the future, the sample rate could be enhanced when the system upgrades to USB 2.0.

References

[1] John Hyde, USB design by example: /a practical guide to building I/O devices, Wiley, 2001.

[2] Don Anderson / Dave Dzatko, Universal Serial Bus System Architecture. Second Edition, Addison Wesley, 2001.

[3] Jan Axelson, USB Complete: Everything You Need to Develop Custom USB Peripherals , Lakeview Research, 2001.

[4] 許永和,微處理機程式設計(USB介面之完全解決方案),長高出版 社,2003.

[5] 蕭世文,精通USB2.0 硬體設計,文魁資訊股份有限公司,2002.

[6] 劉志安,USB2.0 程式設計,文魁資訊股份有限公司,2002.

[7] 楊明豐,8051 單晶片C語言設計實務---使用Keil C,2003.

[8] EZ-USB General Purpose Driver Specification Document, Cypress Semiconductor, 1999.

[9] EZ-USB Manual Technical Reference Vision 1.10, Cypress Semiconductor, 2002.

[10] Jan Axelson, "HIDs Up", Embedded Systems Programming (ESP), October 2000.

www.usb.org/developers/hidpage.html.

[12] USB specification, www.usb.org/developers/docs.html [13] Microsoft DDK, http://msdn.microsoft.com

相關文件