precision-converters-firmware
Classes | Macros | Enumerations | Functions | Variables
ad7124_console_app.c File Reference

AD7124 temperature measurement firmware console interface. More...

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include "app_config.h"
#include "mbed_platform_support.h"
#include "no_os_util.h"
#include "no_os_error.h"
#include "no_os_spi.h"
#include "ad7124.h"
#include "ad7124_regs.h"
#include "ad7124_support.h"
#include "ad7124_regs_configs.h"
#include "ad7124_console_app.h"
#include "ad7124_user_config.h"
#include "ad7124_temperature_sensor.h"
Include dependency graph for ad7124_console_app.c:

Classes

struct  adc_calibration_configs
 

Macros

#define MAX_ADC_SAMPLES   100
 
#define MAX_AVG_ADC_SAMPLES   8
 
#define MAX_RTD_SENSORS   5
 
#define MAX_THERMOCOUPLE_SENSORS   6
 
#define MAX_NTC_THERMISTOR_SENSORS   8
 
#define AD7124_MAX_INPUTS   8
 
#define AD7124_DEFAULT_OFFSET   0x800000
 
#define AD7124_MAX_CONFIGS_USED   3
 
#define CONVERSION_TIMEOUT   10000
 
#define CJC_RTD_CHN   SENSOR_CHANNEL6
 
#define CJC_THERMISTOR_CHN   SENSOR_CHANNEL7
 
#define RTD_3WIRE_REF_MEASUREMENT_CHN   SENSOR_CHANNEL4
 

Enumerations

enum  sensor_channels {
  SENSOR_CHANNEL0 ,
  SENSOR_CHANNEL1 ,
  NUM_OF_SENSOR_CHANNELS ,
  SENSOR_CHANNEL0 ,
  SENSOR_CHANNEL1 ,
  SENSOR_CHANNEL2 ,
  SENSOR_CHANNEL3 ,
  NUM_OF_SENSOR_CHANNELS ,
  SENSOR_CHANNEL0 ,
  SENSOR_CHANNEL1 ,
  SENSOR_CHANNEL2 ,
  SENSOR_CHANNEL3 ,
  SENSOR_CHANNEL4 ,
  SENSOR_CHANNEL5 ,
  SENSOR_CHANNEL6 ,
  SENSOR_CHANNEL7 ,
  NUM_OF_SENSOR_CHANNELS
}
 
enum  sensor_measurement_type {
  AVERAGED_MEASUREMENT ,
  SINGLE_MEASUREMENT ,
  CONTINUOUS_MEASUREMENT
}
 
enum  adc_calibration_type {
  INTERNAL_CALIBRATION ,
  SYSTEM_CALIBRATION
}
 
enum  rtd_3wire_calibration_type {
  MEASURING_EXCITATION_CURRENT ,
  CHOPPING_EXCITATION_CURRENT
}
 

Functions

int32_t ad7124_app_initialize (uint8_t config_id)
 Initialize the AD7124 device and user configuration. More...
 
int32_t enable_disable_sensor (uint32_t chn_number)
 Enable the multiple sensors for measurement. More...
 
int32_t select_cjc_sensor (uint32_t cjc_sensor)
 Select the CJC sensor for thermocouple measurement. More...
 
int32_t perform_ntc_thermistor_measurement (uint32_t measurement_type)
 Perform the multiple NTC thermistor sensors measurement. More...
 
int32_t perform_cjc_measurement (int32_t(*data)[MAX_ADC_SAMPLES], sensor_measurement_type measurement_type)
 Perform the cold junction compensation (CJC) measurement. More...
 
int32_t perform_thermocouple_measurement (uint32_t measurement_type)
 Perform the multiple thermocouple sensors measurement. More...
 
int32_t perform_adc_calibration (uint32_t calibration_type)
 Perform the AD7124 internal/system calibration. More...
 
void rtd_2wire_menu_header (void)
 Display header information for 2-wire RTD measurement menu. More...
 
void rtd_3wire_menu_header (void)
 Display header information for 3-wire RTD measurement menu. More...
 
void rtd_3wire_calibration_menu_header (void)
 Display header information for 3-wire RTD calibration menu. More...
 
void rtd_4wire_menu_header (void)
 Display header information for 4-wire RTD measurement menu. More...
 
void ntc_thermistor_menu_header (void)
 Display header information for NTC thermistor measurement menu. More...
 
void thermocouple_menu_header (void)
 Display header information for NTC thermistor measurement menu. More...
 
void adc_calibration_menu_header (void)
 Display header information for ADC calibration menu. More...
 
void main_menu_header (void)
 Display header information for main menu. More...
 
int32_t display_2wire_rtd_menu (uint32_t menu_id)
 Display 2-wire RTD measurement main menu. More...
 
int32_t display_3wire_rtd_menu (uint32_t menu_id)
 Display 3-wire RTD measurement main menu. More...
 
int32_t display_3wire_rtd_calibration_menu (uint32_t menu_id)
 Display 3-wire RTD calibration main menu. More...
 
int32_t display_4wire_rtd_menu (uint32_t menu_id)
 Display 4-wire RTD measurement main menu. More...
 
int32_t display_thermocouple_menu (uint32_t menu_id)
 Display thermoucouple measurement main menu. More...
 
int32_t display_ntc_thermistor_menu (uint32_t menu_id)
 Display thermistor measurement main menu. More...
 
int32_t display_adc_calibration_menu (uint32_t menu_id)
 Display ADC calibration main menu. More...
 
int32_t reset_device_config (uint32_t menu_id)
 Display ADC calibration main menu. More...
 

Variables

enum rtd_3wire_calibration_type rtd_3wire_calibration_type
 
console_menu rtd_2wire_menu
 
console_menu rtd_3wire_menu
 
console_menu rtd_3wire_calibration_menu
 
console_menu rtd_4wire_menu
 
console_menu ntc_thermistor_menu
 
console_menu thermocouple_menu
 
console_menu adc_calibration_menu
 
console_menu ad7124_main_menu
 

Detailed Description

AD7124 temperature measurement firmware console interface.

This file is specific to ad7124 console menu application handle. The functions defined in this file performs the action based on user selected console menu.

Copyright (c) 2021-22 Analog Devices, Inc. All rights reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Macro Definition Documentation

◆ AD7124_DEFAULT_OFFSET

#define AD7124_DEFAULT_OFFSET   0x800000

◆ AD7124_MAX_CONFIGS_USED

#define AD7124_MAX_CONFIGS_USED   3

◆ AD7124_MAX_INPUTS

#define AD7124_MAX_INPUTS   8

◆ CJC_RTD_CHN

#define CJC_RTD_CHN   SENSOR_CHANNEL6

◆ CJC_THERMISTOR_CHN

#define CJC_THERMISTOR_CHN   SENSOR_CHANNEL7

◆ CONVERSION_TIMEOUT

#define CONVERSION_TIMEOUT   10000

◆ MAX_ADC_SAMPLES

#define MAX_ADC_SAMPLES   100

◆ MAX_AVG_ADC_SAMPLES

#define MAX_AVG_ADC_SAMPLES   8

◆ MAX_NTC_THERMISTOR_SENSORS

#define MAX_NTC_THERMISTOR_SENSORS   8

◆ MAX_RTD_SENSORS

#define MAX_RTD_SENSORS   5

◆ MAX_THERMOCOUPLE_SENSORS

#define MAX_THERMOCOUPLE_SENSORS   6

◆ RTD_3WIRE_REF_MEASUREMENT_CHN

#define RTD_3WIRE_REF_MEASUREMENT_CHN   SENSOR_CHANNEL4

Enumeration Type Documentation

◆ adc_calibration_type

Enumerator
INTERNAL_CALIBRATION 
SYSTEM_CALIBRATION 

◆ rtd_3wire_calibration_type

Enumerator
MEASURING_EXCITATION_CURRENT 
CHOPPING_EXCITATION_CURRENT 

◆ sensor_channels

Enumerator
SENSOR_CHANNEL0 
SENSOR_CHANNEL1 
NUM_OF_SENSOR_CHANNELS 
SENSOR_CHANNEL0 
SENSOR_CHANNEL1 
SENSOR_CHANNEL2 
SENSOR_CHANNEL3 
NUM_OF_SENSOR_CHANNELS 
SENSOR_CHANNEL0 
SENSOR_CHANNEL1 
SENSOR_CHANNEL2 
SENSOR_CHANNEL3 
SENSOR_CHANNEL4 
SENSOR_CHANNEL5 
SENSOR_CHANNEL6 
SENSOR_CHANNEL7 
NUM_OF_SENSOR_CHANNELS 

◆ sensor_measurement_type

Enumerator
AVERAGED_MEASUREMENT 
SINGLE_MEASUREMENT 
CONTINUOUS_MEASUREMENT 

Function Documentation

◆ ad7124_app_initialize()

int32_t ad7124_app_initialize ( uint8_t  config_id)

Initialize the AD7124 device and user configuration.

Initialize the AD7124 device and the SPI port as required.

Parameters
config_id[in]-Register configuration to be load into device
Returns
0 in case of success, negative error code otherwise

This resets and then writes the default register map value to the device. A call to init the SPI port is made, but may not actually do very much, depending on the platform.

◆ adc_calibration_menu_header()

void adc_calibration_menu_header ( void  )

Display header information for ADC calibration menu.

Returns
none

◆ display_2wire_rtd_menu()

int32_t display_2wire_rtd_menu ( uint32_t  menu_id)

Display 2-wire RTD measurement main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_3wire_rtd_calibration_menu()

int32_t display_3wire_rtd_calibration_menu ( uint32_t  menu_id)

Display 3-wire RTD calibration main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_3wire_rtd_menu()

int32_t display_3wire_rtd_menu ( uint32_t  menu_id)

Display 3-wire RTD measurement main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_4wire_rtd_menu()

int32_t display_4wire_rtd_menu ( uint32_t  menu_id)

Display 4-wire RTD measurement main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_adc_calibration_menu()

int32_t display_adc_calibration_menu ( uint32_t  menu_id)

Display ADC calibration main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_ntc_thermistor_menu()

int32_t display_ntc_thermistor_menu ( uint32_t  menu_id)

Display thermistor measurement main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ display_thermocouple_menu()

int32_t display_thermocouple_menu ( uint32_t  menu_id)

Display thermoucouple measurement main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ enable_disable_sensor()

int32_t enable_disable_sensor ( uint32_t  chn_number)

Enable the multiple sensors for measurement.

Parameters
chn_number[in]-Channel number assigned for the sensor
Returns
MENU_CONTINUE
Note
Each sensor has been assigned with unique channel number

◆ main_menu_header()

void main_menu_header ( void  )

Display header information for main menu.

Returns
none

◆ ntc_thermistor_menu_header()

void ntc_thermistor_menu_header ( void  )

Display header information for NTC thermistor measurement menu.

Returns
none

◆ perform_adc_calibration()

int32_t perform_adc_calibration ( uint32_t  calibration_type)

Perform the AD7124 internal/system calibration.

Parameters
calibration_type[in]-ADC calibration type (internal/system)
Returns
MENU_CONTINUE
Note
This function performs both 'Internal/System Full-Scale' and 'Internal/System Zero-Scale' calibration on all enabled ADC channels sequentially.

◆ perform_cjc_measurement()

int32_t perform_cjc_measurement ( int32_t(*)  data[MAX_ADC_SAMPLES],
sensor_measurement_type  measurement_type 
)

Perform the cold junction compensation (CJC) measurement.

Parameters
*data[out]-Pointer to array to read data into
measurement_type[in]-Temperature measurement and display type
Returns
0 in case of success, negative error code otherwise
Note
Both CJCs uses similar excitation and ratiometric measurement logic

◆ perform_ntc_thermistor_measurement()

int32_t perform_ntc_thermistor_measurement ( uint32_t  measurement_type)

Perform the multiple NTC thermistor sensors measurement.

Parameters
measurement_type[in]-Temperature measurement and display type
Returns
MENU_CONTINUE

◆ perform_thermocouple_measurement()

int32_t perform_thermocouple_measurement ( uint32_t  measurement_type)

Perform the multiple thermocouple sensors measurement.

Parameters
measurement_type[in]-Temperature measurement and display type
Returns
MENU_CONTINUE

◆ reset_device_config()

int32_t reset_device_config ( uint32_t  menu_id)

Display ADC calibration main menu.

Parameters
menu_id[in]-Optional menu ID
Returns
MENU_CONTINUE

◆ rtd_2wire_menu_header()

void rtd_2wire_menu_header ( void  )

Display header information for 2-wire RTD measurement menu.

Returns
none

◆ rtd_3wire_calibration_menu_header()

void rtd_3wire_calibration_menu_header ( void  )

Display header information for 3-wire RTD calibration menu.

Returns
none

◆ rtd_3wire_menu_header()

void rtd_3wire_menu_header ( void  )

Display header information for 3-wire RTD measurement menu.

Returns
none

◆ rtd_4wire_menu_header()

void rtd_4wire_menu_header ( void  )

Display header information for 4-wire RTD measurement menu.

Returns
none

◆ select_cjc_sensor()

int32_t select_cjc_sensor ( uint32_t  cjc_sensor)

Select the CJC sensor for thermocouple measurement.

Parameters
cjc_sensor[in]-CJC sensor to be selected
Returns
MENU_CONTINUE
Only one CJC sensor is active at a time, therefore fixed channel value is selected for it during measurement

◆ thermocouple_menu_header()

void thermocouple_menu_header ( void  )

Display header information for NTC thermistor measurement menu.

Returns
none

Variable Documentation

◆ ad7124_main_menu

console_menu ad7124_main_menu
Initial value:
= {
.title = "AD7124 Sensor Measurement Menu",
.items = main_menu_items,
.itemCount = ARRAY_SIZE(main_menu_items),
.headerItem = main_menu_header,
.footerItem = NULL,
.enableEscapeKey = false
}
console_menu_item main_menu_items[]
Definition: ad5592r_console_app.c:1057
void main_menu_header(void)
Display header information for main menu.
Definition: ad7124_console_app.c:2322
#define ARRAY_SIZE(x)
Definition: adi_console_menu.h:49

◆ adc_calibration_menu

console_menu adc_calibration_menu
Initial value:
= {
.title = "AD7124 Calibration",
.items = adc_calibration_menu_items,
.itemCount = ARRAY_SIZE(adc_calibration_menu_items),
.footerItem = NULL,
.enableEscapeKey = true
}
void adc_calibration_menu_header(void)
Display header information for ADC calibration menu.
Definition: ad7124_console_app.c:2295

◆ ntc_thermistor_menu

console_menu ntc_thermistor_menu
Initial value:
= {
.title = "NTC Thermistor Measurement",
.items = ntc_thermistor_menu_items,
.itemCount = ARRAY_SIZE(ntc_thermistor_menu_items),
.footerItem = NULL,
.enableEscapeKey = true
}
void ntc_thermistor_menu_header(void)
Display header information for NTC thermistor measurement menu.
Definition: ad7124_console_app.c:2166

◆ rtd_2wire_menu

console_menu rtd_2wire_menu
Initial value:
= {
.title = "2-Wire RTD Measurement",
.items = rtd_2wire_menu_items,
.itemCount = ARRAY_SIZE(rtd_2wire_menu_items),
.headerItem = rtd_2wire_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
void rtd_2wire_menu_header(void)
Display header information for 2-wire RTD measurement menu.
Definition: ad7124_console_app.c:1964

◆ rtd_3wire_calibration_menu

console_menu rtd_3wire_calibration_menu
Initial value:
= {
.title = "Calibrate 3-Wire RTD Excitation Source",
.items = rtd_3wire_calibration_menu_items,
.itemCount = ARRAY_SIZE(rtd_3wire_calibration_menu_items),
.footerItem = NULL,
.enableEscapeKey = true
}
void rtd_3wire_calibration_menu_header(void)
Display header information for 3-wire RTD calibration menu.
Definition: ad7124_console_app.c:2056

◆ rtd_3wire_calibration_type

Initial value:
=
@ MEASURING_EXCITATION_CURRENT
Definition: ad7124_console_app.c:200

◆ rtd_3wire_menu

console_menu rtd_3wire_menu
Initial value:
= {
.title = "3-Wire RTD Measurement",
.items = rtd_3wire_menu_items,
.itemCount = ARRAY_SIZE(rtd_3wire_menu_items),
.headerItem = rtd_3wire_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
void rtd_3wire_menu_header(void)
Display header information for 3-wire RTD measurement menu.
Definition: ad7124_console_app.c:2005

◆ rtd_4wire_menu

console_menu rtd_4wire_menu
Initial value:
= {
.title = "4-Wire RTD Measurement",
.items = rtd_4wire_menu_items,
.itemCount = ARRAY_SIZE(rtd_4wire_menu_items),
.headerItem = rtd_4wire_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
void rtd_4wire_menu_header(void)
Display header information for 4-wire RTD measurement menu.
Definition: ad7124_console_app.c:2125

◆ thermocouple_menu

console_menu thermocouple_menu
Initial value:
= {
.title = "Thermocouple Measurement",
.items = thermocouple_menu_items,
.itemCount = ARRAY_SIZE(thermocouple_menu_items),
.headerItem = thermocouple_menu_header,
.footerItem = NULL,
.enableEscapeKey = true
}
void thermocouple_menu_header(void)
Display header information for NTC thermistor measurement menu.
Definition: ad7124_console_app.c:2218