Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:20 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Nice easy 3-axis accelerometer module....

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 04:08am 07 Feb 2018
Copy link to clipboard 
Print this post

I found these modules on Aliexpress today.

While they are not as cheap as some accelerometer modules($3.45 each), what I really like about these ones is that all the processing is done on the module for you. You read the X, Y and Z axis directly as a linear voltage on three different pins. 880mV per g @ 1.5g sensitivity. (6g sensitivity can be selected)

400uA current consumption, and 3uA in sleep mode.

Connect to three MM analog pins and you're done, essentially. If you only need one axis, you only need one analog input pin. No complicated I2C commands and corresponding complicated data calculations to get the results.

All I want is tilt sensing, so I think these will do very nicely. I have ordered a couple to play with.

Here is the datasheet: 2018-02-07_140154_MMA7361L_3-axis_with_XYZ_output.pdf
Smoke makes things work. When the smoke gets out, it stops!
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 04:43am 07 Feb 2018
Copy link to clipboard 
Print this post

Is this a digital alternative solution to the ball tilt/mercury switch you were looking at?

I think it is a more reliable solution if it works out. My only thought is you may need to read more than 1 axis reading and a calculation to get a tilt reading on one axis (depending on the orientation of the IC). I'll have a read of the data sheet, but definitely worth a play.Edited by Azure 2018-02-08
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 04:49am 07 Feb 2018
Copy link to clipboard 
Print this post

Yes it is.

I didn't have much luck with that, did I....
Smoke makes things work. When the smoke gets out, it stops!
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 05:15am 07 Feb 2018
Copy link to clipboard 
Print this post

I had a quick read, you need to be aware these measure acceleration (not static position) on each axis.

The components XYZ outputs are relative to the IC so will depend on final chip orientation.

You will need to take readings at some interval and compare it to the previous reading and I suspect do some calculation to determine if it has been 'tilted'.

It is unlike a physical plumb bob tilt which can be moved with minimal accelartion in the X and Y planes and in the Z plane plane without tripping.

Also unlike a mercury tilt switch which can ignore movement in 2 dimensions wihtout tripping.

Just reading a single axis does not necessarily mean it has been 'tilted'.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 05:18am 07 Feb 2018
Copy link to clipboard 
Print this post

Look at page 6 of the PDF. That shows that they do measure static acceleration - they even call it that.

EDIT: Oh, I see what you mean. Not a problem anyway, as I plan to connect all three axis on the next design, so I can read all three to determine if there is a tilt. That's the plan anyway. I will run some tests once I get my hands on them.Edited by Grogster 2018-02-08
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:00am 07 Feb 2018
Copy link to clipboard 
Print this post

The maths will be the same as the maths used on the I2C devices.
This is a quick rehash of the code I posted in October 2015

  Quote   ' TassyJim
' MMA7361L
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SETPIN 2, AIN
SETPIN 3, AIN
SETPIN 4, AIN

DO

accelX=
PIN(2)
accelY=
PIN(3)
accelZ=
PIN(4)

accelM=
SQR(accelX*accelX+accelZ*accelZ)

IF accelM=0 THEN ' avoid divde by zero error
IF accelY<0 THEN
tilt=-
90
ELSE
tilt=
90
ENDIF
ELSEIF accelZ<0 THEN
IF accelY<0 THEN
tilt= -
180 - DEG(ATN(accelY/accelM))
ELSE
tilt=
180 - DEG(ATN(accelY/accelM))
ENDIF
ELSE
tilt =
DEG(ATN(accelY/accelM))
ENDIF
IF lc>100 THEN
PRINT CHR$(27)+"[2J"
lc =
0
ENDIF

PRINT CHR$(27)+"[1;1H",TIME$
PRINT "ACCEL_XOUT ",accelX
PRINT "ACCEL_YOUT ",accelY
PRINT "ACCEL_ZOUT ",accelZ
PRINT
PRINT STR$(tilt,4,1),"Degrees (+/-)"
tilt = ((tilt*
10+3600) MOD 3600)/10 ' MOD gives the result in integers
'if tilt = 0 then tilt = 360 ' uncomment if you want 360 instead of 0
PRINT STR$(tilt,4,1),"Degrees (0-360)"
lc=lc+
1
PAUSE 1000
LOOP

END


I just removed the I2C stuff and the Gyro references.


VK7JH
MMedit
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 06:06am 07 Feb 2018
Copy link to clipboard 
Print this post

Yes, as i said:
  Quote  The components XYZ outputs are relative to the IC so will depend on final chip orientation.

You will need to take readings at some interval and compare it to the previous reading and I suspect do some calculation to determine if it has been 'tilted'.


So depending on what you call 'level' you need an initial value to determine that based on the current chip orientation 'static acceleration' and then depending on what you define as a 'tilt' the difference value from level.

Generically an object can be moving and be considered level and also usually allows a certain amount of hysteresis, these values change the 'static acceleration' but do not necessarily mean it is tilted.

I do not know we learnt what your specific application was to define what 'level' and 'tilt' means in reference to an accelerometer.

Just trying to make sure you don't fall into a situation of reading false positives.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 08:16am 07 Feb 2018
Copy link to clipboard 
Print this post

[Quote]I do not know we learnt what your specific application was to define what 'level' and 'tilt' means in reference to an accelerometer.[/Quote]

Huh?

EDIT: @ Jim - Can you please link to that old thread of yours?Edited by Grogster 2018-02-08
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 07:52pm 07 Feb 2018
Copy link to clipboard 
Print this post

https://www.thebackshed.com/forum/forum_posts.asp?TID=8047&KW=MPU%2D6050

Read the full thread to see the errors in the code.

Jim
VK7JH
MMedit
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 08:33pm 07 Feb 2018
Copy link to clipboard 
Print this post

Shame that lcsoft.net domain is dead.

Looked on it a year or so back when I saw it on some DS18B20 modules.

The site had a huge range of different devices.

Phil.
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 10:01pm 07 Feb 2018
Copy link to clipboard 
Print this post

  Quote  Huh?

I recall you were putting the tilt sensor onto a PCB but not sure what the intended application and use scenario was.

So questions like: When sensing tilt is it initially moving (dynamic) or it is always initially still (static). Is it in a known fixed XYZ orientation. Is it normally parallel to those planes. What planes can it or do you want tilt to be senses in. When it is being setup can the XYZ resting position be zeroed to match the final position?

These sort of things will effect what the 'untilted' force vectors will be like so that from them the force vectors that represent your 'tilt' can be worked out.Edited by Azure 2018-02-09
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 01:06am 08 Feb 2018
Copy link to clipboard 
Print this post

@ Jim: Thanks.

@ Azure: Ahhhh. Gotcha. More complicated then I thought. I will write a simple code to display on the console the XYZ voltages from the module when they arrive, and then by moving the module around, I should be able to get some kind of output that I can play with.

I thought this would be a great replacement for the ball-switch/mercury switch thing I was having so much trouble with late last year. I hope I have not overplayed my hand!
Smoke makes things work. When the smoke gets out, it stops!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:35am 08 Feb 2018
Copy link to clipboard 
Print this post

There are many ways to detect tilt.
I used to use a weight and a microswitch, later on i used a disc with a weight on one side and a optical sensor.
Nowadays these kinds are available ready made.
Like a microswitch tilt sensor: http://golden-switch.manufacturer.globalsources.com/si/6008848479179/pdtl/Tilt-switch/1157835967/Tilting-micro-switch.ht m
Or an optical one: http://www.goldmine-elec-products.com/prodinfo.asp?number=G16882

They both work with a steel ball as the weight, but it is not used to close a circuit by itself. It either activates a switch or blocks out light.

They are used in alarm systems (that where i know them from) for instance in ATM machines and vending machines. Very reliable.
Edited by MicroBlocks 2018-02-09
Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 01:46am 08 Feb 2018
Copy link to clipboard 
Print this post

Yes, the ball-type photo-interrupter type thing is ideal. Both of those types are sold out though. I will do a search for 'Optical tilt switch' to see if that gives any more hits.

MUCH prefer a simple approach over an XYZ idea - I was just trying to get away from mercury and ball-switches. If you know of any more photo-interrupter type tilt switches, this is exactly what I need.
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 02:05am 08 Feb 2018
Copy link to clipboard 
Print this post

I found this website that talks about using an Osram SFH7710 tilt sensor. These things look perfect, but seem to be obsolete from what little searching I have done so far proves.

EDIT: This has possibilities.

EDIT: So does this. This one has gold-plated contacts, and gives me the two tilt angles I need in one package. This is the current frontrunner.Edited by Grogster 2018-02-09
Smoke makes things work. When the smoke gets out, it stops!
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 08:49am 08 Feb 2018
Copy link to clipboard 
Print this post

@Grogster

I think if you do some practical tests like you mention you will get a good result with the XYZ accelerometer. It is one of those things that the maths behind them is more complicated than they are to use in practice (if you test the outputs in the situations that appiy to your use scenario).

Those other chips look good but I think with the testing you'll get the XYZ to do what you want.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 09:28am 08 Feb 2018
Copy link to clipboard 
Print this post

Cool, thanks.
I have my bases covered now with XYZ and various 'Authentic' tilt sensors. I will keep the forums updated.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025