USB-DAQ
Summary
USB-DAQ is a low cost data logger and process
controller. In normal operation it operates autonomously,
collecting data and providing control as required. An on-
board real time clock is provided.
When plugged into a USB port, USB-DAQ appears on
the PC like a removable disk. One file, CONFIG.DAT,
contains the application code. This file is created on the
PC from a Microsoft Excel spreadsheet. Other files may
be used for logging data.
USB-DAQ uses the Mass Storage Device (MSD) USB
profile. It does not require USB driver installation, and
so is immediately compatible with present and future
Windows, Linux and Mac operating systems.
USB-DAQ is generally available in 20-pin and 28-pin
packages. Both devices can use a 25AA1024 EEPROM
chip for moderate data storage (128KByte). The 28-pin
device can additionally use internal flash memory for
data storage up to 8KByte or SD card memory and
chips up to 1GByte. A 40/44-pin device, with the same
capabilities as the 28-pin device but with extra I/O, can
also be made available.
TM
The data logger / process controller that looks like a USB flash drive to a PC
Features
“Flash drive” style PC interface.
Wide range of peripheral I/O – see table 1
Data acquisition / process control engine
Flexible instruction set
32768Hz real time clock with leap year correction
and daylight savings time
USB 2.0 MSD plug and play - No drivers required
One and two chip solutions:
-
Microcontroller with internal 8KB flash memory
-
Microcontroller and 128KB SPI memory
-
Microcontroller and SD memory up to 1GB
DIL, SOIC and SSOP packages
Note: The 20-pin device has reduced functionality.
Table 1. Peripheral feature matrix
-20-SS
-28-SO
-44-PT
USB-DAQ
-20-DIL
-28-DIL
-40-DIL
Internal
No
8K byte
8K byte
Memory
25AA1024
128K byte 128K byte 128K byte
options
No
to 1G byte to 1G byte
SD card/chip
I/O pins
12
21
32
Interrupt on edge
3
3
3
Interrupt on change
0
4
4
Count / Compare /
0
2
2
Pulse Width Modul’n
UART (not buffered)
1
1
1
SPI/I2C (as master)
1
1
1
UNI/O (as master)
12
21
32
Comparators
2
2
2
10-bit A to D
9
10
13
Timer 8-bit
1
1
1
Timer 16-bit
3
3
3
Product ID (hex)
0135
0134
0136
Available packages*
DIL,SSOP DIL,SOIC DIL,TQFP
*Devices in general distribution are
USB-DAQ-20-SS and USB-DAQ-28-DIL
Applications
Food and drug transportation
Low cost data logging
Rapid autonomous USB product development
Research, development and teaching
Firmware Factory USB Product Family
expandIO-USB I/O expander
USB-232, USB-SPI, USB-I2C serial bridges
USB-DataPort high speed data transfer
USB-FileSys embedded file system
USB-DAQ data logger
USB-TEALeaf security dongle
Firmware Factory Ltd
3 Plough Yard, Ground Floor
London EC2A 3LP, UK
sales@firmwarefactory.com
support@firmwarefactory.com
Serial
Memory
Looks like
Flash Drive
Digital, Analog
Comparator &
Counter, Serial I/O
USB
Flash Drive Engine
Data Acquisition &
Process Control Engine
USB-DAQ
p1 of 8
26-Aug-10
USB-DAQ
HW147-5
www.hexwax.com
Basic Operation
USB-DAQ contains a FAT file system on which files can
be stored. When plugged into a Windows, Linux or Mac
PC, USB-DAQ looks like a flash drive and files can be
directly accessed without the need to install drivers or
software. The file can be stored in internal memory (8
kByte), external 25AA1024 memory (128 kByte), or SD
cards or chips up to 1 GByte. The PC can create, read,
write and delete files and subdirectories as required.
In addition to functioning as a flash drive, USB-DAQ has
a data acquisition / process control engine and a real
time clock that allow it to function autonomously when
not connected to the PC. A file named CONFIG.DAT in
the root directory controls the chip’s function when
operating in this mode. This file is created in a Microsoft
Excel application and includes instructions to execute on
startup, and when an interrupt or real-time-clock event
occurs. USB-DAQ can read and write to up to four files
in the root directory; it does not create them, delete
them, or change their length.
When a file in the root directory is modified by the PC,
USB-DAQ notes the modification date and time data in
the directory entry and use this information to set the
time on the real time clock.
Electrical Specifications
Table 2. Electrical Specifications
Operating voltage Vdd, 28-pin device
2.7V – 5.5V
Operating voltage Vdd, 20-pin device
1.8V – 5.5V
Typical/max supply current, Vdd = 5.0
10mA / 21mA
Typical/max Sleep current, Vdd = 5.0
0.1μA / 2μA
Operating Temperature
-40°C to +85°C
Refer to base MCU data sheets in the dev kit for further information
Table 3. 28-Pin Device Pinout
Name
Description
Media detect input
Media
1
Vpp
TEAclipper programming pin Vpp
2
RA0
General I/O pin
3
RA1
General I/O pin
4
RA2
General I/O pin
5
RA3
General I/O pin
General I/O pin
RA4
6
Escape
Escape input pin
7
RA5
General I/O pin
8, 19
Vss
Power ground reference
9
OSCA1
12MHz oscillator input
10
OSCA2
12MHz oscillator output
OSCB1
32768Hz oscillator input
11
RC0
General I/O pin (if no 32768Hz oscillator)
OSCB2
32768Hz oscillator output
12
RC1
General I/O pin (if no 32768Hz oscillator)
MISO-M
Data input from SPI memory
13
RC2
General I/O pin (if no external memory)
14
Vusb
USB supply filter
15
D-
USB data -
16
D+
USB data+
17
RC6
General I/O pin
18
RC7
General I/O pin
20
Vdd
Regulated supply input
21
RB0
General I/O pin
22
RB1
General I/O pin
23
RB2
General I/O pin
24
RB3
General I/O pin
SSn-M
Slave select output to SPI memory
25
RB4
General I/O pin (if no external memory)
26
USB-S
USB voltage sense
MOSI-M
Data output to SPI memory
27
RB6
General I/O pin (if no external memory)
PGC
TEAclipper programming pin PGC
SCK-M
Clock output to SPI memory
28
RB7
General I/O pin (if no external memory)
PGD
TEAclipper programming pin PGD
Pin
Table 4. 20-Pin Device Pinout
Name
Description
Vdd
Regulated supply input
OSCA1
12MHz oscillator input
OSCA2
12MHz oscillator output
Device reset input (active low)
RST#
Vpp
TEAclipper programming pin Vpp
RC5
General I/O pin
RC4
General I/O pin
RC3
General I/O pin
OSCB1
32768Hz oscillator input
RC6
General I/O pin (if no 32768Hz oscillator)
OSCB2
32768Hz oscillator output
RC7
General I/O pin (if no 32768Hz oscillator)
SSn-M
Slave select output to SPI memory
SCK-M
Clock output to SPI memory
MISO-M
Data input from SPI memory
MOSI-M
Data output to SPI memory
RC2
General I/O pin
USB-S
USB voltage sense
General I/O pin
RC0
Escape
Escape input pin
Vusb
USB supply filter
D-
USB data -
PGC
TEAclipper programming pin
D+
USB data+
PGD
TEAclipper programming pin
Vss
Power ground reference
Device Pinout
Pin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Figure 2, Device Pinout
17
18
19
20
p2 of 8
26-Aug-10
USB-DAQ
HW147-5
www.hexwax.com
Dedicated Pin Functions
The pin functions are shown in tables 3 and 4 and figure
2. Most are software-configurable general I/O pins.
Pins with dedicated functions are described below.
Vss, Vdd, Vusb
Vss
is the power supply ground reference.
Vdd
should
be connected to a regulated supply, most usually the
USB power when available and a battery when USB
power is not available.
Vusb
should be connected, via a
470nF capacitor, to
Vss.
See for example C8 in figure 3.
OSCA1, OSCA2
OSCA1 and OSCA2 should be connected to a 12MHz
parallel cut crystal circuit with 22pF capacitors or a
12MHz resonator with 0.25% total tolerance.
OSCB1, OSCB2
If a real-time clock (RTC) is required, OSCB1 and
OSCB2 should be connected to a
32768Hz
parallel cut
crystal circuit with 27pF capacitors. If the RTC is not
required, these pins may be used for general I/O.
Vpp, PGC, PCD
TEAclipper programming pins. Refer to the TEAclipper
Programming section for details. Note that the Vpp pin
may be subject to voltages as high as 13V during
programming.
Media Detect
The Media detect input pin should be pulled low with a
33K resistor if 25AA1024 memory used. If the SCK-M
pin is biased low indicating that internal memory is used,
the Media detect pin is ignored.
The Media detect input pin should be high during normal
operation with SD memory. If SD memory removable,
Media detect should be taken low when it is removed. If
the device is connected to a PC, a soft detach and re-
attach will be performed on media removal. The SD
memory must be physically removed so that a power-up
reset is performed when it is re-inserted.
In order to allow USB-DAQ to be programmed in-circuit,
it must be possible to configure the application circuit so
that this input appears to be pulled high via a 22k
resistor, or pulled low with a 33k resistor.
D+, D-
USB data I/O. Refer to the USB Connectors section for
details of their connections.
USB Voltage Sense
This input should be high when the device is plugged
into a USB host. Refer to figure 4 for a typical method
of deriving this input from the USB supply input.
SCK-M, MISO-M, MOSI-M, SSn-M
If SD or 25AA1024 memory is used, these pins are the
SPI serial interface to the memory. 4k7 pull-up resistors
are required on all these lines.
If internal memory is used, SCK-M should be biased low
on power-up. These pins may then be used for general
I/O.
p3 of 8
26-Aug-10
USB-DAQ
Escape
Escape is an optional input pin. If it is high during
initialization, no code will execute. During development,
enabling the Escape pin is strongly recommended to
recover USB-DAQ from coding errors which might lock
the device. (e.g. A reset in the initialization code.)
The state of the Escape pin is only measured during
initialization. The pin may therefore also be used for
other purposes provided it can be weakly biased during
initialization.
Status Pins
Optional pins indicating device status and controlling
execution are described below. These pin functions can
be assigned to any general I/O pin by changing the
appropriate setting in the Configuration tab of the USB-
DAQ Compiler spreadsheet.
Event Indicator
The DAQ initialization code or event code is executing.
The pin will pulse for a minimum of 100ms.
TxRx Indicator
Data was received from or transmitted to the PC. The
pin will pulse for approximately 100ms.
Suspend Indicator
The Suspend output indicates that the PC has entered a
low-power sleep mode. In suspend mode, the device
should draw no more than 100μA from the USB bus. In
no event should an external power source inject power
into the USB Vdd line.
AllSysGo Indicator
The “All Systems Go” output indicates that the USB is
configured and the PC is not in suspend mode. It
provides a combined indication that it is safe to draw
power from the USB supply.
USB-DAQ can be configured from the spreadsheet to
request either 100mA, allowing the device to operate
from unpowered hubs, or 500mA, in which case it will
only work when connected direct to a PC or powered
hub. This is selected by changing the appropriate
setting in the Configuration tab of the USB-DAQ
Compiler spreadsheet.
General I/O Pins
The following pin functions are software configurable at
runtime by setting their registers appropriately.
Examples of their use are given in the development kit.
Full details of their operation and their associated
registers are given in the base microcontroller
spreadsheets, also in the development kit.
RAx, RBx, RCx, RDx, REx
Digital I/O pins.
ANx
10-bit analog input pins.
HW147-5
www.hexwax.com
INTx, KBIx
Interrupt-on-edge (INT) and interrupt-on-change (KBI)
input pins.
CCPx, P1x
Capture / compare / pulse width modulation pins.
TX, RX
Asynchronous UART
SCK, MISO, MOSI, SSn
Synchronous serial (SPI) port
SCL, SDA
Synchronous serial (I2C) port
CxIN-, CxIN+, CxOUT
Comparator pins
TxCKI
Counter inputs
should be provided for these lines, and also for unused
SD card I/O pins.
The memory can be a removable SD card or a SD-
compatible chip. If the memory is removable, the media
detect input should be connected to a switch to indicate
when the card is present. Devices with SD card readers
will be able to read the data on the SD card directly.
Memories larger than 1GB will be ignored, as will non-
standard memories which do not have block sizes of
512 bytes. San-Disk products are used for testing.
Accessing SD card memory is slow. It is intended
mostly for long-term logging applications only. This
option is only available for the 28-pin and 40/44-pin
devices.
Memory Integrity
In the event of power loss during a USB-DAQ write
operation, it is possible that the contents of data may be
corrupted.
Functionality should not otherwise be
affected.
Memory
Internal Memory
In order to maximize available storage space, the
internal memory is pre-formatted as a 16-sector FAT12
file system with 512 bytes per sector.
(4 of these
sectors are required for the file system and root
directories.) Reformatting by the PC is not permitted.
The root directory can contain up to 16 entries, including
the volume name. The volume is normally supplied
containing no files. If ordered in 5K+ quantities, files
can be pre-loaded.
To indicate to USB-DAQ that the internal memory
should be used, the SCK-M input should be biased low
on startup.
Pages of internal memory may be erased and rewritten
approximately 100K times. In order to minimize wear,
USB-DAQ does not update directory entries; it only
changes the contents of files.
Real Time Clock
The real time clock is self-managing and incorporates
day-of-week calculator, leap-year calculator and optional
daylight savings time calculator. On power-up, the time
st
is set to 00:00:00, Jan 1 2000.
Whenever a file in the root directory is modified by the
PC, the time and date are automatically set to the ‘last
modified’ time and date of the file most recently written
to in the root directory. To set the time, the user simply
needs to open a file in the root directory, modify it, and
save it.
Application Circuits
The following circuits show typical implementations of
the USB-DAQ.
Suggested component values are
shown in table 5.
Table 5. Suggested component values
Label
Component
R1-R3, R40-R43
22k resistor
R6
1k resistor
R21
470Ω resistor
T1
P-channel Mosfet, e.g. NDS352P
D1-D2
Low Vf switching diode
LED1
Light emitting diode
C1
1μF
capacitor
C2, C3
22pF capacitor
C4, C5
27pF capacitor
C6-C7, C9
100nF capacitor
C8
470nF capacitor
X1
12MHz parallel cut crystal
X2
32758Hz parallel cut crystal
External Memory – 25AA1024
For moderate storage applications, a Microchip
25AA1024 memory (128kByte storage) may be
connected to the MISO-M, MOSI-M, SCK-M and SSn-M
lines. A 4k7 pull-up resistor should be provided for
SCK-M. The media detect input should be permanently
biased low.
When first used, the memory will automatically be
formatted as a 16-sector FAT12 file system with 512
bytes per sector. The PC may re-format the drive if
required.
External Memory – SD card / integrated circuit
For large storage applications, an SD-compatible
memory of up to 1GB may be connected to the MISO-M,
MOSI-M, SCK-M and SSn-M lines. 4k7 pull-up resistors
p4 of 8
26-Aug-10
USB-DAQ
In figure 3, the internal memory is used and only
contains components that are strictly necessary. The
device has its own power source Vdd and does not draw
power from the USB port.
Oscillator X1/C2/C3 may be replaced by a low-cost
resonator, provided its frequency tolerance is greater
than 0.25%. C1 and C6 should be placed close to the
HW147-5
www.hexwax.com
USB connector. C7 should be placed near the Vss and
Vdd pins of the USB-DAQ and is required only if it would
be some distance from C6. C8 is a filter capacitor for an
internal regulator and is required.
The TEAclipper connector is for in-circuit programming.
It is recommended to allow firmware updates, even if the
firmware is initially supplied pre-programmed. See the
TEAclipper programming section for details.
R3 pulls USB-S low when the USB connector is not
attached to a PC. R7 ensures the current is limited if
Vdd is below the USB supply voltage. Note how SCK-M
is biased low by R40. It must be low at startup, but may
otherwise be used as general I/O, as may the other
serial memory pins.
The OSCA and OSCB pins are not connected. There is
no real time clock and the event loop can only be
triggered by interrupt events.
R40
Vss
SCK-M
General I/O
Vto
Vdd
Vss
Vcc
Gnd
Serial
Memory
MISO
MOSI
SCK
SSn
R40-R43
Vdd
Vdd
Vdd
Vdd
MOSI-M
SCK-M
SSn-M
MISO-M
General I/O
TxRx
OSCB2
X2
R21
LED1
Vss
C5
Vss
C4
C3
X1
T1
R6
PTO#
R1
OSCB1
USB-DAQ
C9
OSCA2
OSCA1
Vss
C2
Vss
4
3
2
1
PGC
Media/Vpp
Vss
D+
D-
USB-S
R3
D2
USB
Vdd
C8
Vusb
PGD
Vdd
TEAclipper
connector
1
2
3
4
5
Vss
Vbatt
D1
Vss
Vdd
Vss
Vdd
SW1
C7
C6
R2
Vss
C1
Figure 4. Typical Application Circuit, External Memory
D1 and D2 should have a very low forward voltage – ideally 0.3V.
C3
OSCA2
Vss
X1
USB Connectors
Common USB connector and cable configurations are
shown in figure 5 and table 6. The shield on the
connector should be left unconnected. The ID pin on
the mini connector permits the distinction of A and B
plugs. The micro connector pin-out is the same as the
mini connector.
Figure 5 Common USB pin-outs for male connectors
USB-DAQ
OSCA1
C2
Vss
PGC
Media/Vpp
Vss
D+
D-
USB-S
R3
R7
Vusb
PGD
Vdd
4
3
2
1
USB
C8
Vss
TEAclipper
connector
1
2
3
R2
4
5
Vss
Vdd
Vss
C7
C6
Vss
C1
Figure
3.
Typical Application Circuit, Internal Memory
Figure 4 shows a more advanced circuit with many
additional options added. External memory is used.
SW1 acts as a media detect switch for an SD card. If
25AA1024 memory is used, the Media input should
instead be biased low; if non-removable SD memory is
used, the Media input should instead be biased high.
Vto
is gated by P-channel mosfet T1 to provide power
take-off circuit, for example to provide power to a battery
charger. C4 and R6 ensure the inrush current is not so
great as to cause a significant voltage drop.
In this circuit, two power sources are available: power
from the USB power input, and a battery
Vbatt.
D1 and
D2 ensure the higher of these is used by
Vdd.
If the
serial memory cannot not operate at 5V, the USB power
should be regulated to 3.3V.
X2, C4 and C5 comprise a real time clock oscillator.
LED1 shows a typical LED indicator circuit.
Table 6. USB Connection Key
Cable
Name
Description
color
Std Mini
1
1
Vcc
Red
+5V (can dip to 4.08V)
2
2
D–
White
Data –
3
3
D+
Green
Data +
Type A: Connect to ground
–
4
ID
–
Type B: Not connected
4
5
Gnd
Black
Signal ground
Pin
For ultra-low cost products, it is possible to form a USB
Type-A plug direct from a circuit board as shown in
figure 6. This connector is only suitable for a limited
number of insertions (~50 before cleaning is required).
It is unshielded and recommended only for ‘dongle’ type
products with no cables attached.
p5 of 8
26-Aug-10
USB-DAQ
HW147-5
www.hexwax.com