Pulse9
Posts: 5
Joined: Tue May 28, 2013 3:10 pm

I2C tools Speed <Solved>

Sat Jul 06, 2013 6:31 pm

Hello all, I'm trying to read the samples of a BMA180 Accelerometer, I'm using the i2cget to get the values of each axis, I did a script in bash with a while true to read the values and concatenate in a txt file, and running the script with timeout 1s, but when it finish it only show that there is ~50 samples of the BMA180 per second, I modify the registers the decrease the bw (page 30 of the datasheet) to get more samples but didnt work.. is there a way to improve the i2cget speed? so i can get more samples per second? (sorry for my english)
Last edited by Pulse9 on Sun Jul 07, 2013 2:52 pm, edited 1 time in total.

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C tools Speed

Sat Jul 06, 2013 6:43 pm

I'm surprised you are getting even that many with bash. You could try C.

Pulse9
Posts: 5
Joined: Tue May 28, 2013 3:10 pm

Re: I2C tools Speed

Sat Jul 06, 2013 6:51 pm

Isnt using direct bash script fastest than C?

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C tools Speed

Sat Jul 06, 2013 7:26 pm

If you are determined to use i2cget then C wouldn't be dramatically faster then bash.

You can access the i2c device directly.

Pulse9
Posts: 5
Joined: Tue May 28, 2013 3:10 pm

Re: I2C tools Speed

Sat Jul 06, 2013 7:45 pm

Is there a library of C that recommend me? I need to get at least 150 samples per second and I only have ~50, how can i improve the i2c communication to get more samples? Thanks a lot

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C tools Speed

Sat Jul 06, 2013 7:55 pm

Personally with C I just open /dev/i2c-0 or /dev/i2c-1 as files and use read and write.

If you need a C wrapper both http://www.airspayce.com/mikem/bcm2835/ and http://wiringpi.com/ provide them.

Python also provided wrappers.

Pulse9
Posts: 5
Joined: Tue May 28, 2013 3:10 pm

Re: I2C tools Speed

Sun Jul 07, 2013 4:47 am

SOLVED Thanks a lot joan you were right I used C and I got ~1000 samples per second! This is an interesting page to check for performance in different languages Thanks a Lot

http://codeandlife.com/2012/07/03/bench ... pio-speed/

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C tools Speed

Sun Jul 07, 2013 7:56 am

Well done! Quite an improvement.

xerpi
Posts: 6
Joined: Mon Jul 01, 2013 7:25 pm
Location: Barcelona

Re: I2C tools Speed

Sun Jul 07, 2013 12:59 pm

Pulse9 wrote:Isnt using direct bash script fastest than C?
C is compiled to machine code, so the resulting program will be executed directly by the CPU, whereas bash is interpreted, so it's not executed directly by the CPU, there's a program (the interpreter) that executes the bash script.

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 12 guests