久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4331|回復: 7
打印 上一主題 下一主題
收起左側

基于TMS320F28027的微弱電壓測量源程序與Proteus仿真

  [復制鏈接]
跳轉到指定樓層
樓主
基于TMS320F28027芯片的微弱電壓信號測量,熟練掌握DSP開發環境CCS軟件以及Proteus電路設計軟件,掌握微弱電壓的測量方式,掌握TMS320F28027芯片的基本IO操作、中斷方式、ADC功能的使用,進一步了解DSP系統的特點。
  • 方案論證:
基于TMS320F28027芯片的微弱電壓信號測量方案包括如下幾部分:
  • 微弱電壓轉換電路
為了便于對微弱電壓(2*(10-3)*sin(100pi*t))進行測量,設計運算放大電路對微弱電壓進行放大處理,使得電壓變為0~3.2V,電路設計如下:
電壓計算公式:Vout=Rf/R*(u11-u12);
(2)基于TMS320F28027的電壓信號采集及轉換
TMS320F28027的ADC功能:
1.12位雙采樣保持電路。
2.同時采樣和序列采樣方式。
3.全范圍電壓輸入,0V到3.3V固定,或者VREFLO到VREFHI可調。
4.系統時鐘全頻運行,無需分頻。
5.16輸入通道。
6.16個SOC配置,設置觸發,采樣窗口,通道。
7.16個獨立保存轉換結果的結果寄存器。
8.多觸發源。
9.9個靈活的PIE中斷
ADC采集電壓計算公式如下:
Vol=(AdcResult.ADCRESULT0)/4096*3.3;
(3)電壓的動態顯示
測量到電壓后進行顯示,本次實驗采用LM016L型號LCD顯示器進行電壓顯示。
引腳接口說明:
第1腳:VSS為地電源。
第2腳:VDD接5V正電源。
第3腳:VL為液晶顯示器對比度調整端,接正電源時對比度最弱,接地時對比度最高。
第4腳:RS為寄存器選擇,高電平時選擇數據寄存器、低電平時選擇指令寄存器。
第5腳:R/W為讀寫信號線,高電平時進行讀操作,低電平時進行寫操作。當RS和R/W共同為低電平時可以寫入指令或者顯示地址,當RS為低電平R/W為高電平時可以讀忙信號,當RS為高電平R/W為低電平時可以寫入數據。
第6腳:E端為使能端,當E端由高電平跳變成低電平時,液晶模塊執行命令。
第7~14腳:D0~D7為8位雙向數據線。
LM016L接線如下所示:
指令如下所示:
序號
指令
RS
R/W
D7
D6
D5
D4
D3
D2
D1
D0
1
清顯示
0
0
0
0
0
0
0
0
0
1
2
光標返回
0
0
0
0
0
0
0
0
1
*
3
置輸入模式
0
0
0
0
0
0
0
1
I/D
S
4
顯示開/關控制
0
0
0
0
0
0
1
D
C
B
5
光標或字符移位
0
0
0
0
0
1
S/C
R/L
*
*
6
置功能
0
0
0
0
1
DL
N
F
*
*
7
置字符發生存貯器地址
0
0
0
1
字符發生存貯器地址
8
置數據存貯器地址
0
0
1
顯示數據存貯器地址
9
讀忙標志或地址
0
1
BF
計數器地址
10
寫數到CGRAM或DDRAM)
1
0
要寫的數據內容
11
從CGRAM或DDRAM讀數
1
1
讀出的數據內容

芯片時序表如下:
讀狀態
輸入
RS=L,R/W=H,E=H
輸出
D0—D7=狀態字
寫指令
輸入
RS=L,R/W=L,D0—D7=指令碼,E=高脈沖
輸出
讀數據
輸入
RS=H,R/W=H,E=H
輸出
D0—D7=數據
寫數據
輸入
RS=H,R/W=L,D0—D7=數據,E=高脈沖
輸出
  • 系統設計:
  • 系統框圖
(2)程序流程圖
  • 電路及程序
電路設計如下:
程序如下所示:
  1. #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

  2. // Prototype statements for functions found within this file.
  3. interrupt void adc_isr(void);
  4. void Gpio_select(void);
  5. void IOint();
  6. void CMDWrite(unsigned char cm );
  7. void DataWrite(unsigned char dt);
  8. void lcdinit();
  9. // Global variables used in this example:
  10. //Uint16 LoopCount;
  11. //Uint16 ConversionCount;
  12. //Uint16 TempSensorVoltage[10];
  13. Uint32 Volage=0;
  14. double vol=0;
  15. int16 bit1[3]={0};
  16. Uint16 flag=0;
  17. unsigned data='0';
  18. void main()
  19. {

  20. // Step 1. Initialize System Control:
  21. // PLL, WatchDog, enable Peripheral Clocks
  22. // This example function is found in the DSP2802x_SysCtrl.c file.
  23.    InitSysCtrl();

  24.    Gpio_select();
  25. // Step 2. Initialize GPIO:
  26. // This example function is found in the DSP2802x_Gpio.c file and
  27. // illustrates how to set the GPIO to it's default state.
  28. // InitGpio();  // Skipped for this example

  29. // Step 3. Clear all interrupts and initialize PIE vector table:
  30. // Disable CPU interrupts
  31.    DINT;

  32. // Initialize the PIE control registers to their default state.
  33. // The default state is all PIE interrupts disabled and flags
  34. // are cleared.
  35. // This function is found in the DSP2802x_PieCtrl.c file.
  36.    InitPieCtrl();

  37. // Disable CPU interrupts and clear all CPU interrupt flags:
  38.    IER = 0x0000;
  39.    IFR = 0x0000;

  40. // Initialize the PIE vector table with pointers to the shell Interrupt
  41. // Service Routines (ISR).
  42. // This will populate the entire table, even if the interrupt
  43. // is not used in this example.  This is useful for debug purposes.
  44. // The shell ISR routines are found in DSP2802x_DefaultIsr.c.
  45. // This function is found in DSP2802x_PieVect.c.
  46.    InitPieVectTable();

  47. // Interrupts that are used in this example are re-mapped to
  48. // ISR functions found within this file.
  49.    EALLOW;  // This is needed to write to EALLOW protected register
  50.    PieVectTable.ADCINT1 = &adc_isr;
  51.    EDIS;    // This is needed to disable write to EALLOW protected registers

  52. // Step 4. Initialize the ADC:
  53. // This function is found in DSP2802x_Adc.c
  54.    InitAdc();  // For this example, init the ADC

  55. // Step 5. Configure ADC to sample the temperature sensor on ADCIN5:
  56. // The output of Piccolo temperature sensor can be internally connected to the ADC through ADCINA5
  57. // via the TEMPCONV bit in the ADCCTL1 register. When this bit is set, any voltage applied to the external
  58. // ADCIN5 pin is ignored.
  59.               //EALLOW;
  60.               //AdcRegs.ADCCTL1.bit.TEMPCONV               = 1;              //Connect internal temp sensor to channel ADCINA5.
  61.               //EDIS;

  62. // Step 6. Continue configuring ADC to sample the temperature sensor on ADCIN5:
  63. // Since the temperature sensor is connected to ADCIN5, configure the ADC to sample channel ADCIN5
  64. // as well as the ADC SOC trigger and ADCINTs preferred. This example uses EPWM1A to trigger the ADC
  65. // to start a conversion and trips ADCINT1 at the end of the conversion.
  66.               EALLOW;
  67.               AdcRegs.ADCCTL1.bit.INTPULSEPOS              = 1;              //ADCINT1 trips after AdcResults latch
  68.               AdcRegs.ADCCTL1.bit.ADCBGPWD=1;
  69.               AdcRegs.ADCCTL1.bit.ADCPWDN=1;
  70.               AdcRegs.ADCCTL1.bit.ADCENABLE=1;
  71.               AdcRegs.ADCCTL1.bit.ADCREFSEL=0;
  72.               EDIS;
  73.               //DELAY_US(ADC_usDELAY);

  74.               EALLOW;
  75.               AdcRegs.INTSEL1N2.bit.INT1E     = 1;              //Enabled ADCINT1
  76.               //AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;              //Disable ADCINT1 Continuous mode
  77.               //AdcRegs.INTSEL1N2.bit.INT1SEL              = 0;              //setup EOC0 to trigger ADCINT1 to fire
  78.               AdcRegs.ADCSOC0CTL.bit.CHSEL               = 0;              //set SOC0 channel select to ADCINA5 (which is internally connected to the temperature sensor)
  79.               AdcRegs.ADCSOC0CTL.bit.TRIGSEL               = 5;              //set SOC0 start trigger on EPWM1A
  80.               AdcRegs.ADCSOC0CTL.bit.ACQPS               = 6;              //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
  81.               EDIS;


  82. // Step 7. User specific code, enable interrupts:

  83. // Enable ADCINT1 in PIE
  84.    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;              // Enable INT 1.1 in the PIE
  85.    IER |= M_INT1;                                                                                     // Enable CPU Interrupt 1
  86.    EINT;                                                                                              // Enable Global interrupt INTM
  87.    ERTM;                                                                                              // Enable Global realtime interrupt DBGM

  88.   // LoopCount = 0;
  89.    //ConversionCount = 0;


  90. // Assumes ePWM1 clock is already enabled in InitSysCtrl();
  91.    EPwm1Regs.ETSEL.bit.SOCAEN              = 1;                            // Enable SOC on A group
  92.    EPwm1Regs.ETSEL.bit.SOCASEL              = 4;                            // Select SOC from from CPMA on upcount
  93.    EPwm1Regs.ETPS.bit.SOCAPRD               = 1;                            // Generate pulse on 1st event
  94.    EPwm1Regs.CMPA.half.CMPA               = 0x0080;              // Set compare A value
  95.    EPwm1Regs.TBPRD                                                         = 0xFFFF;              // Set period for ePWM1
  96.    EPwm1Regs.TBCTL.bit.CTRMODE               = 0;                            // count up and start



  97. // Wait for ADC interrupt
  98.    IOint();
  99.    lcdinit();
  100.    //DataWrite(1);

  101.    for(;;)
  102.    {

  103.        if(flag==1)
  104.        {
  105.           flag=0;
  106.           CMDWrite(0x80);

  107.           if(bit1[0]>0)
  108.           {
  109.               DataWrite('+');
  110.               DataWrite('0');
  111.               DataWrite('.');
  112.               DataWrite('0');
  113.               DataWrite('0');
  114.               DataWrite(abs(bit1[2])+'0');
  115.               DataWrite(abs(bit1[1])+'0');
  116.               DataWrite(abs(bit1[0])+'0');
  117.           }
  118.           else
  119.           {
  120.               DataWrite('-');
  121.               DataWrite('0');
  122.             DataWrite('.');
  123.             DataWrite('0');
  124.             DataWrite('0');
  125.             DataWrite(abs(bit1[2])+'0');
  126.             DataWrite(abs(bit1[1])+'0');
  127.             DataWrite(abs(bit1[0])+'0');

  128.           }

  129.        }

  130.    }

  131. }


  132. interrupt void  adc_isr(void)
  133. {

  134.   //TempSensorVoltage[ConversionCount] = AdcResult.ADCRESULT0;
  135.   Volage= AdcResult.ADCRESULT0;
  136.   vol=(3.3/4096*Volage+1.6)/800-0.004;

  137.   bit1[0] = ((int32)(vol*100000))%10;
  138.   bit1[1] = ((int32)(vol*10000))%10;
  139.   bit1[2] = ((int32)(vol*1000))%10;

  140.   AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;                            //Clear ADCINT1 flag reinitialize for next SOC
  141.   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE
  142.   flag=1;
  143.   return;
  144. }

  145. void Gpio_select(void)
  146. {


  147.     EALLOW;
  148.     GpioCtrlRegs.GPAMUX1.all = 0x00000000;  // All GPIO
  149.     GpioCtrlRegs.GPAMUX2.all = 0x00000000;  // All GPIO
  150.     GpioCtrlRegs.GPAMUX1.all = 0x00000000;  // All GPIO
  151.     GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF;   // All outputs
  152.     GpioCtrlRegs.GPBDIR.all = 0x0000000F;   // All outputs
  153.     EDIS;

  154. }

  155. void IOint()
  156. {
  157.        EALLOW;

  158.       GpioCtrlRegs.GPAPUD.all=0;
  159.       GpioDataRegs.GPASET.all=1;
  160.       GpioCtrlRegs.GPAMUX1.all=0;
  161.       GpioCtrlRegs.GPADIR.all=0;

  162.      GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;   // Enable pullup on GPIO6  //RS
  163.      GpioDataRegs.GPBSET.bit.GPIO32= 1;   // Load output latch
  164.      GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0;  // GPIO6 = GPIO6
  165.      GpioCtrlRegs.GPBDIR.bit.GPIO32 = 1;

  166.      GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;   // Enable pullup on GPIO6  //RW
  167.       GpioDataRegs.GPBSET.bit.GPIO33= 1;   // Load output latch
  168.       GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0;  // GPIO6 = GPIO6
  169.       GpioCtrlRegs.GPBDIR.bit.GPIO33 = 1;

  170.       GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0;   // Enable pullup on GPIO6   //E
  171.       GpioDataRegs.GPBSET.bit.GPIO34= 1;   // Load output latch
  172.       GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;  // GPIO6 = GPIO6
  173.       GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;

  174.        EDIS;
  175. }

  176. void CMDWrite(unsigned char cm )
  177. {

  178.     GpioDataRegs.GPBDAT.bit.GPIO32=0;
  179.     GpioDataRegs.GPADAT.all=cm;
  180.     DELAY_US(2);
  181.      GpioDataRegs.GPBDAT.bit.GPIO34=1;
  182.      DELAY_US(2);
  183.      GpioDataRegs.GPBDAT.bit.GPIO34=0;

  184. }
  185. void DataWrite(unsigned char dt)
  186. {

  187.     GpioDataRegs.GPBDAT.bit.GPIO32=1;
  188.     GpioDataRegs.GPADAT.all=dt;
  189.     DELAY_US(2);
  190.     GpioDataRegs.GPBDAT.bit.GPIO34=1;
  191.     DELAY_US(2);
  192.     GpioDataRegs.GPBDAT.bit.GPIO34=0;
  193. }
  194. void lcdinit()
  195. {
  196.     GpioDataRegs.GPBDAT.bit.GPIO33=0;
  197.     GpioDataRegs.GPBDAT.bit.GPIO34=0;

  198.     CMDWrite(0x38);
  199.     CMDWrite(0x06);
  200.     CMDWrite(0x0c);


  201. }
復制代碼

  • 仿真結果(附件)
在Proteus軟件進行仿真,仿真結果截圖如下:
   LCD顯示小數點后5位,輸入正弦電壓幅值為0.002,顯示精度為百分之一。


全部資料51hei下載地址:
Proteus仿真與ccs代碼.7z (5.99 MB, 下載次數: 97)
基于TMS320F28027的微弱電壓測量.doc (453.5 KB, 下載次數: 37)

評分

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

查看全部評分

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

使用道具 舉報

沙發
ID:326044 發表于 2022-11-2 20:02 | 只看該作者
軟件不全,能發全嗎
回復

使用道具 舉報

板凳
ID:894794 發表于 2023-5-5 11:41 | 只看該作者
資料很全,很好謝謝樓主
回復

使用道具 舉報

地板
ID:1074206 發表于 2023-5-16 22:45 | 只看該作者
protuse竟然可以仿真DSP,666
回復

使用道具 舉報

5#
ID:420836 發表于 2023-5-17 08:58 | 只看該作者
如果測量的電壓非常小,低至幾毫伏,則可以使用儀器級運算放大器。
回復

使用道具 舉報

6#
ID:899981 發表于 2023-10-16 16:14 | 只看該作者
281523048 發表于 2023-5-5 11:41
資料很全,很好謝謝樓主

您好,能否把能編譯工程發一下,謝謝。
回復

使用道具 舉報

7#
ID:899981 發表于 2023-10-16 16:27 | 只看該作者
您好,這個例程很好,能否給個能編譯的整套源碼?
回復

使用道具 舉報

8#
ID:1142596 發表于 2025-1-6 18:01 | 只看該作者
資料很好,謝謝樓主
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 福利一区二区 | 国产精品三级 | 亚欧精品 | 精品一二区 | 国产永久免费 | 亚洲视频一区在线 | 亚洲国产成人精品久久久国产成人一区 | 99国产精品久久久 | 久久免费高清 | 久久av一区二区三区 | 爱操影视| 在线一区二区三区 | 日韩一级电影免费观看 | 欧美专区在线 | 一区二区免费视频 | 中文字幕电影在线观看 | 羞羞视频网站免费观看 | 色av一区二区 | 欧美性受xxxx白人性爽 | 国产高清免费视频 | 午夜影院中文字幕 | 久久久久久久久久久久一区二区 | 欧美日韩免费一区二区三区 | 日本久久精品视频 | 日韩久久网 | 精品一区在线看 | 一区二区三区四区av | 亚洲国产aⅴ精品一区二区 免费观看av | 91视频国产区 | 美国一级片在线观看 | 免费三级av| 精品久草| 欧美 日韩 国产 一区 | 久久精品国产久精国产 | 毛片在线看片 | 在线一区 | 国产激情精品一区二区三区 | 亚洲成人免费在线 | 亚洲毛片| 亚洲精品国产一区 | 在线看一区二区三区 |