1-wire port expander

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

Device memory

Memory pages

Address space of the device consists of 4 memory pages, each 8 bytes in size:
PageAddressesContents
00x00 .. 0x07ADC results
10x08 .. 0x0fControl/status data
20x10 .. 0x17Thresholds
30x18 .. 0x1fUser data, control/status data

The entire address space is available for reading and writing. Reading and writing data from/to memory addresses is byte-by-byte (commands 0xAA READ MEM, 0x55 WRITE MEM). ADC results are 16-bit values that are written into two memory cells by the device itself asynchronously after ADC conversion is completed sequentially for each channel (the conversion is initiated by 0x3c CONVERT command), the low and high bytes of ADC result are read from device atomically (the situation of reading low byte of old result and high byte of new result is excluded). When writing bytes that change port settings, the changes occur immediately after each byte is written.

Alarm flags

Device has 14 alarm flags: POR, AFD[0..4], AFL[0.2..4], AFH[0.2..4], if at least one of which is set, the device will respond to alarm search request. The device itself can change state of the flags (see description of the corresponding flags). All flags are also available for reading and changing by referring to bits at specific addresses. To exclude a device from alarm list, all of the alarm flags must be cleared.

Addresses 0x00..0x07

Bit76543210
Address 0x00ADCV0:[7..0]
Address 0x01ADCV0:[15..8]
Address 0x02ADCV2:[7..0]
Address 0x03ADCV2:[15..8]
Address 0x04ADCV3:[7..0]
Address 0x05ADCV3:[15..8]
Address 0x06ADCV4:[7..0]
Address 0x07ADCV4:[15..8]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Default00000000

ADCV[0,2..4] - value of the last ADC result on port P[0,2..4], 2 bytes, the LSB first. Always 16-bit value: regardless of the resolution (RES), the result is always left-shifted so that the most significant bit is in the 15th position, the least significant bits are cleared.

Addresses 0x08, 0x0a, 0x0c, 0x0e

Bit76543210
Address 0x08OE0OC0DI0REF0RES0:[3..0]
Address 0x0aOE2OC2DI2REF2RES2:[3..0]
Address 0x0cOE3OC3DI3REF3RES3:[3..0]
Address 0x0eOE4OC4DI4REF4RES4:[3..0]
AccessR/WR/WRR/WR/WR/WR/WR/W
Default00000000

OE[0,2..4] and OC[0,2..4] - port P[0,2..4] operation mode:
OEOCPort mode
00High impedance state
01A pull-up resistor is connected between input and VCC
10Output logical 0 (low)
11Output logical 1 (high)
Setting output port mode does not disable input capability (reading/monitoring logical level or ADC function) of port.

DI[0..4] (bit DI1 for port P1 is located in byte at address 0x1f) - current logical level read from port P[0..4], 0 - low, 1 - high.

REF[0,2..4] - ADC reference voltage for port P[0,2..4], will be used for subsequent ADC. Indicates the conversion range for the ADC, any exceeding voltage will result in maximum ADC value.
REFReference voltage
0VCC
1Internal 1.1V

RES[0,2..4] - ADC resolution in bits (from 1 to 15, value 0 corresponds to 16 bits) for port P[0,2..4], will be used for subsequent ADC.

Addresses 0x09, 0x0b, 0x0d, 0x0f

Bit76543210
Address 0x09PORAFD0AFH0AFL0AEH0AEL0AED0AWD0
Address 0x0bPORAFD2AFH2AFL2AEH2AEL2AED2AWD2
Address 0x0dPORAFD3AFH3AFL3AEH3AEL3AED3AWD3
Address 0x0fPORAFD4AFH4AFL4AEH4AEL4AED4AWD4
AccessR/WR/CR/WR/WR/WR/WR/WR/W
Default10001100

POR - power-on reset flag, 0 - cleared, 1 - set. The device itself can only set this flag, which means that all settings have been reset to default. User can write 0 or 1 (but writing 1 will not generate a reset cycle). Flag is updated simultaneously in all four bytes.

AFD[0..4] (bit AFD1 for port P1 is located in byte at address 0x1f, but in a bit with a different number!) - logical level alarm flag of port P[0..4], 0 - cleared, 1 - set. By the user this flag can only be cleared by writing 1, writing 0 keeps flag unchanged:
Writing to AFDAFD
0unchanged
10
By the device itself this flag can only be set and only if corresponding alarm enable bit AED[0..4] is set to 1 and the logical level of port P[0..4] (0 - low, 1 - high) matches the corresponding value of the AWD[0..4] bit, otherwise flag remains unchanged:
AEDAWDPort logical levelAFD
0anyanyunchanged
10always highunchanged
10detected low1
11always lowunchanged
11detected high1

AFL[0,2..4] / AFH[0,2..4] - analog value too low/high (below THL[0.2..4] / above THH[0.2..4] threshold) alarm flag, 0 - cleared, 1 - set. User can write 0 or 1. By the device itself this flag is set only if the corresponding alarm enable bit AEL[0.2..4] / AEH[0.2..4] is set to 1 and analog value is outside the corresponding threshold, otherwise flag is cleared. Both flags are updated after the ADC is completed and written for the corresponding port, the flags of the port for which ADC was not performed remain unchanged:
ADC was performed on portAELADC resultAFL
noany unchanged
yes0does not matter0
yes1ADCV:[15..8] >= THL0
yes1ADCV:[15..8] < THL1
ADC was performed on portAEHADC resultAFH
noany unchanged
yes0does not matter0
yes1ADCV:[15..8] <= THH0
yes1ADCV:[15..8] > THH1
When compared to the threshold, only the high byte of the ADC result is used.

AEL[0,2..4] / AEH[0,2..4] - enable analog low/high alarm for port P[0,2..4] (see tables of states in AFL[0.2..4] / AFH[0.2..4] bits description).

AED[0..4] (bit AED1 for port P1 is located in byte at address 0x1f) - enable logical level alarm for port P[0..4] (see table of states in AFD[0..4] bit description).

AWD[0..4] (bit AWD1 for port P1 is located in byte at address 0x1f) - monitored logical level of port P[0..4] (0 - low, 1 - high), upon detection of which the alarm flag is set (see table of states in AFD[0..4] bit description).

Addresses 0x10, 0x12, 0x14, 0x16

Bit76543210
Address 0x10THL0:[7..0]
Address 0x12THL2:[7..0]
Address 0x14THL3:[7..0]
Address 0x16THL4:[7..0]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Default00000000

THL[0,2..4] - low threshold value for the analog signal on port P[0,2..4], if ADC result is lower than this value, alarm flag is set (see table of states in AFL[0,2..4] / AFH[0,2..4] bits description).

Addresses 0x11, 0x13, 0x15, 0x17

Bit76543210
Address 0x11THH0:[7..0]
Address 0x13THH2:[7..0]
Address 0x15THH3:[7..0]
Address 0x17THH4:[7..0]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Default11111111

THH[0,2..4] - high threshold value for the analog signal on port P[0,2..4], if ADC result is higher than this value, alarm flag is set (see table of states in AFL[0,2..4] / AFH[0,2..4] bits description).

Address 0x1e

Bit76543210
Address 0x1ePWM1:[7..0]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Default11111111

PWM1 - sets the duty cycle of signal on port P1 in PWM mode (OE1 = 1, OC1 = 1), in other modes the parameter does not affect anything. The result duty cycle will be: S = (PWM1 + 1) / 256. The duty cycle S = 0 can be obtained by setting port mode OE1 = 1, OC1 = 0. Setting PWM1 = 255, OE1 = 1, OC1 = 1 corresponds to output logical 1 (high) on port P1.

Address 0x1f

Bit76543210
Address 0x1fOE1OC1DI1unusedunusedAFD1AED1AWD1
AccessR/WR/WRR/WR/WR/WR/WR/W
Default00000000

OE1 and OC1 - port P1 operation mode:
OEOCPort mode
00High impedacne state
01A pull-up resistor is connected between input and VCC
10Output logical 0 (low)
11Output PWM signal
Setting output port mode does not disable input capability (reading/monitoring logical level) of port.

DI1, AFD1, AED1, AWD1 - see DI[0..4], AFD[0..4], AED[0..4], AWD[0..4] bits description respectively.

User data

Bit76543210
Address 0x18unused
Address 0x19unused
Address 0x1aunused
Address 0x1bunused
Address 0x1cunused
Address 0x1dunused
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Default00000000

Addresses are not used by the device, they can be used to store user data.