Skip to content

Incorrect implementation of proximity measurement frequency #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stonehippo opened this issue Feb 6, 2022 · 4 comments
Closed

Incorrect implementation of proximity measurement frequency #21

stonehippo opened this issue Feb 6, 2022 · 4 comments

Comments

@stonehippo
Copy link
Contributor

stonehippo commented Feb 6, 2022

After a comparison of the CP version of this module with the data sheet, and the Arduino version of the Adafruit VCNL4010 library, I think that this module is not correctly setting the proximity measurement read rate on the chip.

The documentation for this module says that setting the frequency property is supposed to set the proximity read frequency:

The frequency of proximity measurements. Must be a value of:

FREQUENCY_3M125: 3.125 Mhz

FREQUENCY_1M5625: 1.5625 Mhz

FREQUENCY_781K25: 781.25 Khz

FREQUENCY_390K625: 390.625 Khz (default)

See the datasheet for how frequency changes the proximity detection accuracy.

However, the data sheet states that there are 8 modes for the proximity rate register:

000 - 1.95 measurements/s (DEFAULT)
001 - 3.90625 measurements/s
010 - 7.8125 measurements/s
011 - 16.625 measurements/s
100 - 31.25 measurements/s
101 - 62.5 measurements/s
110 - 125 measurements/s
111 - 250 measurements/s

In addition, this module is setting the PROXIMITY MODULATOR TIMING ADJUSTMENT (register 15) register at address 0x8f, not the PROXIMITY RATE REGISTER (register 2) at 0x82 (as described in the data sheet and implemented in the Arduino library). Based on this information, I’m pretty sure this is not what was intended, as the register being used changes the frequency of the square wave of the IR signal, not the number of measurements made by the sensor.

@stonehippo
Copy link
Contributor Author

For reference, I’m looking at the data sheet here. The registers in question are documented on pages 7 and 11.

@ladyada
Copy link
Member

ladyada commented Feb 6, 2022

woops, exciting :) could you submit a PR? it would be greatly appreciated

@stonehippo
Copy link
Contributor Author

Can do!

@stonehippo
Copy link
Contributor Author

Resolved by #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants