Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)

This article discusses special considerations and methods related to the Serial Peripheral Interface (SPI) protocol used to communicate digitally with LME and LDE series pressure sensors.

Scope

It is beyond the scope of this article to define the SPI protocol itself; many excellent resources on the topic are readily available for reference1.

It is also outside of the scope of this article to discuss the application of LDE devices for analog output and/or as drop-in replacements for LBA devices. For more information on this, refer to the LDE datasheet.

LDE/LME Device Overview

Basic Overview of Device Operation

LDE and LME series low differential pressure sensors operate on the thermal-anemometer principle, where a heating element is bounded by a symmetrical arrangement of downstream and upstream temperature sensors. A flow across this sensing element is developed by a differential pressure applied across the device’s ports. As pressure (and thus flow) increases, the heater’s temperature profile shifts next to one or the other temperature sensor; this difference between the downstream and upstream pressure can thus be extrapolated to the applied differential pressure.

The voltage output of this sensing element is acquired and converted to a digital signal by the embedded microcontroller's ADC. Processing is performed to linearize the output and tare offset, and a digital output is then allowed to pass to either a DAC to provide an analog output signal, or to the serial interface for transfer over the SPI bus

Hardware Block Diagrams/Explanation of Differences

While the overview of the device in the earlier paragraph helps understand the working of the sensor, there are slight differences in the underlying architecture of the LDE/LME series sensors, based on their supply voltage.

5 V LDE/LME devices

At its essence, the LDE/LME devices consist of a microcontroller and a sensor bridge (Figure 1). The pressure measurements of the sensor may be requested over the SPI bus. This protocol is also used for individual calibration of each device, and thus it is important that the communication protocol described in section (Major Specifications for SPI Bus Communication) is implemented carefully. The device firmware could become corrupted if the communication protocol is not carefully implemented.

Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)

Figure 1. This block diagram excludes supply connections to only show signal paths. Image Credit: First Sensor

3 V LDE Devices

The 3 V LDE device is identical to the 5 V device, except for the use of a level shifter on the SPI bus (Figure 2). In addition, but not shown, a voltage converter is used to provide the microcontroller and the sensor bridge with the required 5 V from the 3 V supply voltage.

This level shifter translates logic voltages from the native 5 V of the sensor microcontroller down to 3 V. Due to this hardware addition, it is essential for the microcontroller driving the SPI bus to be able to source a minimum 2 mA current to ensure proper communication.

Figure 2. This block diagram excludes supply connections to only show signal paths. Image Credit: First Sensor

Major Specifications for SPI Bus Communication

The pressure measurement result of the sensor may be requested over the SPI bus. As described in the LDE/LME datasheet, this is performed by sending three successive commands, MSB first, to the sensor:

Step Hexadecimal Binary Description
1 0x2D B00101101 Poll current pressure measurement
2 0x14 B00010100 Send result to data register
3 0x98 B10011000 Read data register

 

As per the standard SPI protocol, each command is sent in the following manner:

  1. Assert /CS low to allow communication with the sensor.
  2. For each bit of the command (MSB first),
    - set the MOSI line to the correct logic level for the current bit;
    - pulse the SCLK line.
  3. Assert /CS high to disable communication with the sensor.

This is followed by reading out the entire two-byte result on the MISO pin, MSB first, by applying 16 successive pulses on the SCLK line while /CS is asserted low.

  /CS should be held high every time the SPI master device does not communicate with the sensor.

It is also essential to ensure that the timing between signals on the SPI bus adheres to the Interface specification criteria in the LDE/LME datasheet.

LDE Evaluation Kit

There is an evaluation kit available for LDE devices.

Difference Between Evaluation Kit and Datasheet Communication Protocols

The evaluation kit and its associated Windows® software interacts with the installed LDE devices through a proprietary communication protocol over the SPI bus. This specialized protocol offers the evaluation software with the commands for requesting a pressure measurement as documented on the LDE datasheet, as well as access to otherwise non-user-accessible areas of the LDE device's flash memory.

Users must be aware of this custom protocol should they attempt to observe the evaluation kit's SPI bus signals, as it may not aid any efforts in debugging their own code.

Hardware Connection Considerations

For the sensor pinout, see the LDE/LME datasheet.

The connections listed under “Digital Output Connection” in the following table are essential for digital communication over SPI bus.

Description Digital Output Connection LDE Pin LME Pin
Reserved No connection 1 N/A
Voltage supply Supply voltage 2 1
Ground Ground 3 2
Analog output No connection 4 3
Analog output No connection 5 4
SPI clock Master microcontroller’s SPI clock pin 6 5
SPI Master Out Slave In (MOSI) Master microcontroller’s MOSI pin 7 6
SPI Master In Slave Out (MISO) Master microcontroller’s MISO pin 8 7
SPI slave select Master microcontroller’s slave select pin 9 8
Reserved No connection 10 N/A

 

Simple Point-To-Point Connection

With regard to single LDE/LME 5 V devices (and LDE 3 V devices with a microcontroller capable of driving the SPI bus with 2 mA per line), the pins for the SPI bus may be directly joined between the microcontroller and the sensor. Additional external components are not required.

Use of Pull-Up Resistors

The use of pull-up resistors is basically not needed for SPI as most master devices are configured for push-pull mode. However, if pull-up resistors are required for use with 3 V LDE devices, they should be greater than 50 kΩ.

Use of Series Resistors and Optional Buffers

There are some application cases where 33 Ω series resistors at both ends of each SPI bus line may be helpful. It is also possible to further improve signal quality by adding buffers or line drivers, such as a 74HC125, on each line as well.

These application cases include:

  • using a master device with limited bus driving capability;
  • multiple slave devices on the same bus segment;
  • long SPI bus lines.

Figure 3 shows both these topologies.

If series resistors are used, they must be physically placed as close as possible to the pins of slave and master devices.

Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)

Image Credit: First Sensor

Software considerations

A very specific sequence of events, controlled by software running on the SPI master device, is needed for the flow of data to and from the LDE/LME device.

UML Activity Diagram

Shown in Figure 4 is the UML activity diagram that describes the sequence of actions to be performed by the SPI master device to read a pressure measurement in Pascals from an LDE/LME device.

Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)

Image Credit: First Sensor

Sample Code

The sample code shown below provides a generic example of code that can be used to implement the pressure-reading operation illustrated in Figure 4 above. The pin numbers indicated are randomly selected and will differ with the SPI master device being used.

It must be remembered that the microcontroller used may require that the pins are set as either outputs or inputs:

– CS_PIN → OUTPUT
– MOSI_PIN → OUTPUT
– SCLK_PIN → OUTPUT
– MISO_PIN → INPUT

This code listing ignores setting the pin mode as the method considerably differs between microcontrollers. This code listing also ignores the timing requirements for the bus for the same reason.

Image Credit: First Sensor

Image Credit: First Sensor 

Image Credit: First Sensor

Troubleshooting

 

The following steps may help to resolve difficulties in communicating with the sensor over SPI:

  1. If using an LDE device, confirm that the sensor works normally in a First Sensor evaluation kit to rule out damage to the sensor or firmware corruption.
  2. Test code using a simple, short and direct point-to-point connection between the SPI master device and the sensor.
  3. Ensure that the SPI bus lines are connected correctly:
    MISO ↔ MISO
    MOSI ↔ MOSI
    SCLK ↔ SCLK
    /CS ↔ /CS
  4. Ensure that the code implementation uses SPI Mode 0 (CPOL=0, CPHA=0).
  5. Ensure that data is sent and received MSB first.
  6. Visualize the SPI bus on an oscilloscope to confirm that commands are being sent correctly and that /CS is being appropriately toggled (LOW to enable, HIGH on idle).

1 Useful reference materials include:

1. AN991, “Using the Serial Peripheral Interface to Communicate Between Multiple Microcomputers”, Motorola Inc., 1987.
2. “Serial Peripheral Interface Bus”, Wikipedia (http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus), accessed 17 September, 2014.
3. The manufacturer’s datasheet and any relevant application notes for the SPI master device intended to be used.

This information has been sourced, reviewed and adapted from materials provided by First Sensor AG.

For more information on this source, please visit First Sensor AG.

Citations

Please use one of the following formats to cite this article in your essay, paper or report:

  • APA

    First Sensor AG. (2020, October 19). Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI). AZoSensors. Retrieved on April 24, 2024 from https://www.azosensors.com/article.aspx?ArticleID=785.

  • MLA

    First Sensor AG. "Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)". AZoSensors. 24 April 2024. <https://www.azosensors.com/article.aspx?ArticleID=785>.

  • Chicago

    First Sensor AG. "Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI)". AZoSensors. https://www.azosensors.com/article.aspx?ArticleID=785. (accessed April 24, 2024).

  • Harvard

    First Sensor AG. 2020. Using Pressure Sensors to Discuss Special Considerations Related to the Serial Peripheral Interface (SPI). AZoSensors, viewed 24 April 2024, https://www.azosensors.com/article.aspx?ArticleID=785.

Tell Us What You Think

Do you have a review, update or anything you would like to add to this article?

Leave your feedback
Your comment type
Submit

While we only use edited and approved content for Azthena answers, it may on occasions provide incorrect responses. Please confirm any data provided with the related suppliers or authors. We do not provide medical advice, if you search for medical information you must always consult a medical professional before acting on any information provided.

Your questions, but not your email details will be shared with OpenAI and retained for 30 days in accordance with their privacy principles.

Please do not ask questions that use sensitive or confidential information.

Read the full Terms & Conditions.