Coder Social home page Coder Social logo

fma_force_sensor's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

FMA Force Sensor

This is a library to run the FMA series of micro force sensors by Honeywell via I2C. It is written to work with a MAX32630FTHR, but it could easily be adapted for other microprocessors.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

This project is a custom library written to operate the FMA series of micro force sensors from Honeywell. This particular library was written for the I2C version of the chip, and does not include functionality for the SPI version.

This library allows reading of the measured force value in Newtons as well as the package tempeature in Celsius.

(back to top)

Getting Started

This library should be added to your favourite IDE and imported. See the Usage section for how to implement.

Prerequisites

The code only requires standard C++ functions along with I2C.

Installation

The .h and .cpp files need to be downloaded and added to their own folder in the libraries you are using.

If using Keil Studio Cloud, the Github URL for this repository needs to be added to the libraries for the project.

(back to top)

Usage

Example of use for code 1.1 versions:

#include "mbed.h"
#include "max32630fthr.h"
#include "fma_force_sensor.h"
#include "USBSerial.h"

// Enable FTHR
MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); // Enable J1-pin2, 3.3V and set GPIO to 3.3v

// Start serial communication
USBSerial serial;

// Start I2C bus on the correct pins
I2C i2c_bus(P3_4, P3_5); // SDA, SCL

// Initialize the force sensor and associate it with the I2C bus
FMA_Force_Sensor force_sensor(i2c_bus);

// main() runs in its own thread in the OS
int main()
{
    // Set the I2C bus speed
    i2c_bus.frequency(100000);
    // Set the address for the device
    force_sensor.set_address(40);

    float force_value = 0.0;
    float temp_value = 0.0;
    int force_status;
    int temp_status;
    
    ThisThread::sleep_for((1000ms));
    
    // Set the zero value for the force readings
    serial.printf("Setting Zero Value \n");
    force_sensor.set_zero();

    while (true) {

        // Get the force value
        force_status = force_sensor.get_force(force_value);
        ThisThread::sleep_for(20ms);        
        // Get the temperature
        temp_status = force_sensor.get_temp(temp_value);
        
        // If there are no errors, display the values
        if (!force_status && !temp_status){
        serial.printf("%.3f, %.2f\n", force_value, temp_value);
        }
        // Display the errors along with the returned value.
        // A value of -99 with a status of 1 indicates an I2C read error
        else{
            serial.printf("Error: Force: %.3f, Status: %d\n", force_value, force_status);
            serial.printf("Error: Temp: %.2f, Status %d\n", temp_value, temp_status);
        }

        ThisThread::sleep_for(100ms);
    }
}

Example of use for code 1.0 versions:

   #include "mbed.h"
   #include "max32630fthr.h"
   #include "fma_force_sensor.h"
   #include "USBSerial.h"  // For communication via the onboard USB port
   // Enable FTHR
   MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); // Enable J1-pin2, 3.3V and set GPIO to 3.3v
 
   // Start serial communication
   USBSerial serial;

   // Start I2C bus on the correct pins
   I2C i2c_bus(P3_4, P3_5); // SDA, SCL
 
   // Create the Sensor_Raw object
   FMA_Force_Sensor force_sensor(i2c_bus);
 
   int main()
   {
    
   i2c_bus.frequency(400000);
   float force_value = 0.0;
   float temp_value = 0.0;
   ThisThread::sleep_for((1000ms)); // Time for sensor to initialize
   force_sensor.set_zero();
 
   while (true) {

       force_value = force_sensor.get_force();
       temp_value = force_sensor.get_temp();
      
       serial.printf("%.2f, %.1f\n", force_value, temp_value);
       
       ThisThread::sleep_for(10ms);
   }
}

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

(back to top)

Contact

Project Link: https://github.com/Kawoogie/FMA_Force_Sensor

(back to top)

fma_force_sensor's People

Contributors

kawoogie avatar

Watchers

 avatar

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.