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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4521|回復: 3
收起左側

FDC2214/STM32F103設計源碼+電路圖pcb封裝庫

[復制鏈接]
ID:444798 發表于 2018-12-12 14:21 | 顯示全部樓層 |閱讀模式
FDC2214原理圖手冊源碼封裝庫等相關資料下載
1. Schematic design
2. Firmware

Folder

Folder

0.png

單片機源程序如下:
  1. /*******************************************************************************
  2.   * @file    Project/fdc2214.c
  3.   * @author  T.D.NGUYEN
  4.   * @version V1.1.0
  5.   * @date    05/24/2018
  6.   * @brief   STM32F1-FDC2214 using I2C1-CAN to PC.
  7.   ******************************************************************************
  8.   *(C) COPYRIGHT 2018 @DV1985a
  9.   */

  10. /* Includes ------------------------------------------------------------------*/
  11. #include "stm32f10x.h"
  12. #include "stm32f10x_conf.h"
  13. #include "platform_config.h"
  14. #include "fdc2214.h"
  15. #include <stdio.h>
  16. #include "stdlib.h"
  17. #include "string.h"   
  18. #include <stdbool.h>
  19. #include "led.h"
  20. #include "i2c.h"
  21. #include "stm32f10x_exti.c" // External interrupt

  22. //*****************************************************************************
  23. //*****************************************************************************
  24. // #defines
  25. //*****************************************************************************
  26. #define PROX_INTEGRAL_THRESHOLD         200
  27. #define PROX_INTEGRAL_HYS                        1.2
  28. #define B1_INTEGRAL_THRESHOLD            90000
  29. #define B2_INTEGRAL_THRESHOLD                90000
  30. #define B1_INTEGRAL_CAP                            300000
  31. #define B2_INTEGRAL_CAP                                300000
  32. #define PROX_DERIVATIVE_THRESHOLD        0
  33. #define B1_DERIVATIVE_THRESHOLD                3000
  34. #define B2_DERIVATIVE_THRESHOLD                 3000
  35. #define LEAKAGE_FACTOR_PROX                0.99
  36. #define LEAKAGE_FACTOR_BUTTON         0.9

  37. #define DELAY_1_MS        8000                        //delay for 1ms based on 8Mhz clock
  38. #define DELAY_1_SEC        8000000                        //delay for 1sec based on 8Mhz clock

  39. /********PROXIMITY PROCESSING VARIABLES************/
  40. uint32_t proxMeasSample = 0;
  41. uint32_t movingAvgProx = 0;
  42. uint32_t prevMovingAvgProx = 0;
  43. int32_t derivativeProx = 0;
  44. int32_t integralProx = 0;
  45. int32_t prevIntegralProx = 0;

  46. uint16_t integralProxHys = 0;

  47. /*********BUTTON1 PROCESSING VARIABLES***************/
  48. uint32_t b1MeasSample = 0;
  49. uint32_t movingAvgB1 = 0;
  50. uint32_t prevMovingAvgB1 = 0;
  51. int32_t derivativeB1 = 0;
  52. int32_t integralB1 = 0;
  53. int32_t prevIntegralB1 = 0;

  54. /*********BUTTON2 PROCESSING VARIABLES***************/
  55. uint32_t b2MeasSample = 0;
  56. uint32_t movingAvgB2 = 0;
  57. uint32_t prevMovingAvgB2 = 0;
  58. int32_t derivativeB2 = 0;
  59. int32_t integralB2 = 0;
  60. int32_t prevIntegralB2 = 0;

  61. /*******OTHER VARIABLES********/
  62. bool flagINTB = false;
  63. bool initCal = true;
  64. bool proxOn = false;

  65. /*****FUNCTION DECLARATIONS*****/
  66. void initMovingAvgVars(void);

  67. //*****************************************************************************
  68. // Interrupt Service Routines
  69. //*****************************************************************************
  70. void EXTI1_IRQHandler(void)
  71. {
  72.     //FDC2214 Data Ready bit INTB pin
  73.     flagINTB = true;
  74.     EXTI_ClearITPendingBit(EXTI_Line0);
  75.     NVIC_ClearPendingIRQ(EXTI0_IRQn);
  76. }

  77. /**
  78. * @brief  Main program.
  79. * @param  None
  80. * @retval None
  81. */

  82. int main(void)
  83. {

  84.     SystemInit();
  85.     CLOCK_Configuration();
  86.     RCC_Configuration();
  87.     NVIC_Configuration();
  88.     GPIO_Configuration();
  89.     USART_Configuration();
  90.     TIM_Configuration();
  91.     I2C_Configuration();  //Init I2C1
  92.     CAN_Configuration();
  93.     __enable_interrupt();
  94.    
  95. //   configureDebugLEDs();
  96. //    setAllDebugLEDs();
  97. //    GPIO_SetBits(GPIOA, GREEN_LED);
  98. //    delay(10);
  99. //    GPIO_SetBits(GPIO_LED, GPIO_Pin_7);
  100. //    delay(1000);
  101.     GPIO_SetBits(GPIO_LED, GPIO_Pin_7);
  102.     GPIO_SetBits(GPIO_LED, GPIO_Pin_6);
  103.     GPIO_ResetBits(GPIO_LED, GPIO_Pin_5);
  104.     GPIO_ResetBits(GPIO_LED, GPIO_Pin_4);
  105.         delay(1000);  
  106.    
  107. //Delays to get user hand out of proximity of sensor (if pressed reset SW)
  108. //    delay(1000);
  109. //    delay(1000);

  110.     FDC2214_init(); //Initialize and configure FDC2214
  111.     FDC2214_enableINTB();

  112.     //Initialize and stabilize moving average variables
  113.     initMovingAvgVars();
  114.     clearAllDebugLEDs();

  115.    
  116. while(1)
  117.     {

  118.         //Collect FDC measurements
  119.         if(flagINTB)
  120.         {
  121.             proxMeasSample = FDC2214_readMeasProxSensor();
  122.             b1MeasSample = FDC2214_readMeasButton1();
  123.             b2MeasSample = FDC2214_readMeasButton2();
  124.             flagINTB = false;      

  125.             //Process Data using Derivative/Integration Algorithm
  126.             //Moving Average using IIR filter of 8 samples
  127.             prevMovingAvgProx = movingAvgProx;
  128.             prevMovingAvgB1 = movingAvgB1;
  129.             prevMovingAvgB2 = movingAvgB2;
  130.                         movingAvgProx = ((movingAvgProx << 2) - movingAvgProx + proxMeasSample) >> 2;
  131.                         movingAvgB1 = ((movingAvgB1 << 2) - movingAvgB1 + b1MeasSample) >> 2;
  132.                         movingAvgB2 = ((movingAvgB2 << 2) - movingAvgB2 + b2MeasSample) >> 2;

  133.                         derivativeProx = movingAvgProx - prevMovingAvgProx;
  134.                         derivativeB1 = movingAvgB1 - prevMovingAvgB1;
  135.                         derivativeB2 = movingAvgB2 - prevMovingAvgB2;

  136.                         /******************************************/
  137.                         /**************CH0 = Proximity ************/
  138.                         /******************************************/
  139.                         if((abs(derivativeProx) > PROX_DERIVATIVE_THRESHOLD))
  140.                         {
  141.                                 integralProx = prevIntegralProx + derivativeProx;
  142.                         }
  143.                         else
  144.                         {
  145.                                 integralProx = prevIntegralProx;
  146.                         }

  147.                         if(proxOn)
  148.                                 integralProxHys = PROX_INTEGRAL_THRESHOLD / PROX_INTEGRAL_HYS;
  149.                         else
  150.                                 integralProxHys = PROX_INTEGRAL_THRESHOLD * PROX_INTEGRAL_HYS;


  151.                         if(integralProxHys <= -(integralProx))
  152.                         {
  153.                                 //Object detected for Proximity Sensor
  154.                                 prevIntegralProx = integralProx;
  155.                                 setProxLED();
  156.                                 proxOn = true;
  157.                         }
  158.                         else
  159.                         {
  160.                                 //Object not detected
  161.                                 prevIntegralProx = integralProx * LEAKAGE_FACTOR_PROX;
  162.                                 clearProxLED();
  163.                                 proxOn = false;
  164.                         }

  165.                         /******************************************/
  166.                         /*****CH1 = Cap touch Button1******/
  167.                         /******************************************/
  168.                         if(abs(derivativeB1) > B1_DERIVATIVE_THRESHOLD)
  169.                         {
  170.                                 integralB1 = prevIntegralB1 + derivativeB1;
  171.                                 // Set integral cap for B1
  172.                                 if (-integralB1 > B1_INTEGRAL_CAP)                //Cap integral for more responsiveness
  173.                                 {
  174.                                         integralB1 = -(B1_INTEGRAL_CAP);
  175.                                 }
  176.                         }
  177.                         else
  178.                         {
  179.                                 integralB1 = prevIntegralB1;
  180.                                 // Set integral cap for B2
  181.                                 if (-integralB1 > B1_INTEGRAL_CAP)                //Cap integral for more responsiveness
  182.                                 {
  183.                                         integralB1 = -(B1_INTEGRAL_CAP);
  184.                                 }
  185.                         }

  186.                         if(B1_INTEGRAL_THRESHOLD <= -(integralB1))
  187.                         {
  188.                                 //Object detected
  189.                                 prevIntegralB1 = integralB1;
  190.                                 setButton1LED();
  191.                         }
  192.                         else
  193.                         {
  194.                                 //Object not detected
  195.                                 prevIntegralB1 = integralB1 * LEAKAGE_FACTOR_BUTTON;
  196.                                 clearButton1LED();
  197.                         }

  198.                         /******************************************/
  199.                         /*****CH2 = Cap touch Button2******/
  200.                         /******************************************/
  201.                         if(abs(derivativeB2) > B2_DERIVATIVE_THRESHOLD)
  202.                         {
  203.                                 integralB2 = prevIntegralB2 + derivativeB2;
  204.                                 // Set integral cap for B2
  205.                                 if (-integralB2 > B2_INTEGRAL_CAP)                //Cap integral for more responsiveness
  206.                                 {
  207.                                         integralB2 = -(B2_INTEGRAL_CAP);
  208.                                 }
  209.                         }
  210.                         else
  211.                         {
  212.                                 integralB2 = prevIntegralB2;
  213.                                 // Set integral cap for B2
  214.                                 if (-integralB2 > B2_INTEGRAL_CAP)                //Cap integral for more responsiveness
  215.                                 {
  216.                                         integralB2 = -(B2_INTEGRAL_CAP);
  217.                                 }
  218.                         }

  219.                         if(B2_INTEGRAL_THRESHOLD <= -(integralB2))
  220.                         {
  221.                                 //Object detected
  222.                                 prevIntegralB2 = integralB2;
  223.                                 setButton2LED();
  224.                         }
  225.                         else
  226.                         {
  227.                                 //Object not detected
  228.                                 prevIntegralB2 = integralB2 * LEAKAGE_FACTOR_BUTTON;
  229.                                 clearButton2LED();
  230.                         }

  231. //                        debugUART_4(movingAvgProx, proxMeasSample, derivativeProx, integralProx);                //UART to debug for variables

  232.             //Clear DRDY bit by reading STATUS REGISTER
  233.                         FDC2214_clearDRDY();
  234.         }
  235.     }
  236. }


  237. //*****************************************************************************
  238. ……………………

  239. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
STM32-FDC_FINAL.rar (72.53 KB, 下載次數: 55)
STM32F1-FDC2214 - manual.7z (1.34 MB, 下載次數: 72)




回復

使用道具 舉報

ID:195464 發表于 2019-7-29 10:56 | 顯示全部樓層
多謝樓主分享,研究一下
回復

使用道具 舉報

ID:746619 發表于 2020-5-8 09:48 | 顯示全部樓層
請問沒有完整的PCB圖嗎
回復

使用道具 舉報

ID:748161 發表于 2020-5-10 10:14 | 顯示全部樓層
多謝分享
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 成人在线观看网址 | 国产精品国产a级 | 在线视频日韩精品 | 成人夜晚看av | 欧美性一区二区三区 | 青青久久av北条麻妃海外网 | 亚洲国产电影 | 欧美日韩国产精品激情在线播放 | 久久久成人免费一区二区 | 天堂中文资源在线 | 国产一区二区三区免费观看视频 | 成人国产一区二区三区精品麻豆 | 久久夜视频 | 国产精品日产欧美久久久久 | 中文字幕成人 | 国产清纯白嫩初高生在线播放视频 | 日韩欧美电影在线 | 福利视频亚洲 | 亚洲国产精品日本 | 国产色婷婷久久99精品91 | 亚洲精品美女视频 | 亚洲精品乱码 | 精品国产高清一区二区三区 | 久久久久久国产精品 | 国产毛片av| 精品免费视频一区二区 | 欧美日韩三级在线观看 | 国产99免费视频 | 免费日韩av | 日韩不卡一区二区三区 | 亚洲一区二区三区在线播放 | 久久久黄色 | 中文字幕成人av | 国产美女在线观看 | 色吧色综合| 粉嫩国产精品一区二区在线观看 | 日韩中文电影 | 中文字幕一区在线 | 国产精品久久久久久久免费大片 | 成年人网站免费视频 | 国产精品波多野结衣 |