Skip to content

saul_adc: Add conversion functionality#8581

Closed
jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
jnohlgard:pr/saul-adc-filter
Closed

saul_adc: Add conversion functionality#8581
jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
jnohlgard:pr/saul-adc-filter

Conversation

@jnohlgard
Copy link
Member

@jnohlgard jnohlgard commented Feb 16, 2018

Contribution description

Adds an option to specify an additional conversion function to the adc_params.h saul_adc configuration struct. The conversion function should take a raw ADC sample and convert it to some other measurement.
Included in the PR is an example generic filter function to convert ADC reading to real voltage. Only the Mulle platform is configured yet, but it is quite straightforward to implement the configuration.

Issues/PRs references

Depends on #8566, #8577, #8592, #8593

@jnohlgard jnohlgard added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR State: waiting for other PR State: The PR requires another PR to be merged first Area: drivers Area: Device drivers labels Feb 16, 2018
@jnohlgard jnohlgard added this to the Release 2018.04 milestone Feb 16, 2018
@jnohlgard
Copy link
Member Author

One caveat is that the sensor type is still determined by the driver (saul_adc), so the source is still listed as SENSE_ANALOG when enumerated, regardless whether it puts out values in raw ADC numbers or e.g. a temperature reading

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some minors things. The feature is interesting.

* Real Vrefh = vrefh * 10^(scale)
* For example, scale = -3 means that vrefh, vrefl are given in millivolts.
*/
void adc_conv_set_scale(int new_scale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_scale is not documented (use @param[in] new_scale ...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #8593

*/

/**
* @ingroup driver_sensif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, this group is not defined (git grep only return an @ingroup driver_sensif in phydat_str.c. Looks like there a typo somewhere or something missing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #8592

* @name ADC sample conversion configuration
* @{
*/
#define BOARD_ADC_VREFH_DEFAULT 33000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe put parenthesis around values

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed


static void test_phydat_fit(void)
{
int val0 = 100000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be interesting to put a comment explaining what this test is supposed to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #8592

@jnohlgard jnohlgard added the Area: SAUL Area: Sensor/Actuator Uber Layer label Feb 19, 2018
@jnohlgard jnohlgard force-pushed the pr/saul-adc-filter branch 3 times, most recently from cddbf1c to e406001 Compare February 27, 2018 06:10
@vincent-d
Copy link
Member

This feature is interesting and I'm wondering whether it could be extended to work with any type of sensor within saul. My use case would be to convert a raw adc value form an i2c ADC to a voltage.

@jnohlgard
Copy link
Member Author

@vincent-d I agree that it might be useful, but might be better then to create a saul filter device which wraps another saul device.
Anyway, I think for these more advanced scenarios it will be very helpful to have the XFA feature (arrays distributed across different compilation units) #7523.

@stale
Copy link

stale bot commented Jan 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Jan 17, 2020
@stale stale bot closed this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR State: stale State: The issue / PR has no activity for >185 days State: waiting for other PR State: The PR requires another PR to be merged first Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants