Search This Blog

Friday 15 June 2012

Surface level measurement using LIS302DL-MEMS Accelerometer

Bingo! I want to write a program for LIS302DL(MEMS Accelerometer) by my self since I've bought STM32F4 Discovery. After few days of working and learning, I've just finish my programming few minutes ago and it is working perfectly well.

So, the program is written to keep the discovery board's surface level at zero, means if the surface is tilted on which the Board is placed, the led(s) will glow such that it indicate the direction at which the surface should be tilted to balance the level.

STM32F4 Discovery also came with the same program, but it is too complex to understand. In their Demo, TIMER4 is used. Instead of using timer I've used only simple led on-off command. It is too simple to understand then using timer.

Here are some photos:

It isn't possible for me to tilt the whole table. So, I just tilted the board!Bad PJ, isn't it?





Here's the video of Acceleromter and STM32F4 in action:




The program used one special type of interrupt Sys_Tick. This interrupt generates at every 1ms in my program. You can change if you want. So, at every 1ms we check the resisters of LIS302DL and compare it with our logic to blink led according to the direction. I don't want to say that we should not use TIMx in programming, but what I mean is why to use complex programming method when the simplest form of programming is available. The main advantage of not using TIM4 is that the time require to handle TIM4 interrupt is saved in case of using simple GPIO On-Off command.


40 comments:

  1. Wow!!! I was also trying to make an easier code but got no success..Can you share your code plz...

    ReplyDelete
    Replies
    1. sure...
      I would like to share. Send me your email address.

      Delete
    2. can you share the code with me also ? i would really help me... if you can send the code to this email: modeliukax@gmail.com

      Delete
  2. i need one, plz share it.
    trandat.us09@gmail.com

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. plz share it!!
    my email: phuc.ng25@gmail.com
    thanks

    ReplyDelete
  5. You can send the code to this email: artem.peryev@gmail.com

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. hey, i have texas instruments ekk-lm4f232 eval board....it has arm cortex m4 processor....can u plz tell me where did u learn its programming?? need it urgently
    email me at prateekaroraeee@gmail.com
    thnx

    ReplyDelete
    Replies
    1. Hi Prateek
      Just play around with example codes. Try to understand it. I am sure you'll learn a lot just by doing this.

      Delete
  8. Wow!!! I was also trying to make an easier code but got no success..Can you share your code
    My Email : phuoc166.nguyenhuu@gmail.com
    tks u

    ReplyDelete
  9. Can you share code for me?
    Thank you!
    tmtuan.23@gmail.com

    ReplyDelete
  10. Hi, good work!
    I'm trying to make something like this for few days but I can't.

    Could you email me your code please?
    leo.guitarmg@gmail.com

    Thanks!

    ReplyDelete
  11. Could you email me your code too?
    martin.thuemmel@gmail.com

    Thanks!

    ReplyDelete
  12. could you share your code with me too?
    kruzi@web.de
    thanks a lot

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. could you send me the code please:
    sassi.insaf@gmail.com

    ReplyDelete
  16. I really need it: sassi.insaf@gmail.com

    ReplyDelete
  17. Your code, would be a great help for a beginner with this card(me), please email it to me! adam.mesterhazi@gmail.com

    ReplyDelete
  18. could you send me the code please:
    renyu34@yahoo.com

    ReplyDelete
  19. could you send me the code please:
    przemek.rolka@gmail.com

    ReplyDelete
  20. can you send also to me please, ufukyumrukaya@gmail.com. thank you

    ReplyDelete
  21. If you do not mind please send me also this program. I have to start to learn it and it will be a great model for me. This is my email: siczek@gmail.com. Thanks a lot.

    ReplyDelete
  22. Hi there, i would love to get this code too. I'm struggling for a few days with this damn MEMS-Sensor.
    My E-Mail: bladeboarder1@hotmail.com

    ReplyDelete
  23. bonjour ; I happened to configure LIS302DL and showed me the measurements between 0 and 255 for the three axes. I can not know these values ​​are between 0 and 255 which unit so that I can convert them after mm/s2 ??

    ReplyDelete
  24. Please if you do not understand the question let me know

    ReplyDelete
    Replies
    1. Hi Amina
      Refer datasheet of LIS302DL. In mechanical specification on page no 10, the sensitivity is given as either 18 mg or 72 mg depending upon FS bit is set to 0 or 1 respectively.
      The measurement values are in between 0 to 255. Suppose you read value 100. Now, if you've set FS bit to zero, multiply this reading by 18 i.e. 100*18 you'll get your answer 1800 mg. You can convert 'mg' into mm/s2 by multiplying it by 9.810 So, final answer will be 17658 mm/s2.

      Delete
  25. Hey I'm working on a project to expand on the use of the MEMS accel, can you send me your project code?

    e-mail: jacobryan90@gmail.com

    Thank you.

    ReplyDelete
  26. Hey. Could you send me your project code?

    e-mail: pietrucha.piotrek@gmail.com
    Thank you

    ReplyDelete
  27. Hi, could I have your project code too?

    e-mail: joytoefl120@gmail.com
    Thank you.

    ReplyDelete
  28. can you send also to me please, rlkumar1977@gmail.com. thank you

    ReplyDelete
  29. Hi,
    Please share it.
    Thanks a lot.
    My e-mail: tha_akan91@hotmail.com
    have a nice day...

    ReplyDelete
  30. Hi please share with me your code.

    E-mail:buraksakaci@gmail.com

    have a nice day

    ReplyDelete
  31. Hi

    I've been struggling on this for a week. Can you please send it to me on a.patel@uct.ac.za

    Thanks so much

    Amir

    ReplyDelete
  32. I really need it: aresrepair@gmail.com
    have a nice day

    ReplyDelete
  33. Hi please share with me your code.

    E-mail:buraksakaci@gmail.com

    have a nice day

    ReplyDelete
  34. to compile this source code, what software are you using?

    ReplyDelete
  35. Hi,
    I have downloaded the source code provided in the following link https://github.com/mitul93/STM32F4-Discovery-MEMS-interface

    Built a Project project with code provide in STM32F4-Discovery_FW_V1.1.0 and replaced main.c,main.h,stm32f4xx_it.c and stm32f4xx_it.h.
    Project build was successful but no Leds are building when i tilt the board. Is there any modification required in the code

    ReplyDelete