2

Lets say I have a sensor connected to Arduino Uno Rev3's I2C Bus. I am reading the sensor output and using Serial.print() to send the sensor reading back to a my laptop.

I am trying to understand the bottlenecks that limits the sensor sampling rate received at the laptop.

The sampling rate of the sensor depends on many factors. Lets assume sensors sampling rate is not limited. That would mean I am limited by how much data each intermedia bus can carry before it reaches the laptop. For example, I am limited by I2C bus atmega328p is using to read the sensor data. I am also limited by the UART bus atmega16u2 is using to send the data to my laptop. Am I correct so far? Also, on what bus atmega328p and atmega16u2 are connected over?

3
  • refer to the sensor datasheet
    – jsotola
    Feb 5, 2022 at 5:48
  • Are you using I2C Fast Mode (400kHz) (if the sensor is even capable of that)? If not, then the I2C interface is probably the bottleneck (assuming that the sensor samples fast enough)
    – chrisl
    Feb 5, 2022 at 10:13
  • @chrisl I am using MPU6050 on I2C 400KHz. On Spec, the sensor can sample from 4 to 1kHz, but I am applying a digital low pass filter that adds 19ms delay. So the sensor sampling rate is too slow already. But still I am trying to understand the intermediate steps so better understand the hardware. Feb 5, 2022 at 18:03

2 Answers 2

3

If there had been a specific scenario you were considering, it might help to share. There's quite a lot to think about with just theoretical assumptions.

That would mean I am limited by how much data each intermedia bus can carry before it reaches the laptop

Yes, mostly yes. The bandwidth of the entire transmission interface which includes the I2C interface, ATMEGA328P, connection to ATMEGA16U2, and the USB interface would account for the theoretical max sampling rate of the sensor.

For some cases, you may need to consider the latency as well as the bandwidth of the transmission media, which would include the I2C interface, ATMEGA328P, ATMEGA16U2, and the USB interface. The sensor may require some calculations which may result in some delay. The I2C interface or the UART interface could introduce some delay too, especially if it's driven by bit-banging(although probably not with 328P).

Also from 328P's perspective here, it has to receive data from the sensor, make calculations from the incoming raw data if needed, and send over the UART interface to the 16U2. Most of these processes will happen step by step and if the combined processing time takes longer than the delay between each sample coming from the sensor, the 328P itself could theoretically be a bottleneck too.

1
  • Thanks for the detailed answer. That cleared things up. Feb 5, 2022 at 17:56
2

Also, on what bus atmega328p and atmega16u2 are connected over?

See:

https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf

They are connected by TxD and RxD.

Without seeing your code (hint) it is extremely difficult to say. Perhaps a faster baud rate would help.

6
  • Thanks, I just wanted to know that atmega16u2 and atmega328p are connected via UART. Do Serial.begin also set the baud rate of this connection as well? Feb 5, 2022 at 17:58
  • @QuaziIrfan, only there
    – Juraj
    Feb 6, 2022 at 6:55
  • @Juraj Sorry, I don't get what you mean. Feb 6, 2022 at 11:14
  • @QuaziIrfan, USB line doesn't use that baud rate
    – Juraj
    Feb 6, 2022 at 11:57
  • So, is there a fixed baud rate that's set during the manufacturing process? Feb 6, 2022 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.