Root/cntr/README

Source at commit 43f0bcee36200ee03daadfab33688098ed36896a created 8 years 8 months ago.
By Werner Almesberger, cntr/README: cntr -r always returns an error, so we cannot use it with &&
1Arbitrary-precision frequency counter
2=====================================
3
4Theory of operation
5-------------------
6
7The arbitrary-precision frequency counter counts clock cycles of a
8frequency source that is assumed to be free from drift. It compares the
9count with the host's system clock. If the system clock is synchronized
10with an accurate NTP reference, measurements with arbitrarily high
11accuracy can be obtained.
12
13In practice, this is limited by the the frequency source's drift and
14the time one is willing to wait. If NTP maintains the system time
15with an accuracy of +/- 100 ms, obtaining measurements with an
16accuracy of +/- 1 ppm would take about 28 hours.
17
18Additional error sources, such as the round-trip time when requesting
19a sample from the microcontroller, are also considered in the accuracy
20calculation.
21
22The counter consists of a board based on a C8051F320 microcontroller
23and the control software on the host. The microcontroller counts
24events in a free-running 16 bit counter that is regularly read and
25extended to 32 bits. The 32 bit counter is periodically queried by
26the host.
27
28The microcontroller's counter can count at a frequency of up to 3 MHz.
29(SYSCLK/4)
30
31In order to protect against transmission errors not detected by USB's
32CRC, which are occur relatively often, each packet is protected by a
33CRC-32 and an inverted copy of the payload. Corrupted packets are
34rejected by the host.
35
36The 32 bit counter wraps around at most once very 21.8 ms. The 32 bit
37counter wraps around at most every 1431 s. The host extends the 32 bit
38counter to 64 bits, and calculates frequency and accuracy from the
39count and the run time of the measurement application.
40
41
42Performing a measurement
43------------------------
44
45To perform a measurement, connect the CNTR board's probe input to the
46clock source and then run the "cntr" application on the host. An
47accuracy goal (in ppm) can be specified on the command line (see
48below).
49
50The host polls the microcontroller every 100 ms and displays the run
51time (in seconds), the measured frequency, and the accuracy achieved
52so far.
53
54Measurements can be stopped by pressing ^C or by specifying an
55accuracy goal. At the end, the total number of events counted and
56communication statistics are displayed.
57
58
59Updating the firmware
60---------------------
61
62The protocol revision and the build date of the firmware of the CNTR
63board can be queried with "cntr -i".
64
65To update the firmware, run
66cntr -r; sleep 1 && dfu-util -d 0x20b7:0xcb72 -D cntr.bin
67
68
69Known issues (version 2 hardware)
70---------------------------------
71
72- the input circuit only works up to about 1 MHz. The problem is that
73  we discharge too slowly though the base of Q1, which in turn keeps
74  the transistor turned on too long.
75
76  An alternative design that sets R2 to zero, adds a 47 Ohm termination
77  resistor in parallel to VR4, and places a 1 kOhm resistor between
78  VR4 and Q1 works up to about 2 MHz, but accepts a lot of HF noise
79  and is very sensitive to the signal amplitude.
80
81  Some test results with a ~1.8 m RG-174 cable, square wave bursts
82  with a 50% duty cycle and ~ 5 ns raise/fall time:
83
84  Design Frequency Source amplitude Input amplitude
85               (nominal) (nominal) (measured)
86  ------------ ---------- ---------------- ---------------
87  Original 1 MHz 700 mV ~700 mV
88  Alternative 2 MHz 1.6 V ~800 mV
89               1 MHz 1.5 V ~750 mV
90
91  The test consisted of setting the frequency and adjusting the nominal
92  source voltage in increments of 100 mV for the lowest voltage at
93  which which ten consecutive bursts of 50000 cycles each were all
94  received correctly.
95
96  The source has an output impedance of 50 Ohm, so voltage at the probe
97  input (indicated in the table) is roughly half the nominal source
98  voltage in the alternative design.
99
100- the MMCX connector is hard to solder because of its large thermal
101  capacitance and surface
102- the lateral pads of the MMCX connector could be wider
103- manufacturing tolerances can push the USB connector a bit inside
104  the board, making its signal pins overshoot the pads
105- the ground fill under the LED causes a secondary cathode contact
106  (which is harmless on this case)
107

Archive Download this file



interactive