Author Topic: SPI or I2C for optimal energy consumption, EMI and EMC between MCU and Sensor  (Read 397 times)

0 Members and 1 Guest are viewing this topic.

Offline Wilson__Topic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: gb
STM32 MCU links with sensor that has three connection modes, SPI 4 wires, SPI 3 wires and I2C.   

Which mode, data clocking frequency and GPIO speed (4 settings, fast to slow) use minimum battery energy, has best EMI (electromagnetic interference) and EMC (electromagnetic compatibility) performance?

Spacing between MCU and sensor is 15mm.  Sensor data 60 bytes per second.  Two layers PCB, 0.6mm thick.  Only one sensor, no bus.  MCU has enough pin.    3.1 volts for both chip

Many thanks
« Last Edit: May 14, 2024, 10:03:59 pm by Wilson__ »
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21784
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Probably not I2C, due to the pull-ups.  But depending on overall bit rate (length of transaction x how often polled per second) it could be an extremely narrow difference.

On same board, EMC is irrelevant -- that depends wholly on layout and ground integrity.  Short trace lengths mean source termination resistors aren't even important.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: Wilson__

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2633
  • Country: us
Any difference in the power consumed by the interface itself may be swamped by other factors that depend on the sensor and what you're doing with the data.  For example, configuring the GPIOs for higher speed (really, higher drive strength) will certainly consume more power, but if that lets you complete an SPI transaction faster and put the MCU/sensor to sleep sooner, maybe it's a net reduction in energy consumed.  If you are trying to complete an operation quickly and get back to sleep, SPI will give a substantially shorter transaction, since it'll be higher speed and doesn't require addressing or start/stop signals.   If by "mode" you mean SPI mode (clock polarity/phase), I can't see how that would make a difference, you will have the same number of bits and clock transitions in any case -- and likely you don't have much choice anyway, since you'll need to use a mode supported by the sensor.

It's possible that the sensor could operate differently depending on the interface, for example if certain functions are only supported via one or the other, and that could have an impact on its power consumption as well.  You'd really have to look at a lot of the details of the application to say anything for sure, but if there is a difference in energy consumption, I would bet SPI is the winner.
 
The following users thanked this post: Wilson__

Offline exmadscientist

  • Frequent Contributor
  • **
  • Posts: 351
  • Country: us
  • Technically A Professional
Very general rules of thumb:

1. I2C is kind of crap. If you have two design ideas, of roughly equal cost/complexity/general pain, and one uses I2C and one doesn't, it's probably best to choose the other one. (But there are a lot of I2C parts out there and they do bring advantages, so the general-pain-level is rarely equal.)

2. Most problems with I2C arise when it leaves your PCB. If you can keep I2C on your board, you probably don't need to worry too much about it. Probably. Conversely, if you are planning to take I2C off-board to any significant degree, it can be worth investing a lot of time into either not doing this or doing it carefully.
 
The following users thanked this post: Wilson__

Offline Wilson__Topic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: gb
What ballpark SPI clock frequency you 'feel' comfortable in this case?   0.5 to 10 MHz sounds right???
 
MCU and sensor rated 24MHz and 17MHz.   PCB trace 15mm and is short in wavelength of un-wanted emission antenna.

Driven cap 10pF.  5pF MCU pin, unspecified on sensor, and pcb trace capacitance (0.75pF per 15mm)

Faster SPI clock means chips can finish and back to sleep sooner and save waken time battery usage.    But, not want to get too high that it generate too much EMI.

Many thanks
 

Online dietert1

  • Super Contributor
  • ***
  • Posts: 2134
  • Country: br
    • CADT Homepage
I2C is half the pin count in case it matters. SPI pin count increases with the number of devices. At least one extra pin per device. Sometimes a device needs an interrupt pin in addition to its chip select.
SPI is 100x or so faster.
In very low power designs the power consumption of I2C pull-ups and the increased up-time of the CPU matter.

Regards, Dieter
 
The following users thanked this post: Wilson__

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7452
  • Country: nl
  • Current job: ATEX product design
What ballpark SPI clock frequency you 'feel' comfortable in this case?   0.5 to 10 MHz sounds right???
 
MCU and sensor rated 24MHz and 17MHz.   PCB trace 15mm and is short in wavelength of un-wanted emission antenna.

Driven cap 10pF.  5pF MCU pin, unspecified on sensor, and pcb trace capacitance (0.75pF per 15mm)

Faster SPI clock means chips can finish and back to sleep sooner and save waken time battery usage.    But, not want to get too high that it generate too much EMI.

Many thanks
If it's a 4 layer board with a full GND and VCC plane, you can easily run it at the full rated speed. Verify the end result with a scope, decrease it only if it's marginal on the timing characteristics.
The EMI generated is the same, since what makes the most EMI is the edge rate of your digital signals, not your clock rate.
I2C is half the pin count in case it matters. SPI pin count increases with the number of devices. At least one extra pin per device. Sometimes a device needs an interrupt pin in addition to its chip select.
SPI is 100x or so faster.
In very low power designs the power consumption of I2C pull-ups and the increased up-time of the CPU matter.

Regards, Dieter

On low power systems, you make the I2C transactions with a DMA and a sleeping core.
 
The following users thanked this post: Wilson__


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf