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

2 次查看(过去 30 天)
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..

回答(1 个)

Asif Iqbal
Asif Iqbal 2017-10-20
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 个评论
Francesco campagna
Francesco campagna 2017-11-11
Mee too I had the same problem, since I'm using the library with 'arduino' function for i2C communication, there is no option to increase the Baudrate in this way. Can't find a solution nowhere
Jose Marcelo Duarte
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by