1-wire pulse counter

Russian translation | User manual | Library for Arduino | Device web interface

Device memory

Memory pages, counters, scratchpad

Address space of the device consists of 16 memory pages, each 32 bytes in size:
PageAddressesContentsCounter
00x000 .. 0x01fSettings and status data-
10x020 .. 0x03fReserved-
20x040 .. 0x05fReserved-
30x060 .. 0x07fReserved-
40x080 .. 0x09fReserved-
50x0a0 .. 0x0bfScratchpad-
60x0c0 .. 0x0dfUser data, status data-
70x0e0 .. 0x0ffScratchpad (copy)-
80x100 .. 0x11fSettings and status data (copy)-
90x120 .. 0x13fReserved-
100x140 .. 0x15fReserved-
110x160 .. 0x17fReserved-
120x180 .. 0x19fReserved-
130x1a0 .. 0x1bfScratchpad (copy)-
140x1c0 .. 0x1dfUser data, status data (copy)A
150x1e0 .. 0x1ffScratchpad (copy)B

Each memory page has a 32-bit counter associated with it. Counters A and B are tied to pages 14 and 15, respectively, the counters of the remaining pages are not used and always have a value of 0. The value of any of the 16 counters can be obtained with a special request (0xA5 READ MEM COUNTER), which guarantees atomic reading of the counter. The value of counters A and B can also be obtained by reading bytes 0..7 of pages 0 or 8, in which the values of counters A and B are mapped, but in this case the reading is not performed atomically (increment of counter can occur between sequential reading of counter bytes). Writing counters A and B is possible only by writing to bytes 0..7 of memory page 0, writing will be performed atomically.

Reading data from memory addresses is performed directly (0xA5 READ MEM COUNTER), while writing is performed with the help of a special 32 bytes Scratchpad memory area: first, data is written to Scratchpad (0x0F WRITE SCRATCH), and then atomically copied from Scratchpad to specified memory addresses (0x5A COPY SCRATCH). The contents of Scratchpad can be read either by a special request (0xAA READ SCRATCH) or by reading memory pages 5,7,13 and 15, in which Scratchpad is mapped. Writing to Scratchpad or any of pages 5,7,13 or 15 changes only Scratchpad and its copies in those pages. Writing to other pages will overwrite Scratchpad and its copies with the written data.

Settings and status data

The state and settings of the device are stored in a memory area, one part of which is mapped in memory pages 0 and 8 (both are mapped to the same part of the state and settings) and other part in bytes 24..31 of pages 6 and 14 (both are mapped to the same part of the state).

All state and settings bytes are available for reading. Only bytes 0..7 of page 0 (counter values) and bytes 8..13 of page 8 (settings) are available for writing.

All bytes in pages 1..4, 9..12, as well as bytes 14..16, 18..31 in pages 0 and 8 and bytes 25..31 in pages 6 and 14 are reserved.

Addresses 0x000..0x003 and 0x100..0x103

Bit76543210
Offset in page: 0Counter A:[7..0]
Offset in page: 1Counter A:[15..8]
Offset in page: 2Counter A:[23..16]
Offset in page: 3Counter A:[31..24]
Access in page 0R/WR/WR/WR/WR/WR/WR/WR/W
Access in page 8RRRRRRRR
Default00000000

Counter A in normal operating mode (not in Measure mode), 4 bytes, LSB first.

Bit76543210
Offset in page: 0Counter A:[7..0]
Offset in page: 1Counter A:[15..8]
Offset in page: 2Measure Min:[7..0]
Offset in page: 3Measure Max:[7..0]
Access in page 0R/WR/WR/WR/WR/WR/WR/WR/W
Access in page 8RRRRRRRR
Default00000000

In the Measure mode, two most significant bytes of counter A are used to accumulate statistics of the minimum and maximum value of the digitized analog signal for samples that have passed the filter (if the analog mode is activated by setting: threshold rising > threshold falling, otherwise min and max values are undefined).

Addresses 0x004..0x007 and 0x104..0x107

Bit76543210
Offset in page: 4Counter B:[7..0]
Offset in page: 5Counter B:[15..8]
Offset in page: 6Counter B:[23..16]
Offset in page: 7Counter B:[31..24]
Access in page 0R/WR/WR/WR/WR/WR/WR/WR/W
Access in page 8RRRRRRRR
Default00000000

Counter B in normal operating mode (not in Measure mode), 4 bytes, LSB first.

Bit76543210
Offset in page: 4Counter B:[7..0]
Offset in page: 5Counter B:[15..8]
Offset in page: 6Measure Samples:[7..0]
Offset in page: 7Measure Samples:[15..8]
Access in page 0R/WR/WR/WR/WR/WR/WR/WR/W
Access in page 8RRRRRRRR
Default00000000

In the Measure mode, two most significant bytes of counter B are used to accumulate statistics of the number of samples that have passed the filter. Samples, 2 bytes, LSB first.

Addresses 0x008..0x00b and 0x108..0x10b

Bit76543210
Offset in page: 8Threshold falling A:[7..0]
Offset in page: 9Threshold rising A:[7..0]
Offset in page: 10Threshold falling B:[7..0]
Offset in page: 11Threshold rising B:[7..0]
Access in page 0RRRRRRRR
Access in page 8R/WR/WR/WR/WR/WR/WR/WR/W
Default00000000

Thresholds - values used to convert digitized analog value to logical state:
Digitized analog value on input is VConverted logical state of input
Threshold falling >= Threshold risingconversion is off, state is read directly from input
V < Threshold fallinglow
V > Threshold risinghigh
Threshold falling <= V <= Threshold risingprevious state

Addresses 0x00c and 0x10c

Bit76543210
Offset in page: 12PINCAPINCBPUDAPUDBSPWR1SPWR0PUT1PUT0
Access in page 0RRRRRRRR
Access in page 8R/WR/WR/WR/WR/WR/WR/WR/W
Default00000000

PINCA/PINCB - enable counter A/B increment mode on both edges (see table of states in EDGEA/EDGEB bit description).

PUDA/PUDB - disable pull-up resistor between power supply and A/B input:
PUDMode
0Pull-up enabled
1Pull-up disabled

SPWR[1..0] - sensors power supply mode:
SPWR1SPWR0Mode
00PWR pin is always off
01Pulse power supply on PWR pin
10PWR pin is used as input B, pulse power supply on B pin
11Power supply on PWR pin is always on
The PWR pin strength is below 100uA, the B pin strength is below 10mA.

PUT[1..0] - delay after turning on pull-ups and powering the sensors and before sampling inputs A and B:
PUT1PUT0Mode
0025 us
0150 us
10125 us
11425 us

Addresses 0x00d and 0x10d

Bit76543210
Offset in page: 13EDGEAEDGEBMSRPMSRLMSRAMSRBSMP1SMP0
Access in page 0RRRRRRRR
Access in page 8R/WR/WR/WR/WR/WR/WR/WR/W
Default00010011

EDGEA/EDGEB - edge used for counter A/B increment:
PINCEDGEMode
00Increment on falling edges
01Increment on rising edges
1anyIncrement on both edges

MSRP - device power mode filter in Measure mode:
MSRPMode
0Accumulate statistics only when operating on battery power
1Accumulate statistics only when operating from external power supply

MSRL - input logical level filter in Measure mode:
MSRLMode
0Accumulate statistics only when measured input is in low logical state
1Accumulate statistics only when measured input is in high logical state

MSRA,MSRB - enable Measure mode for input A/B:
MSRAMSRBMode
00Normal operating mode
01Measure mode for input B
10Measure mode for input A
11Reserved

SMP[1..0] - interval between samples:
SMP1SMP0Mode
0019 ms
0138 ms
1075 ms
11150 ms

Addresses 0x011 and 0x111

Bit76543210
Offset in page: 17Level ALevel BReserved
Access in page 0RRRRRRRR
Access in page 8RRRRRRRR
Default00000000

Level A/B - current logical state of inputs A and B, 0 - low, 1 - high.

Addresses 0x0d8 and 0x1d8

Bit76543210
Offset in page: 24Battery:[7..0]
Access in page 6RRRRRRRR
Access in page 14RRRRRRRR
Default00000000

Battery - current value representing voltage of the CR2032 battery. The battery voltage in Volts can be calculated using the formula Vbat = (VCC - 0.68V) * Battery / 256. In Measure mode, the Battery value is undefined.

User data

Bytes 0..23 of pages 6 and 14 (both pages are a mapping of each other) are available for storing user data.

The entire Scratchpad page can also be used to store user data, but before writing any other memory page, the Scratchpad contents must be read and remembered, and after writing, the remembered contents must be restored on device again. Thus, 56 bytes can be available for storing user data.