GithubHelp home page GithubHelp logo

bobveringa / hscdtd008a-library Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 52 KB

A library for the HSCDTD008A Sensor and CJMCU-008 Module

License: MIT License

C 75.96% C++ 24.04%
arduino c c-plus-plus driver hscdtd008a library

hscdtd008a-library's People

Contributors

bobveringa avatar tilman1 avatar

Stargazers

 avatar

Watchers

 avatar

hscdtd008a-library's Issues

TCS and OCL are (sometimes) order dependent

Summary:
The order of temperature compensation and offset calibration seems to be order dependent in the latest build.

A HSCDTD_STAT_NO_DATA error is triggered if temperature compensation is done before offset calibration. Validation is needed if this is also the case for the C driver layer, or if this only happens in the Wrapper layer. I have no reason to believe the wrapper layer causes any of this behavior, but validating it seems a good first step.

Initial code analysis shows no obvious reason why the order of these operations should matter, so more investigation is needed.

Workaround
The workaround is to do offset calibration before temperature compensation.

Additional details:
A logic analyzer clearly shows the driver attempting to check the status register, but only 0x00 is returned from it.

image

If both temperature compensation and offset calibration are disabled, only 2 attempts are needed before data is available.

image

If only offset calibration is enabled, it takes ~26 attempts:
image

if only temperature compensation is enabled, it takes ~29 attempts:
image

If both are enabled in the "wrong" order, and the number of max-attempts is increased from 50 to 100, data is available within 32 attempts. This does not make any sense to me.
image

It could have something to do with these functions explicitly setting the device in the FORCE state.
Because the DRDY (white) pin is high about 93ms after starting a reading.
image

In any case, something goes wrong when using TCS or OCL (or a combination of the 2) as the number of attempts is just way to high.

Code snippet to test:

void setup() {
  hscdtd_status_t status;

  Serial.begin(9600);

  geomag.begin();
  // If you know the I2C address is different than in the provided
  // data sheet. Uncomment the line below, and configure the address.
  geomag.begin(0x0F);

  // Initialize the hardware.
  status = geomag.initialize();
  if (status != HSCDTD_STAT_OK) {
    Serial.println("Failed to initialize sensor. Check wiring.");

    // Halt program here.
    while (true) { delay(1); }
  }
  // Compensate for temperature.
  geomag.temperatureCompensation();

  geomag.offsetCalibration();
}

Data Ready Pin Support

Add support for the Data Ready Pin Support to the Arduino Layer. Including some examples.

Proper support for Normal State

Currently, the driver supports the Force State for reading data from the sensor. The HSCDTD008A also supports configuring the sensor to a specific frequency and reading sensor data without explicitly starting a read operation.

The goal is to research how Normal State can be properly supported on an Arduino. In addition, some examples should be created that clearly show how it should be used.

  • Investigate how Normal State works
  • Implement C Driver (If required)
  • Implement Wrapper layer
  • Create example(s)

Some platforms are not easily supported with current setup

As @tilman1 pointed out in #9 the address for the chip is hard-coded in the platform file. Given that this are cheap chips, they are likely to have addresses that are all over the place.

This means a modification is needed to allow other platforms to set up all required components for I2C functionality.

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.