adc: rework the example to remove rms and mean value.
Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
This commit is contained in:
parent
68f3f0f815
commit
58469e08da
|
|
@ -4,7 +4,7 @@ Digi APIX ADC Sample Application
|
|||
Sample application to access and manage ADC channels using the Digi APIX library.
|
||||
|
||||
The application enables one ADC channel on the board. After that, the application
|
||||
takes periodic samples and calculates the rms and mean value of the samples batch.
|
||||
takes periodic samples and prints the raw value and the value in mv.
|
||||
|
||||
The ADC lines used in the sample are mapped as follows in the Digi Boards:
|
||||
- **CCIMX6 SBC**: PMIC_ADCIN1 (GPIO Connector Pin 1).
|
||||
|
|
@ -90,4 +90,4 @@ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
THIS SOFTWARE.
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ static adc_t *adc;
|
|||
|
||||
struct adc_sampling_cb_data {
|
||||
adc_t *adc;
|
||||
int total_value;
|
||||
int total_value_rms;
|
||||
int number_of_samples;
|
||||
};
|
||||
|
||||
|
|
@ -143,8 +141,6 @@ static int adc_sampling_cb(int sample, void *arg)
|
|||
struct adc_sampling_cb_data *data = arg;
|
||||
float sample_mv = 0;
|
||||
|
||||
data->total_value += sample;
|
||||
data->total_value_rms += powf(sample, 2);
|
||||
data->number_of_samples--;
|
||||
sample_mv = ldx_adc_convert_sample_to_mv(data->adc, sample);
|
||||
|
||||
|
|
@ -193,8 +189,6 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
cb_data.number_of_samples = number_of_samples;
|
||||
cb_data.total_value = 0;
|
||||
cb_data.total_value_rms = 0;
|
||||
|
||||
/* Register signals and exit cleanup function */
|
||||
atexit(cleanup);
|
||||
|
|
@ -220,10 +214,5 @@ int main(int argc, char *argv[])
|
|||
sleep(1);
|
||||
}
|
||||
|
||||
printf("The mean value of the samples is: %d mV\n",
|
||||
cb_data.total_value/number_of_samples);
|
||||
printf("The RMS value of the samples is: %.2f mV\n",
|
||||
sqrt(cb_data.total_value_rms/number_of_samples));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ the number of address bytes.
|
|||
<name>Digi APIX ADC Sample</name>
|
||||
<description>
|
||||
Sample application to access and manage ADC channels using the Digi APIX library.
|
||||
The application enables one ADC channel on the board. After that, the application takes periodic samples and calculates the rms and mean value of the samples batch.
|
||||
The application enables one ADC channel on the board. After that, the application takes periodic samples and prints the raw value and the value in mv.
|
||||
</description>
|
||||
<path>apix-adc-example</path>
|
||||
<platforms>
|
||||
|
|
|
|||
Loading…
Reference in New Issue