Skip to content

Data acquisition

OwnTech Data Acquisition Zephyr Module is in charge of acquiring data from OwnTech Power Converter sensors.

Overview

NOTE: Temperature sensor implementation is still under development, do not use this channel for now.

The Data acquisition module initializes the ADCs and DMAs to perform periodic acquisitions of the power converters sensors, and dispatches them in per-channel buffers.

To use the Data Acquisition module, just include data_acquisition.h in your source file.

Configuration functions provided by this module:

  • int8_t data_acquisition_init()
  • int8_t data_acquisition_set_adc12_dual_mode(uint8_t dual_mode)
  • int8_t data_acquisition_configure_adc_channels(uint8_t adc_number, char* channel_list[], uint8_t channel_count)
  • int8_t data_acquisition_configure_adc_trigger_source(uint8_t adc_number, uint32_t trigger_source)
  • int8_t data_acquisition_start()

Functions to obtain acquired data:

  • uint16_t* data_acquisition_get_v1_low_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_v2_low_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_v_high_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_i1_low_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_i2_low_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_i_high_values(uint32_t* number_of_values_acquired)
  • uint16_t* data_acquisition_get_temp_sensor_values(uint32_t* number_of_values_acquired)

An additional function is also available:

  • char* data_acquisition_get_channel_name(uint8_t adc_number, uint8_t channel_rank)

After calling the data_acquisition_init() function, you have to configure the module by specifying the configuration you want for the ADCs using the configuration functions. After configuration has been done, you can start the module by calling data_acquisition_start().

To get acquired data, call one of the data_acquisition_get_***_values().

Configuration

The following error codes can be returned by the configuration functions. When developing an application, always check the functions return value for error codes. Configurations functions return 0 if they went well, otherwise they will return one of these values:

  • ECHANNOTFOUND (-1) Channel not found: you tried to enable a channel that does not exist for this ADC.
  • EUNITITIALIZED (-2) Uninitialized: you tried to call a configuration function without initializing the module first.
  • EALREADYSTARTED (-3) Already started: you tried to call a configuration function after the module has been started.
  • EALREADYINIT (-4) Already initialized: you called the initialization function more than once.

Initializing the module

Call data_acquisition_init() before any other functions from this module.

Configuring the module

TODO

Please refer to data_acquisition.h while this section is being built.

Starting the module

When all ADC configuration has been done, you can call data_acquisition_start() to start the module.

It is advised to only call the start function once all other modules initializations have been proceed to (e.g. at the end of the main()), as it will immediately start the ADCs and begin collect data.

Additional functions

For convenience, function data_acquisition_get_channel_name() gives you the name of an enabled channel. It can only be called after the configuration for an ADC has been provided using the data_acquisition_configure_adc_channels() function.

Available channels

Allowed values for the functions parameters are the channel numbers.

There are currently 6 channels that can be acquired by either ADC 1 or ADC 2, and 1 channel that is acquired by ADC 3.

Channel name Pin ADC Channel
I1_LOW PA1 1/2 2
I2_LOW PC1 1/2 7
I_HIGH PC2 1/2 8
V1_LOW PA0 1/2 1
V2_LOW PC0 1/2 6
V_HIGH PC3 1/2 9
TEMP_SENSOR PB1 3 1

µC_scheme Representation of the µController external pins

Enabling or disabling the module

This module is loaded by default. The user explicitly has to set CONFIG_OWNTECH_DATA_ACQUISITION=n in prj.conf to prevent the module from loading.