找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5119|回復(fù): 3
打印 上一主題 下一主題
收起左側(cè)

STM32 AD轉(zhuǎn)換采樣電壓十二位二進(jìn)制數(shù)LED燈顯示Proteus仿真

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:436144 發(fā)表于 2018-12-18 17:09 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
STM32單片機(jī)AD轉(zhuǎn)換采樣電壓十二位二進(jìn)制數(shù)LED燈顯示proteus仿真
上周做的用LED燈顯示AD采樣電壓十二位二進(jìn)制顯示
粗略的顯示了一下,有些不足,希望大家能夠給予指導(dǎo)并相互學(xué)習(xí)。

仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #include "stm32f10x.h"
  2. #include "usart1.h"
  3. #include "adc.h"
  4. #include "stdio.h"
  5. #include "led.h"

  6. float temp;
  7. int main(void)
  8. {
  9.         GPIO_Led_Config();
  10.   ADC1_GPIO_Config();
  11.   ADC_Config();
  12.         while(1)
  13.         {               
  14.     int a,b,c,d,e,f,g,h,i,j,k,l,m;                        
  15.                          ADCConvertedValue=ADC_GetConversionValue(ADC1);
  16. //                         temp=(float)ADCConvertedValue*(3.3/4096);         
  17.                 a=ADCConvertedValue;
  18.         b=a%2;
  19.         c=(a/2)%2;
  20.         d=(a/4)%2;
  21.         e=(a/8)%2;
  22.         f=(a/16)%2;
  23.         g=(a/32)%2;
  24.         h=(a/64)%2;
  25.         i=(a/128)%2;
  26.         j=(a/256)%2;
  27.         k=(a/512)%2;
  28.         l=(a/1024)%2;
  29.         m=(a/2048)%2;
  30.         
  31. if(b==1)        
  32.         GPIO_SetBits(GPIOB,GPIO_Pin_1);
  33. else
  34.         GPIO_ResetBits(GPIOB,GPIO_Pin_1);
  35. if(c==1)        
  36.         GPIO_SetBits(GPIOB,GPIO_Pin_2);
  37. else
  38.         GPIO_ResetBits(GPIOB,GPIO_Pin_2);
  39. if(d==1)        
  40.         GPIO_SetBits(GPIOB,GPIO_Pin_3);
  41. else
  42.         GPIO_ResetBits(GPIOB,GPIO_Pin_3);
  43. if(e==1)        
  44.         GPIO_SetBits(GPIOB,GPIO_Pin_4);
  45. else
  46.         GPIO_ResetBits(GPIOB,GPIO_Pin_4);
  47. if(f==1)        
  48.         GPIO_SetBits(GPIOB,GPIO_Pin_5);
  49. else
  50.         GPIO_ResetBits(GPIOB,GPIO_Pin_5);
  51. if(g==1)        
  52.         GPIO_SetBits(GPIOB,GPIO_Pin_6);
  53. else
  54.         GPIO_ResetBits(GPIOB,GPIO_Pin_6);
  55. if(h==1)        
  56.         GPIO_SetBits(GPIOB,GPIO_Pin_7);
  57. else
  58.         GPIO_ResetBits(GPIOB,GPIO_Pin_7);
  59. if(i==1)        
  60.         GPIO_SetBits(GPIOB,GPIO_Pin_8);
  61. else
  62.         GPIO_ResetBits(GPIOB,GPIO_Pin_8);
  63. if(j==1)        
  64.         GPIO_SetBits(GPIOB,GPIO_Pin_9);
  65. else
  66.         GPIO_ResetBits(GPIOB,GPIO_Pin_9);
  67. if(k==1)        
  68.         GPIO_SetBits(GPIOB,GPIO_Pin_10);
  69. else
  70.         GPIO_ResetBits(GPIOB,GPIO_Pin_10);
  71. if(l==1)        
  72.         GPIO_SetBits(GPIOB,GPIO_Pin_11);
  73. else
  74.         GPIO_ResetBits(GPIOB,GPIO_Pin_11);
  75. if(m==1)        
  76.         GPIO_SetBits(GPIOB,GPIO_Pin_12);
  77. else
  78.         GPIO_ResetBits(GPIOB,GPIO_Pin_12);
  79.         }
  80. }
  81.         
復(fù)制代碼

所有資料51hei提供下載:
ADC.7z (262.74 KB, 下載次數(shù): 86)


評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:224469 發(fā)表于 2018-12-25 09:56 | 只看該作者
運行protues直接卡死了
回復(fù)

使用道具 舉報

板凳
ID:162058 發(fā)表于 2019-4-24 16:56 | 只看該作者
樓主,AD采樣的參考電壓是怎么設(shè)置的啊
回復(fù)

使用道具 舉報

地板
ID:324291 發(fā)表于 2020-11-12 11:17 | 只看該作者
lumilu 發(fā)表于 2019-4-24 16:56
樓主,AD采樣的參考電壓是怎么設(shè)置的啊

滑動變壓器吧
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表