print

Data Logging Utilising USB Sensors and Storage

There are a wide variety of data capture devices on the market today that are targeted at PC-based data logging applications. Frequently, these sensors will have a USB interface as opposed to RS232 or other legacy interfaces. Exploiting USB devices in the embedded world has traditionally required relatively high-powered hardware with a USB Host controller interface, RTOS and USB software drivers.


For storage, the low-cost and high-capacity of USB Flash disks has made them attractive for many embedded applications. There are advantages of using USB Flash disks as storage in certain applications where dedicated internal Flash or battery-backed storage may be unsuitable or just prohibitively expensive. For example, the requirements may specify that the monitoring device is left in-situ and the storage device removed for analysis periodically; the device may only be powered intermittently; or the device has to be able to store large amounts of data over an extended time period with minimum power consumption.


Data logging application


The application illustrates an MCU-controlled device, an FTDI VNC1L USB Host controller with two ports: one is used for a data sensor from which to read information, the other is used for a Flash disk to store information. Communication between the MCU and the USB Host controller is via a UART (or SPI) Command Monitor interface that permits an application to control USB devices using a simple command set.


A block diagram of the application is shown in Figure 1. The MCU chosen in this case is a PIC18F1320 device on a Microchip PICDEM 4 Demo Board, although it should be straightforward to port to other members of the PIC family and other MCU families. The MCU to VNC1L interface uses 4 wires (plus power and ground) connected to the PIC’s EUSART (Tx and Rx) and 2 I/O ports to enact RTS/CTS flow control. Alternatively, a 4-wire SPI port can be implemented by bit-banging I/O ports directly. Source code is provided in C for both methods.



Fig. 1:USB data Logger block diagram.


The application requests readings from a DLP Design DLP-TILT 2-axis tilt sensor and stores the data received in CSV format on a USB Flash disk. The DLP-TILT module will sample the current reading of the sensor when it receives an OUT packet containing the ‘z’ character from the USB bus. The tilt sensor reading can then be accessed by polling for an IN packet. Using the VNC1L Monitor the OUT packet can be sent with the DSD (Device Send Data) command followed by the number of bytes of data and the data to send. The IN packet can be received with a DRD (Device Read Data) command – the VNC1L returns the number of bytes and any data read from the device. The user is not required to format USB packets and need not be concerned about the underlying USB protocols.


Typically USB devices can have several milliseconds latency due to the USB requirement of transferring data in packets, although this can be overcome by adequate buffering of the sensor data. Of course, the design may not require a USB sensor device but only call for the storage of data onto a Flash disk. This is normally the case in data acquisition applications where an MCU is sampling analogue inputs or recording data from an external source. This will allow for higher data rates to be captured since there is no requirement to poll USB devices.


Data acquisition application


Figure 2 shows an analogue input application. In our example the MCU used is again a PIC18F1320 device on a Microchip PICDEM 4 Demo Board. A MEMS accelerometer module from STMicroelectronics, the STEVAL-MKI010V1, is connected to an analogue input of the PIC. This input is sampled periodically by the PIC application and the results added to a FIFO buffer, implemented in software, before being written to the storage device by the VNC1L.


The VNC1L Monitor provides commands to read and write files on USB Flash disks. It also has commands that manage file systems, allowing creating,



Fig. 2: Data acquisition block diagram.


renaming and deleting both files and directories. As with the commands for communicating with USB devices, the file system commands are simple to use. To write data to a file the sequence is OPW (Open for Write) followed by a filename, WRF (Write to File) followed by the number of bytes to write and CLF (Close File), again followed by a filename.


The standard sector size for USB Flash disks is 512 bytes; therefore for best performance it is advantageous to attempt to buffer 512 byte of data before writing to the USB Flash disk. The file systems employed on USB Flash disks are normally FAT12, FAT16 or FAT32. In these file systems clusters are allocated as-required and this may lead to small delays when clusters are not allocated sequentially. This is, however, generally only prevalent on disks that are approaching capacity.

Contact Information
Future Technology Device International Ltd.

Future Technology Device International Ltd.
373 Scotland St.
Glasgow, Scotland, G5 8 QB
United Kingdom
(0) 44 141 429 2777 Telephone

(0) 44 141 429 2758 Fax
sales@ftdichip.com
www.ftdichip.com

Future Technology Devices International Ltd.
(USA) 7235 NW Evergreen Parkway Suite
600 Hillsboro, OR 97124-5803 US
A Tel: +1 (503) 547-0988
Fax: +1 (503) 547-0987 E-Mail

(Sales): us.sales@ftdichip.com

Future Technology Devices International Limited

(Taiwan) 4F, No 18-3, Sec. 6 Mincyuan East
Road, Neihu District, Taipei 114,

Taiwan
Tel: +886 2 8791 3570
Fax: +886 2 8791 3576 E-Mail

(Sales): tw.sales1@ftdichip.com

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Comments

One Response to “Data Logging Utilising USB Sensors and Storage”

  1. David Says:

    A very versatile setup, great for people out in the field and a great addition to any remote camp and outpost with researchers who use laptops.

Leave a Reply

Comment

Security Code: