Mini Multi Function Expansion Board
The Mini Multi Function Expansion Board is a small device that provides 5
analog inputs and a 1-wire interface that can handle up to 64 temperature
sensors. On demand, the device will learn the serial numbers of all devices
present on the 1-wire bus. The board supports the DS1820, DS18S20, and
DS18B20 temperature sensors.
If the COUNTER symbol is defined when building the project, one of the analog
inputs is instead configured to count pulses using an 8-bit counter with an
optional 8-bit pre-scaler. With a small modification of the circuitry
(accompanied by the appropriate code changes) it is also possible to provide
an input that can count pulses using a full 16-bit counter.
One additional screw terminal, connected to another I/O pin of the PIC, has
already been provided in the design. This connection may be used by the
firmware as a method to put the device in self-program
mode.
Another option is to use it to accurately measure time intervals. For
example to measure the time between pulses of an electricity meter. Based on
the measured interval, the current power consumption can be calculated.
Click on the images below for the schematic and a proposed circuit board
layout that can easily be built on a piece of perf board.
Here's a picture of the finished device:
Operation
The device has I2C slave address 0x58. Using the HomeVisionXL I2C commands
the device can be configured and controlled. Configuring the device is done
by writing a byte with the two most significant bits set. The lower six bits
control which setting is being configured:
- 11000100
- Discover 1-wire devices. This operation takes a few milliseconds for
each connected device. So allow some time before continuing to communicate
with the device.
- 11010000
- Enter program mode.
- 111yxxxx
- Configure pulse counter, where:
- y=edge:
- 0=rising
- 1=falling
- xxxx=prescaler:
- 0000=1:1
- 0001=1:2
- 0010=1:4
- 0011=1:8
- 0100=1:16
- 0101=1:32
- 0110=1:64
- 0111=1:128
- 1000=1:256
Writing other values selects which information will be returned when
subsequently reading a byte from the device:
- 00000000
- Status flags. See below for the meaning of each individual flag.
- 00000001
- Temperature sensor group flags.
- 00000010
- Number of discovered 1-wire devices.
- 00000011
- Pulse count. Reset to 0 after reading the value.
- 00001xxx
- A/D Value (last 3 bits select the A/D port).
- 00010xxx
- Temp sensor flags (last 3 bits select the group).
- 01xxxxxx
- Temperature (last 6 bits select the sensor).
- 10xxxxxx
- Sensor family code (last 6 bits select the sensor). This will report 16
(0x10) for DS1820 and DS18S20 devices and 40 (0x28) for DS18B20 devices.
The meaning of the status flags is as follows:
- bit 0
- Analog input 0 has changed. Cleared after reading the status flags.
- bit 1
- Analog input 1 has changed. Cleared after reading the status flags.
- bit 2
- Analog input 2 has changed. Cleared after reading the status flags.
- bit 3
- Analog input 3 has changed. Cleared after reading the status flags.
- bit 4
- Analog input 4 has changed. Cleared after reading the status flags.
- bit 5
- Temperature has changed. Cleared after reading the status flags.
- bit 6
- Pulse count has changed. Cleared after reading the pulse count.
- bit 7
- 1-Wire devices detected on the bus.
The status byte allows very efficient access to the device by the Homevision
controller. Your schedule would just regularly check the status byte. Only
if the bit for any of the used analog inputs is set, it should write a byte
selecting that input and reading the value. Similarly with the pulse count.
When bit 5 is set, you can read the temperature sensor group flags to find
which groups of 8 temperature sensors have detected a change. Next you read
the temperature sensor flags for those groups to determine which sensors
within the group have changed.
Downloads
Last modified: 21 Mar 2021, 09:47 CET
|