MATLAB Answers

Using MATLAB, how to change baud rate of data reception from i2c device via arduino?

7 views (last 30 days)
Apz
Apz on 19 Oct 2017
Hi all,
I want to increase the speed of data acquisition from a i2c device connected to matlab (MATLAB 2017a) using arduino. The i2c device data updates maximum at a rate of 1kHz. I need at least 100 data per second from device but data transmission via arduino is too slow. Taking ~60ms for one data read from register of i2c device.
Is there any way to increase the baud rate of data transmission through arduino OR how to change baud rate with matlab?
Or any other suggestion to increase the data transmission speed? Thank you..

Answers (1)

Asif Iqbal
Asif Iqbal on 20 Oct 2017
Hi, So here is just some suggestion. Since in the I2C the clock speed is generated by the Master check the master clock speed. Based on what u wrote it seems like your Arduino board is the master. In that case increase the clock speed of the Arduino. While setting clock speed keep an eye out for "prescaler" related to I2C(There are prescaler for other modules too). what it does is reduces the clock speed u set for your I2C driver. So read the datasheet carefully and set the clock speed. Since the max speed is 1KHz you can set some value close to it. One more thing which might slow your data exchange speed is how much data you exchange during each message. Try to reduce that if possible.
  3 Comments
Jose Marcelo Duarte
Jose Marcelo Duarte on 25 May 2020
Same problem here. I ended up giving up of MATLAB Arduino Support and created my own solution to use Arduino as an I2C/USB-Serial bridge to MatLab. Besides not having a simple solution to change serial port's baund rate, I have founded another problem in MATLAB Arduino Support. I was getting error in a loop of my code where there are an I2C write and an read operations. The MATLAB Arduino Support was silently ignoring some write operation. The problem disaper when I added a long time delay after each I2C operation. My target I2C slave device some times produces a long clock stretching (up to 5 ms). Maybe, the MATLAB Arduino Support does not support clock stretching, and so it is not full compilent with I2C spec.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!