推荐星级:
  • 1
  • 2
  • 3
  • 4
  • 5

STM32F407单片机24bit_ADC_AD7190称重模块+16bit_DAC_电压输出实验K

更新时间:2021-09-07 13:45:28 大小:7M 上传用户:xzxbybd查看TA发布的资源 标签:stm32f407单片机 下载积分:8分 评价赚积分 (如何评价?) 打赏 收藏 评论(0) 举报

资料介绍

STM32F407单片机24bit_ADC_AD7190称重模块+16bit_DAC_电压输出实验KEIL工程源码

int main(void)

{

  uint16_t data=0xFFFF/2;

  double temp,opa;

  float data_temp;      

  int32_t weight_count;  

  uint8_t cali_flag=0;

  /* 复位所有外设,初始化Flash接口和系统滴答定时器 */

  HAL_Init();

  /* 配置系统时钟 */

  SystemClock_Config();


  /* 初始化串口并配置串口中断优先级 */

  MX_DEBUG_USART_Init();

  /* 初始化LED */

  LED_GPIO_Init(); 

  

  KEY_GPIO_Init();

  /* 初始化BEEP */

  BEEP_GPIO_Init();

  

  if(AD7190_Init()==0)

  {

    printf("获取不到 AD7190 !\n");

    while(1)

    {

      HAL_Delay(1000);

      if(AD7190_Init())

        break;

    }

  }

  printf("检测到  AD7190 !\n");

  weight_ad7190_conf();

  

  HAL_Delay(500);

  weight_Zero_Data = weight_ad7190_ReadAvg(6);

  printf("zero:%d\n",weight_Zero_Data);

  printf("硬石DAC(AD5689)模块模拟量电压输出\n"); 

  

  AD5689_Init();

  AD5689_WriteUpdate_DACREG(DAC_A,data); 

  AD5689_WriteUpdate_DACREG(DAC_B,0xFFFF-data); 

  printf("data:%d\n",data);

  

  opa=OPA_RES_R2/OPA_RES_R1;  

  while(1)

  {

    weight_count=weight_ad7190_ReadAvg(3);

    data_temp=weight_count-weight_Zero_Data;

    weight=data_temp*1000/weight_proportion;

    printf("重量:%d->%.2f\n",weight_count,weight);

    HAL_Delay(200);

    if(KEY1_StateRead()==KEY_DOWN)  // 清零

    {      

      weight_Zero_Data = weight_ad7190_ReadAvg(6);

      printf("zero:%d\n",weight_Zero_Data);

      cali_flag=1;

    }

    if(KEY2_StateRead()==KEY_DOWN) // 校准:必须先按“清零”键,然后把20g砝码放在称上,按下校准键

    {

      if(cali_flag)

      {

        weight_count = weight_ad7190_ReadAvg(6);

        weight_proportion=(weight_count-weight_Zero_Data)*1000/100;

        printf("weight_proportion:%d\n",weight_proportion);

      }

      cali_flag=0;

    }

    

    if(KEY3_StateRead()==KEY_DOWN)

    {

      if(data>(0xFFFF-1000))

        data=(0xFFFF-1000);

      data +=1000;

      AD5689_WriteUpdate_DACREG(DAC_A,data); 

      AD5689_WriteUpdate_DACREG(DAC_B,0xFFFF-data);

      temp=(double)(data*2-0xFFFF)*2500*opa/0xFFFF;

      //temp为目标电源值,这里先放大1000倍(方便计算而已),等后面显示再还原

      //data是数字量DA值,当data取值


部分文件列表

文件名文件大小修改时间
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/.mxproject6KB2017-03-31 17:13:56
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h707KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xe.h707KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f405xx.h1203KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h1316KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410cx.h591KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410rx.h592KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410tx.h587KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f411xe.h710KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412cx.h1141KB2017-05-27 11:05:48
YSF4_HAL_AD_DA-102. 24bit_ADC_AD7190称重模块+16bit_DAC_电压输出/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412rx.h1227KB2017-05-27 11:05:48
...

全部评论(0)

暂无评论

上传资源 上传优质资源有赏金

  • 打赏
  • 30日榜单

推荐下载