Giter Site home page Giter Site logo

mc3416's Introduction

MC3416 Accelerometer Library

  • The MC3416 is a small form factor,integrated digital output 3-axis accelerometer with a feature set optimized for cell phones and consumer product motion sensing. Applications include user interface control, gaming motion input, electronic compass tilt compensation for cell phones, game controllers, remote controls and portable media products.

Library features:

Get Accelerometer Xout Yout Zout Data.
The Accelerometer Resolution Range Configures ±2g , ±4g , ±8g , ±12g , ±16g
configure The Gain Value For 3 Axis.
Active Interrupt Pin For Motions Sense 

    Motion Algorithms: Tilt/Flip Tilt-35 
                       AnyMotion , Shake

Set Thershold Value For All Motion Algorithms.
Set Debounce Time For Motion Algorithm.
Configure the Time Control Register.
Configue The Output DataRate 128 To 1024 
  • You Can Download DataSheet MC3416 From This Link: MC3416

  • If you are a user of IC (Accelerometer) MC3416 library You need to do the following steps to port this library with your code:

  • This library is ported for ESP32-IDF , STM32 Mcrocontroller.

  • If you use the RTOS operating system, you must change the value of the following macro at the beginning of the MC3416.h file:

#define USE_RTOS    1
  • Set Device I2C Number I2C_0 , I2C_1, ... in I2C_Drive.h:
#define MC34_I2C_Drive      I2C_1
  • uncomment Your CPU In I2C_Drive.h :
#define ESP32_IDF
// #define MC60_OPENCPU
// #define STM32
  • you Can use In Main.c Code:
#include "MC3416.h"
//foo

int main()
{
    /*config and init mc34xx-----------*/
    MC34xx_ChipParam_t mc34xx_config = {0};
    mc34xx_config.g_range=g_range_2g;
    mc34xx_config.sample_rate=sample_rate_1024;
    mc34xx_config.X_Gain=0x0f;
    mc34xx_config.Y_Gain=0x0f;
    mc34xx_config.Z_Gain=0x0f;
    
    MC34xx_Init(&mc34xx_config);    //init mc3416 -> Disable any interrupt
    /*---------------------------------*/
    static float x_axis,y_axis,z_axis;  //3 float type for get axis

    while(1)
    {
        MC34xx_Get_XYZ_Float(&x_axis,&y_axis,&z_axis);
        MC34xx_intn_list = MC34xx_CheckSoft_Interrupt();    /*Check ISR Register*/
        switch ((uint8_t)MC34xx_intn_list)
        {
        case MC_INTN_No:
            printf("\nNo Any INTN");
            break;
        case MC_INTN_Tilt:
            printf("\n--->Tilt INT Readed!");
            break;
        case MC_INTN_Flip:
            printf("\n--->Flip INT Readed!");
            break;
        case MC_INTN_AnyMotion:
            printf("\n--->AnyMotion INT Readed!");
            break;
        case MC_INTN_Shake:
            printf("\n--->Shake INT Readed!");
            break;
        case MC_INTN_Tilt_35:
            printf("\n--->Tilt_35 INT Readed!");
            break;
        case MC_INTN_ACQ:
            printf("\n--->ACQ INT Readed!");
            break;
        }
        vTaskDelay(pdMS_TO_TICKS(5));   //delay For Test 
        //foo
    }
}

Contact The Author

mc3416's People

Contributors

hardphoenix avatar

Stargazers

 avatar

Watchers

 avatar

mc3416's Issues

BUG: Read-out of XYZ values.

Hi!

Thanks for the great work on setting up this module.
However I think I have found a problem in your implementation.

If the accelerometer is free running (Active) and you use "MC34xx_Get_XYZ_Float" in a polling mode you can have the situation that the register contents changes to new samples while reading.

Explanation:
You use 6 seperate I2C reads to read XH, XL, YH, YL, ZH and ZL in "MC34xx_Get_XYZ_Float"

The datasheet states that the register content does not change during I2C read (Chapter 11) of PDF.
However your code uses 6 reads. So you are unsure if those 6 registers belong to eachother.

In my oppineon you should use only 1 I2C command to read 6 bytes at once.

Kind regards,

Remon Dijkstra.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.