4043 views|1 replies

1458

Posts

1

Resources
The OP
 

[ST NUCLEO-U575ZI-Q Review] + Multi-channel ADC data acquisition [Copy link]

In the rheological analyzer, the detection of temperature, pressure, torque and speed is involved. The temperature and pressure both require ADC for data collection, while the speed detection requires pulse counting per unit time. As for the torque detection, ADC can be used for data collection, or it can be realized by pulse counting per unit time.

Therefore, it can be seen that multi-channel ADC data acquisition is very important.

The routines provided by the manufacturer include a single-channel ADC data acquisition example, which uses channel 9 and occupies pin PA4.

Figure 1 Pin Function

So how do we open more data collection channels?

Through data query, other data acquisition channels are shown in Figure 2. For this purpose, channel 7 and channel 8 corresponding to pins PA2 and PA3 are selected for use, thus making up 3 data acquisition channels.

Figure 2 Other acquisition channels

By adding a serial digital tube module, the collected data can be displayed in real time.

The initialization function of acquisition channel 9 is:

static void MX_ADC1_Init(void)
{
  ADC_ChannelConfTypeDef sConfig = {0};
  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV4;
  hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  hadc1.Init.GainCompensation = 0;
  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc1.Init.LowPowerAutoWait = DISABLE;
  hadc1.Init.ContinuousConvMode = DISABLE;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;
  hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
  hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
  hadc1.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }
  sConfig.Channel = ADC_CHANNEL_7;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SamplingTime = ADC_SAMPLETIME_391CYCLES_5;
  sConfig.SingleDiff = ADC_SINGLE_ENDED;
  sConfig.OffsetNumber = ADC_OFFSET_NONE;
  sConfig.Offset = 0;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
}

The main program for data collection and display is:

int main(void)
{
  uint16_t u;
  HAL_Init();
  SystemClock_Config();
  SystemPower_Config();
  MX_GPIO_Init();
  MX_ICACHE_Init();
  MX_ADC1_Init();
  if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
  {
      Error_Handler();
  }
  app_MAX7219();
  Init_MAX7219();
  Write_Max7219(1,0);
  Write_Max7219(2,0);
  Write_Max7219(3,0);
  Write_Max7219(4,0);
  Write_Max7219(5,15);
  Write_Max7219(6,15);
  Write_Max7219(7,15);
  Write_Max7219(8,15);
  while (1)
  {
    if (HAL_ADC_Start_IT(&hadc1) != HAL_OK)
    {
      Error_Handler();
    }
    while (ubAdcGrpRegularUnitaryConvStatus != 1);
    ubAdcGrpRegularUnitaryConvStatus = 0;
	u=uhADCxConvertedData_Voltage_mVolt;
	Write_Max7219(1,u%10);
    Write_Max7219(2,u%100/10);
    Write_Max7219(3,u%1000/100);
    Write_Max7219(4,u/1000);
	HAL_Delay(500);
  }
}

After the program is compiled and downloaded, its running effects are shown in Figures 3 to 5.

Figure 3 Random signal acquisition results

Figure 4 Collection results when grounding

Figure 5: Acquisition results when connected to VCC

This completes the data acquisition of the specified channel and converts the acquisition result into power (mV) for display. If you are acquiring data from multiple channels, you only need to rotate the acquisition channel during the acquisition process.

Taking the specified data acquisition channel 7 as an example, the statement is:

sConfig.Channel = ADC_CHANNEL_7;

It can be replaced with ADC_CHANNEL_8 and ADC_CHANNEL_9 to change the detection channel.

In the rheological analyzer, the detection of temperature, pressure and torque is achieved by obtaining 4~20mA current signals through the corresponding transmitters, and then converting them into 0~5V voltage signals through the current/voltage conversion module and connecting them to the three data acquisition channels. Of course, corresponding numerical conversion processing is required to display the corresponding physical quantity values, which will not be introduced in detail here.

This post is from RF/Wirelessly

Latest reply

Review summary: Free application | ST NUCLEO-U575ZI-Q https://bbs.eeworld.com.cn/thread-1228653-1-1.html   Details Published on 2023-1-12 09:35
 

1w

Posts

204

Resources
2
 

Review summary: Free application | ST NUCLEO-U575ZI-Q https://bbs.eeworld.com.cn/thread-1228653-1-1.html

This post is from RF/Wirelessly
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

https://bbs.eeworld.com.cn/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
STN-LCD color screen module

Abstract : This article introduces the internal structure, main components, and design selection requirements of the col ...

ADSL connection method in LAN

1. Add a 10M or 10/100M adaptive network card to the server   and connect the ADSL MODEM to the network card using the ...

Self-study experience of single chip microcomputer

Whether you are an amateur electronics enthusiast or a practitioner in the electronics industry, mastering microcontroll ...

C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

【TI recommended course】#Lecture on Basic Knowledge of Electronic Circuits - Power MOSFET#

//training.eeworld.com.cn/TI/show/course/3693

915MHz Hardware Design Based on CC1310

1. Overview The CC1310 combines an ultra-low power RF transceiver with a powerful 48MHz Cortex-M33 microcontroller, and ...

We dismantled a domestic medical B-ultrasound machine and let's take a look

I passed by a scrap yard and saw a B-ultrasound machine with a broken screen. I estimated that the screen was damaged i ...

Did you see the blood moon last night? Share it with everyone. I heard it is a once-in-a-millennium event.

I saw it when I opened my circle of friends at night. When I wanted to look, the moon was no longer red. Did you see the ...

Noise Suppression and Attenuation Techniques in Electronic Systems (Second Edition)

This book covers all aspects of the practical application of noise suppression technology in circuits. It covers two bas ...

Knowledge points about spectrum analyzer measuring RF signals

There is relatively little knowledge on the Internet about spectrum analyzers measuring RF signals. Is there any expert ...

快速回复 返回顶部 Return list