LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM
User Name
Password
Slackware - ARM This forum is for the discussion of Slackware ARM.

Notices


Reply
  Search this Thread
Old 02-22-2014, 04:10 AM   #1
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 634
Blog Entries: 20

Rep: Reputation: 81
Connecting an accelerometer to a Pi


When my son is not using my Pi for watching toons I plan to use it to control a model submarine droid. Appart from controlling servos via GPIO pins (to my understanding there's a kernel module [servoblaster] that does that to minimize servo jutter and stop them from overheating dew to task switching timing inaccuracies afflicting userspace) ... but I wanted to give my SUB an accelerometer so that it could correct unwanted accelerations.

This might be a good accelerometer for the job: https://www.modmypi.com/adafruit-tri...-accelerometer

but there's no tutorial for connecting it to Pi and reading data from it.
Any help is appreciated.

Last edited by louigi600; 02-22-2014 at 04:31 AM.
 
Old 02-22-2014, 05:01 PM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by louigi600 View Post
When my son is not using my Pi for watching toons I plan to use it to control a model submarine droid.
that seems a very interesting, but also a very eager project. I wonder how you're going to control the vessel:
  • Via LAN cable? That would restrict its mobility a lot.
  • Via WiFi? Nearly impossible, the range of 2.4GHz radio waves is mere centimeters under water. Except you have a long rod protruding out of the water.
  • Fully autonomous? That would require a camera and some sophisticated software, and only slow movement so you're still able to catch it if it should go rampant.

Quote:
Originally Posted by louigi600 View Post
I wanted to give my SUB an accelerometer so that it could correct unwanted accelerations.
Okay, but think of physics: You can't distinguish between gravitation and acceleration. Therefore, every slight tilt or cant of the vessel would be interpreted as an acceleration in a certain direction. Did you consider that?

Quote:
Originally Posted by louigi600 View Post
This might be a good accelerometer for the job: https://www.modmypi.com/adafruit-tri...-accelerometer

but there's no tutorial for connecting it to Pi and reading data from it.
So you'll have to go the investigative way. The page you point to has a link to the data sheet. There are some other projects for the Pi that communicate with I²C devices. I can't see any other way than checking with the data sheet what commands and instructions the chip needs to be sent to, and what its response looks like and how it is to be interpreted. The general way of using I²C communication can be taken from some other project.
That probably means hours, if not days of investigation and testing. But I'm afraid someone has to do it. If nobody else did it for this chip on the Pi yet, you might have to be that pioneer. ;-)

[X] Doc CPU
 
Old 02-22-2014, 05:33 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,675

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Quote:
You can't distinguish between gravitation and acceleration.
Yes you can. It depends on the type of accelerometer. These accelerometer can measure both static and dynamic acceleration.

In a nutshell static measures gravity and dynamic measures shock and motion. http://www.analog.com/static/importe...ts/ADXL345.pdf
 
Old 02-22-2014, 05:40 PM   #4
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 634

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Quote:
Originally Posted by Doc CPU View Post
Hi there,



that seems a very interesting, but also a very eager project. I wonder how you're going to control the vessel:
  • Via LAN cable? That would restrict its mobility a lot.
  • Via WiFi? Nearly impossible, the range of 2.4GHz radio waves is mere centimeters under water. Except you have a long rod protruding out of the water.
  • Fully autonomous? That would require a camera and some sophisticated software, and only slow movement so you're still able to catch it if it should go rampant.



Okay, but think of physics: You can't distinguish between gravitation and acceleration. Therefore, every slight tilt or cant of the vessel would be interpreted as an acceleration in a certain direction. Did you consider that?



So you'll have to go the investigative way. The page you point to has a link to the data sheet. There are some other projects for the Pi that communicate with I²C devices. I can't see any other way than checking with the data sheet what commands and instructions the chip needs to be sent to, and what its response looks like and how it is to be interpreted. The general way of using I²C communication can be taken from some other project.
That probably means hours, if not days of investigation and testing. But I'm afraid someone has to do it. If nobody else did it for this chip on the Pi yet, you might have to be that pioneer. ;-)

[X] Doc CPU
I'm going for full auto ... and I'm not targeting millimetric precision so I'm hoping to do without camera ... but I'll be doing maths on the accelerometers to estimate position. I'll not be attempting to make it swim thought a tiny home but just have it follow a pre-calculated path supposing there are no obstacles in the way. If I can get that to work I'll look into handling unexpected obstacles.

I also said "unwanted acceleration": g is constant and practical so I can deal with that as acceleration is a vector and vectors sum (yes it's simple physics).

I found some other interesting sensors with accelerometer, compass and rotation sensor: I might use one of those

Last edited by louigi600; 02-22-2014 at 05:43 PM.
 
Old 02-22-2014, 06:16 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,675

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
School project?

Yes, look into using Inertial Measurement Units (IMUs) using a fibre optic gyro. They are small and used in drones etc. I think you will find that using acceleration as a sole means for determining position very crude. Also IMUs have a drift factor, if you do not use some external input for speed and depth make sure to take it into account.
 
Old 02-23-2014, 02:32 AM   #6
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 634

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Quote:
Originally Posted by michaelk View Post
School project?
Yes, look into using Inertial Measurement Units (IMUs) using a fibre optic gyro. They are small and used in drones etc. I think you will find that using acceleration as a sole means for determining position very crude. Also IMUs have a drift factor, if you do not use some external input for speed and depth make sure to take it into account.
This is the other sensor I found intresting: http://www.allthingsmicro.com/produc...accelmag-board is has all 3 in one neat pcb ... the only snag is that they are not oriented in the same axis which will require software coordinate rearranging. But am an absolure nubi in this field so any suggestions are welcome.

Yeah ... I was guessing that the deceleration caused by drag (and fluid current) would be unmeasurable so I'd haveto account for that somehow, maybe have a small propeller up front attached to an undriven DC motor and measure the tension produced. If I remember correctly the voltage produced is close to linear with angular velocity of the prop, and that should be linear with the speed too.
Water is really dense compared to air so I cal assume any lateral drift is dew to fluid movement, or at worse, the sub changing immersion depth ... so I guess doing full auto might need a means of measuring depth too. How about an accelerometer placed on a tilting surface that is moved by pressure differential between outside and inside ?

Really coarse if fine for a first attempt at a drone ... if I like it I'll look into better accuracy but GPS will not work under water so I'll haveto figure out something else.

Update on the sensors: A friend of mine has a 10DOF left over from is multi-rotor drone chopper ... he's gonna give it to me for some reasonable price so I think I'll go for that.

Last edited by louigi600; 02-24-2014 at 11:45 AM.
 
Old 03-13-2014, 11:35 PM   #7
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 634

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Now that I have the IMU I did a littple reserch and play with it. If anyone is intrested I wrote a small article on how I went about reading some information out of my IMU on
docs.slackware.com

Last edited by louigi600; 03-18-2014 at 04:29 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Dualshock/SIXAXIS Accelerometer in Wired Mode? Kvbx4 Linux - Games 1 03-03-2013 10:45 AM
Accelerometer Driver for Lenovo Ideapad S10-3 TimmyTurner Linux - Laptop and Netbook 2 01-30-2011 10:26 AM
LXer: Google bringing accelerometer support to Chromium LXer Syndicated Linux News 0 07-07-2010 01:40 AM
Digikam connecting as root/not connecting as regular user jayhel Slackware 5 09-29-2005 05:57 PM
Mysql is not connecting from servlet.But connecting from java, help pls Harish_f Linux - General 0 05-08-2002 03:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration