I²C bus communication with digital HMI, HDI, HCLA

I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
1
INTRODUCTION
2
The digital HMI, HDI, HCLA, HCA and SSI
pressure sensors are calibrated and
temperature compensated with an on-board
ASIC, which provides a corrected digital
pressure value. For the HDI, HCLA, HCA and
SSI series an additional analog voltage output is
available at the same time. The response time
of the sensors depend on the adjusted internal
resolution. For 12 bit it is typ. 0.5 ms.
The HMI, HDI, HCLA, HCA and SSI pressure
sensors are configured to comply with the I²C
bus protocol.
I²C BUS PROTOCOL
2.1 General characteristics
Two lines, a serial data line (SDA) and a serial
clock line (SCL), carry information between the
devices connected to the bus (see Fig. 1). Any
device with I²C compatible protocol can be
attached to the bus. Both SDA and SCL are
bidirectional lines, connected to a positive
supply voltage via pull-up resistors (see section 4
Application Circuit). When the bus is free, both
lines are HIGH. They can only be pulled LOW by
the devices connected to the bus.
The I²C bus is a simple, serial 8-bit oriented
computer bus for efficient Inter-IC (acronym I²C)
control. It provides good support for
communication between different IC’s across
short circuit-board distances, such as
interfacing microcontrollers with various lowspeed peripheral devices. Each device
connected to the bus is software addressable
by a unique address and a simple master-slave
relationship exists at all times. The I²C bus
requires only two bi-directional bus lines, a
serial data line (SDA) and a serial clock line
(SCL). The data transfer rate is freely selectable
and can be max. 400 kbit/s.
SCL
SDA
Master
Slave
Fig. 1:
Slave
Slave
Example of an I²C bus configuration
E / 11155 / D
1/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
SDA
Master-Transmitter
Slave-Receiver
SCL
SDA
Master-Receiver
Slave-Transmitter
SCL
Fig. 2:
I²C master-slave concept
2.2 Master-slave concept
2.3 Data validity
The I²C bus uses a simple master-slave
concept. The master initialises a data transfer
(START command), generates the clock (SCL)
signal and terminates the transfer (STOP
command). Any device addressed by the
master is considered a slave.
Data is only valid during the HIGH period of the
clock. During this HIGH period the data on the
SDA line must be stable HIGH to transmit a “1”
or stable LOW for a “0”. The HIGH or LOW
state of the data line is only allowed to change
when the clock signal on the SCL line is LOW
(see Fig. 3).
Masters and slaves can operate as either
transmitters or receivers, depending on their
function (see Fig. 2). The transmitter is the
device that sends data to the bus. A transmitter
can either put data on the bus on its own accord
(master-transmitter), or in response to a
request from the master (slave-transmitter).
The receiver is the device that receives data
from the bus. A receiver can either receive data
on its own request (master-receiver) or in
response to a request from the master (slavereceiver).
NOTE:
The digital HMI, HDI, HCLA, HCA and
SSI pressure sensors are designed to
work as slave-transmitters and will
therefore only respond to requests
from a master device.
E / 11155 / D
SDA
SCL
Data Data
valid allowed
to change
Fig. 3:
I²C bus data validity
2/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
2.4 START (S) and STOP (P) conditions
2.5 Byte format
Prior to any transaction on the bus, a START
condition needs to be issued. The START
condition acts as a signal to all connected IC’s
that something is about to be transmitted on the
bus. As a result, all connected devices will listen
to the bus and the bus is considered to be busy.
After a message has been completed, a STOP
condition is sent by the master. In this way the
master can notify that no further data will be
received or sent. This is the signal for all
devices that the bus is idle again. START and
STOP conditions are always generated by the
master.
Every byte put on the SDA line must be 8-bits
long. Data is transferred with the most
significant bit (MSB) first and the other bits
following down to bit 8, the least significant bit
(LSB). As you can see in Fig. 5, the bit
representing decimal number 128 will be
transmitted first (MSB).
The START condition is defined as a HIGH to
LOW transition on the SDA line while SCL is
HIGH. The STOP condition is defined as a
LOW to HIGH transition on the SDA line while
SCL is HIGH (see Fig. 4).
SDA
SCL
START
condition
Fig. 4:
STOP
condition
MSB
D u al
0
Decimal
Fig. 5:
1
1
0
1
1
0
1
128 64
32
16
8
4
2
1
I²C bus byte format
2.6 Addressing and data direction
The first byte after the START condition
determines which slave will be selected by the
master. Each slave has a unique address to
identify it on the bus. This address is 7 bits long
followed by bit 8 which is the data direction bit
(R/W) (see Fig. 6). A ‘0’ for the R/W bit
indicates that the master wants to transmit
information to a selected slave (WRITE), a ‘1’
indicates that the master requests information
from the slave (READ).
MSB
LS B
7 bit address
I²C bus START and STOP conditions
b7
Fig. 6:
E / 11155 / D
LS B
b6
b5
b4
b3
R/W
b2
b1
b0
I²C bus address byte
3/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
When an address is sent, each device in the
system compares the first seven bits after the
START condition with its own address. If they
match, the device considers itself addressed by
the master as a slave-receiver or slavetransmitter, depending on the R/W bit.
The 7-bit addressing allows 128 (27) different
addresses on the same bus. Since 16
addresses are reserved (in the Phillips
specification), in practice 112 addresses remain
for communication on the bus. However, the
total number of devices connected to the bus is
limited by the maximum bus capacitance
CSDA=400 pF.
A slave address can be made-up of a fixed and
a programmable part. Typically, the four most
significant bits are fixed and assigned to
specific categories of devices. The three least
significant bits are programmable through
hardware address pins allowing up to eight (23)
devices of identical categories on the same I²C
bus.
2.7 Acknowledge (ACK or A)
Each byte sent on the bus has to be followed by
an acknowledge bit issued from the receiver for
correct receipt of data. The acknowledge also
means that the device is ready to continue the
data transfer.
The master must generate an extra clock pulse
for this purpose. The transmitter releases the
SDA line (HIGH) during the acknowledge clock
pulse. The receiver must pull down the SDA line
so that it is stable LOW from the beginning
(rising edge) of the acknowledge clock pulse
until its end (LOW level after falling edge) (see
Fig. 7).
If the receiver does not want to receive a further
byte it leaves the SDA line HIGH and a not
acknowledge (NACK or A) will be sent. Now the
master can terminate the transfer with a STOP
condition.
NOTE:
The digital I²C bus pressure sensors of
the HMI, HDI, HCLA, HCA and SSI
series have a general preconfigured
slave address (0x1111000b). By factory
programming it is possible to define an
additional secondary slave address for
each individual device. According to I²C
bus specification 127 different
addresses are available. The sensor will
then listen to both slave addresses.
E / 11155 / D
4/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
Data from
transmitter
Data from
receiver
SCL
1
2-8
START
condition
Fig. 7:
9
ACK
Acknowledge (ACK) on the I²C bus
2.8 Data transfer overview
A complete data transfer is shown in Fig. 8.
After the START condition, the slave address is
sent. The data direction bit (R/W) determines
whether it is a READ or WRITE transfer. The
addressed slave acknowledges (ACK) the
correct receipt of the first byte. Now an
unrestricted number of data bytes can be
transmitted, always followed by an
acknowledgement.
The data transfer is always terminated by a
STOP condition generated by the master. If the
master afterwards wishes to continue the
communication, it has to generate a new
START condition and initiate a new data
transfer.
SDA
1-7
8
Address
R/W
9
1-8
9
1-8
9
ACK
Data
ACK
Data
NACK
l
SCL
START
condition
Fig. 8:
STOP
condition
Complete I²C bus data transfer
E / 11155 / D
5/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
3
DATA TRANSFER WITH HMI, HDI,
HCLA, HCA AND SSI PRESSURE
SENSORS
Data Byte 1
Data Byte 2
X P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0
Relevant data
The digital HMI, HDI, HCLA, HCA and SSI
pressure sensors are designed to work as
slave-transmitters and will therefore only
respond to requests from a master device.
Fig. 10: Two data bytes containing the pressure
value as a 15 bit information
NOTE:
With a SCL clock frequency of 400 kHz
the exchange of the 2 data bytes
containing the current pressure value
takes about 40 µs. However, the internal
sensor conversion cycle to obtain a
new pressure value is 250 µs for 12 bit
resolution. Therefore, if the sensors are
not deactivated they will send up to 7
times the same digital pressure value.
For further information please contact us.
3.1 Pressure reading
To read out a pressure value the master
generates a START condition and sends the
sensors slave address (either the hard codeded
addess 0x1111000bin or the secondary factory
programmed address) followed by a READ
command (R/W=1) (see Fig. 9). At the moment
of the first acknowledge (A) from the sensor,
the master-transmitter becomes a masterreceiver. The sensor starts to send two data
bytes containing the current pressure value as
a 15 bit information placed in the output
registers of its ASIC (see Fig. 10). The master
must acknowledge the reception of the first
data byte. To terminate the pressure reading
from the sensor the master sends a STOP
condition. The sensor is also able to send
pressure values “online”. That means if the
master does not send a STOP condition but an
acknowledge after the third exchanged byte the
sensor-slave will go on sending the last
available pressure value when it is clocked.
1
S Slave Address R/W A
Data Byte 1
3.2 Optional temperature reading
As an option the sensors can be factory
configured to deliver an additional 15 bit
temperature reading. This will then be
transmitted as a 3rd and 4th byte after the
pressure value. If there is an acknowledge sent
after these two additional bytes the sensor will
continue sending alternating pressure and
temperature values until it is deactivated by a
STOP condition.
A
Data Byte 2
generated by slave
n Data Bytes
A P
Read out of n
pressure values
Read out of first pressure value
generated by master
A
S = START condition
Data Byte 1 = High Byte (MSB first)
A = Acknowledge
Data Byte 2 = Low Byte (LSB last)
A = Not Acknowledge
P = STOP condition
Fig. 9:
Readout of digital pressure information using I²C bus protocol
E / 11155 / D
6/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
3.3 Calculation of the actual pressure
value from the digital pressure word
For an actual digital pressure reading of
P counts = 5080 counts hex = 20608 counts dec
The following formulas show how to calculate
the actual pressure value from the digital
sensor output:
Definitions:
S
= Sensitivity [counts/mbar]
Outmax = Output @ max. pressure [counts]
Outmin = Output @ min. pressure [counts]
Pmax
= Max. value of pressure range [mbar]
Pmin
= Min. value of pressure range [mbar]
P
= Pressure reading [mbar]
Pcounts = Digital pressure reading [counts]
Out max − Out min
S=
Pmax − Pmin
P=
Pcounts − Out min
+ Pmin
S
the actual pressure in mbar can be calculated
from equation (2) to be
P=
20608 counts − 1638 counts
+ 0 mbar = 36,18 mbar
524,28 counts / mbar
This pressure reading is calculated with the
typical calibration values, not taking into account
that the individual sensor calibrations might
differ within the tolerances specified in the HCLA
data sheet.
3.4 Resolution of data
(1)
(2)
The following example shows the calculation for
a HCLA0050…U device (pressure range 0…50
mbar unidirectional). Please refer to the HCLA
data sheet for the specified calibration values.
Outmin = 0666 counts hex = 1638 counts dec
Out max = 6CCC counts hex = 27852 counts
dec
Each temperature and pressure value will be
transmitted as a 15 bit word. However, the
actual resolution can be less than this
depending upon how the internal A/D-converter
is configured. Also internal calculations and
signal windowing will reduce the effective
resolution. The standard resolution for pressure
measurement is set at 12 bits, which results in
an effective resolution of 11 to 12 bits. For
temperature measurement the limiting factor is
the sensitivity of the sensing element. For
further information please contact us.
With equation (1) the sensitivity of the sensor
gives
S=
27852 counts − 1638 counts
= 524,28 counts/mbar
50 mbar − 0 mbar
E / 11155 / D
7/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
3.5 Timing parameters
Parameter
Symbol
Min.
tBUF
1.3
tHD.STA
0.8
LOW period of SCL
tLOW
1.3
HIGH period of SCL
tHIGH
0.6
Setup time repeated START condition
tSU.STA
1
Data hold time
tHD.DAT
0
Data setup time
tSU.DAT
0.2
Bus free time between STOP and START condition
Hold time (repeated) START condition, to first clock pulse
Typ.
Max.
Unit
µs
Rise time of both SDA and SCL
tR
0.3
Fall time of both SDA and SCL
tF
0.3
Setup time for STOP condition
tSU.STO
0.6
Table 1: Timing parameters for I²C bus communication with HMI, HDI, HCLA, HCA and SSI pressure sensors
tSU;DAT
tHD;DAT
tSU;STA tHD;STA
tR
tSU;STO tBUF
tHD;STA
tF
SCL
SDA
tHIGH
tLOW
SCL
SDA
Fig. 11: I²C bus timing characteristics
E / 11155 / D
8/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
Parameter
Symbol
Min.
Typ.
Max.
Input high level
90
100
Input low level
0
10
Output low level
Unit
% of V s
10
Pull-up resistor
Ω
500
Load capacitance @ SDA
C SD A
400
Input capacitance @ SDA/SCL
CI2C_IN
10
FSC L
SCL clock frequency
100*
pF
400
kHz
* recommended
Table 2: I²C bus communication parameters for HMI, HDI, HCLA, HCA and SSI pressure sensors
3.6 Communication parameters
The maximum allowed communication speed
on the bus depends on the configured internal
clock frequency of the HMI, HDI, HCLA, HCA
and SSI pressure sensors. It is 400 kHz in the
standard configuration.
If both digital and analog interfaces are used in
parallel it is recommended to separate these
lines as far as possible from each other.
Further, decoupling capacitors of 220 nF
between supply and ground and 15 nF between
the analog output and ground are beneficial. It
is important to place the capacitors as close to
the pins as possible.
3.7 Signal noise due to communication
4
As the pulses transmitted on the two bus lines
have very sharp edges, this can cause some
electromagnetic interference. Especially for
very low pressure values and small PCB
designs, these spikes can influence the analog
millivolt measurement of the sensor bridge and
downgrade signal quality.
NOTE:
To prevent signal noise we recommend
a min. clock frequency of 100 kHz (max.
400 kHz) and transmission breaks of
min. 500 µs between two pressure
readings. This is especially valid for low
pressure devices up to 25 mbar. Please
contact us for more information.
APPLICATION CIRCUIT
Both SCL and SDA lines have to be connected
to a 5 V supply voltage via pull-up resistors RP
as shown in Fig. 12. We recommend to use
1.5 kΩ resistors. Additionally, serial resistors RS
of max. 240 Ω should be used in each
communication line.
+VS
R
P
SCL
SDA
R
P
R
S
Sensor
R
S
Fig. 12: I²C bus application circuit for HMI, HDI,
HCLA, HCA and SSI pressure sensors
E / 11155 / D
9/10
www.first-sensor.com
www.sensortechnics.com
I²C bus communication with digital HMI, HDI, HCLA, HCA and SSI
pressure sensors
5
SAMPLE PROGRAM CODE
byte byte_msb, byte_lsb;
int16 pressure;
// 8bit values
// 16bit value
// Set I2C unit to I2C master mode, clock speed 100 kHz and 7 bit addressing
configureI2C (I2C_MASTER | CLK_SPEED_100KHZ | ADDRESSING_7BIT);
// Set the target address of the sensor (0x78 = 120dec)
I2C_set_target(0x78);
// Send start condition for reading from sensor (slave)
I2C_send_start_read();
// Read first (MSB) data byte and answer with ACK (continue communication)
I2C_read (&byte_msb, SEND_ACK);
// Read second (LSB) data byte and answer with NACK (end communication)
I2C_read (&byte_lsb, SEND_NACK);
// Send Stop condition
I2C_send_stop();
// Put both values together
pressure = ((int16)byte_msb << 8) | byte_lsb;
6
TROUBLESHOOTING
6.1
Sensor does not respond
· For HDI, HCLA, HCA, SSI only:
Check the analogue output signal of the
sensor. If it responds to pressure changes the
sensor works. Then, errors of the digital output
can be limited to problems of the I²C bus.
· Switch the supply voltage on and off in order
to restart the sensor.
· Check the acknowledge signals (ACK or
NACK) and the STOP condition from the
master in the application circuit. If the sensor
has stopped the communication due to an
error, it has to be restarted by power off and on.
Please contact us for further information:
6.2
Sensor supplies unstable data
· Have the advices regarding signal noise
under point 3.7 been followed?
E / 11155 / D
www.sensortechnics.com/contact
[email protected]
10/10
www.first-sensor.com
www.sensortechnics.com