Giter VIP home page Giter VIP logo

adafruit_emc2101's Introduction

Adafruit EMC2101 Build StatusDocumentation

This is the Adafruit EMC2101 Temperature monitor and fan controller for Arduino Tested and works great with the Adafruit EMC2101 Breakout Board

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Installation

To install, use the Arduino Library Manager and search for "Adafruit EMC2101" and install the library.

Dependencies

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation and doxygen

Documentation is produced by doxygen. Contributions should include documentation for any new code added.

Some examples of how to use doxygen can be found in these guide pages:

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips

Formatting and clang-format

This library uses clang-format to standardize the formatting of .cpp and .h files. Contributions should be formatted using clang-format:

The -i flag will make the changes to the file.

clang-format -i *.cpp *.h

If you prefer to make the changes yourself, running clang-format without the -i flag will print out a formatted version of the file. You can save this to a file and diff it against the original to see the changes.

Note that the formatting output by clang-format is what the automated formatting checker will expect. Any diffs from this formatting will result in a failed build until they are addressed. Using the -i flag is highly recommended.

clang-format resources

About this Driver

Written by Bryan Siepert for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution

adafruit_emc2101's People

Contributors

caternuson avatar dhutchings avatar evaherrada avatar ladyada avatar siddacious avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_emc2101's Issues

clkovr and signed temps

  • Arduino board: NA

  • Arduino IDE version (found in Arduino -> About Arduino menu): NA

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): NA

Hi,
I decided to create a micropython library for the EMC2101 as adding blinka and platform direct adds a lot of files.
I based my EMC2101 micropython library on this Arduino EMC2101 library.
This meant that I had to read this library line by line. Whilst reading it, I noticed a few things that you may/may not feel are helpful.
There is one mistake that prevents the user from changing the clkovr bit correctly, and some issues where the sign bit is ignored on temperatures. Note this only affects readings of negative temperatures, which I guess most people won't encounter!

Note that I'm not great with C++ and am new to Github so I didn't want to make changes to your files and try and push them onto the project. I opted for writing down some comments instead.
Here is my full list of comments:
Adafruit_EMC2101.h
Line 69 : Duplicate of line 61
Line 70 : Duplicate of line 62

Adafruit_EMC2101.cpp
Line 162 : States clkovr_bit.write(clksel)
Should be clkovr_bit.write(clkovr)

Lines 416-420: This is not an error but the code could be made more consistent
Line 416 states lsb_value = EMC2101_FAN_RPM_NUMERATOR / min_rpm
At tis point, you're not calculatign the lsb.
This is actually a raw limit value that includes the msb and lsb.
In the getFanMinRPM function, you call this value "raw_limit"
For consistency, you could change:
Line 416 to: uint16_t raw_limit = EMC2101_FAN_RPM_NUMERATOR / min_rpm;
Line 417 to: if (!tach_limit_lsb.write(raw_limit & 0xFF)) {
line 420 to: if (!tach_limit_msb.write((raw_limit >> 8) & 0xFF)) {

Lines 445-449: When reading the external temperature, I think you are
ignoring the sign bit. This means that a negative temperature will
read like a very high temperature.
I think you need to do something like:
sign_bit = (buffer[0] >> 7) & 0x01;
raw_ext = buffer[0] << 8;
raw_ext |= buffer[1];
raw_ext &= 0x3FF ; // REMOVE THE SIGN BIT!
raw_ext >>= 5;
if sign_bit == 1 {raw_ext = -raw_ext;}
return raw_ext * 0.125;
See EMC2101 datasheet section 6.3 Temperature Data Registers
See also EMC2101 datasheet Table 5.2 for an example of the sign bit
in use

Line 449: You have a variable for the _TEMP_LSB, suggestion to use that
instead of typing the number out again

Lines 459-462: Not an error but a variable name inconsistency.
You are using the variable ext_temp_lsb when we are reading
the internal temp, not the external temp.

Lines 457-462: Again, you are ignoring the sign bit.
I think negative temperatures will read as very high temperatures.
You should extract the 7th bit, use it for the sign, and then mask
it off when reading the temp.
See EMC2101 datasheet section 6.3 Temperature Data Registers
See also EMC2101 datasheet Table 5.3 for an example of the sign bit
in use

Line 489: You have a variable for the EMC2101_FAN_RPM_NUMERATOR, suggestion
to use that instead of typing the number out again.

Lines 637-656: In get and set forced temperature functions you are ignoring
the sign bit again (as above)
See EMC2101 datasheet section 6.8

Thanks
Harry

EMC2101 not detected on Arduino Due

  • Arduino board: Arduino Due

  • Arduino IDE version (found in Arduino -> About Arduino menu): Arduino 1.8.15

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

If I compile and run the example sketch adafruit_emc2101_test.ino on Arduino Mega I get this output via the serial terminal which looks ok to me. (0 RPM is ok cause I've no fan connected ATM. However with fan connected it seems to be ok as well.)

Adafruit EMC2101 test!
EMC2101 Found!
Data rate set to: 32 HZ
External Temperature: 127.00 degrees C
Internal Temperature: 24 degrees C
Duty Cycle: 23% / Fan RPM: 0 RPM

External Temperature: 127.00 degrees C
Internal Temperature: 24 degrees C
Duty Cycle: 23% / Fan RPM: 0 RPM

...

If I run the example sketch with the Arduino Due and the exact same development setup I get this:

Wrong chip ID 
Failed to find EMC2101 chip
Adafruit EMC2101 test!
Address not found
Failed to find EMC2101 chip

Breakout Board: No PWM readings

This isn't really an issue with the code in this repo, but more of a documentation/hardware issue.

I recently bought one of your EMC2101 breakout boards and was eager to try it out. However, when I plugged everything in and ran some of the examples on an Arduino UNO, I never got a PWM reading from the fan. The wiring was correct and obviously it also was a 4-pin fan.

All the info on the tutorial page (https://learn.adafruit.com/emc2101-fan-controller-and-temperature-sensor) suggests that it is configured to be used with PWM fans by default and you only need to modify things such as solder bridges when changing to DC fan mode.

However, upon trying to debug my wiring and software for a solid 30 minutes, I double checked the solder bridges and compared the images on the documentation to the board I had in front of me. It is supposed to looks like this:

adafruit_products__edit4808_quarter_back

And my board looked like this instead:

20230616_211934

I.e. the TACH jumper that's used to get the tachometer readings from the fan is not closed by default despite what the tutorial suggests.

And indeed, after closing the Tach jumper manually, everything worked fine. So, when buying this board users cannot 100% use it in either DC or PWM fan modes since the jumpers are not set and the documentation is misleading. I know I could have had a look at that from the beginning, but, like I said, everything suggests that you can instantly use it with PWM fans. As far as I know there isn't one hint on that changed jumper.

Please fix this, so others do not waste their time too.

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.