标题: 虚拟示波器制作资料 [打印本页]

作者: 伟民电子    时间: 2016-6-16 21:35
标题: 虚拟示波器制作资料


下位机原理图


部分程序:
  1. /*
  2. * Copyright (c) 2010 仪星电子
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.

  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. * GNU General Public License for more details.

  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  15. */

  16. /*
  17. * 著作权所有(C) 2010 仪星电子
  18. *
  19. * 本程序为自由软件;您可依据自由软件基金会所发表的GNU通用公共授权条款规定,
  20. * 就本程序再为发布与/或修改;无论您依据的是本授权的第二版或(您自行选择的)
  21. * 任一日后发行的版本。

  22. * 本程序是基于使用目的而加以发布,然而不负任何担保责任;亦无对适售性或特定
  23. * 目的适用性所为的默示性担保。详情请参照GNU通用公共授权。

  24. * 您应已收到附随于本程序的GNU通用公共授权的副本;如果没有,请写信至自由软件
  25. * 基金会:59 Temple Place - Suite 330, Boston, Ma 02111-1307, USA。

  26. * Email yixingdianzi@126.com
  27. * Email/MSN yixingdianzi@hotmail.com
  28. * QQ 648887464
  29. */

  30. /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
  31. * File Name          : main.c
  32. * Author             : MCD Application Team
  33. * Version            : V3.1.0
  34. * Date               : 10/30/2009
  35. * Description        : Virtual Com Port Demo main file
  36. ********************************************************************************
  37. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  38. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  39. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  40. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  41. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  42. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  43. *******************************************************************************/

  44. /* Includes ------------------------------------------------------------------*/
  45. //#include "stm32f10x.h"
  46. #include "stm32f10x_gpio.h"
  47. #include "usb_lib.h"
  48. #include "usb_desc.h"
  49. #include "usb_pwr.h"
  50. #include "qdmx_usb.h"
  51. #include "qdmx_adc.h"

  52. #define SEND 32

  53. /* Private typedef -----------------------------------------------------------*/
  54. /* Private define ------------------------------------------------------------*/
  55. /* Private macro -------------------------------------------------------------*/
  56. /* Private variables ---------------------------------------------------------*/
  57. /* Extern variables ----------------------------------------------------------*/
  58. extern __IO uint32_t count_in;
  59. extern uint8_t Controla_a;
  60. extern uint8_t Controla_b;

  61. /* Private function prototypes -----------------------------------------------*/
  62. /* Private functions ---------------------------------------------------------*/
  63. void Set_System(void);
  64. void Callback(uint8_t *p);
  65. void Delay(__IO uint32_t nCount);
  66. void GPIO_configure(void);                                       
  67. /*******************************************************************************
  68. * Function Name  : main.
  69. * Description    : Main routine.                                
  70. * Input          : None.
  71. * Output         : None.
  72. * Return         : None.
  73. *******************************************************************************/
  74. int main(void)
  75. {  
  76.         vu8 s;
  77.         /*设置系统时钟*/
  78.         Set_System();
  79.         
  80.         /*初始化USB模块*/  
  81.         Set_USBClock();
  82.         USB_Interrupts_Config();
  83.         USB_Init();
  84.         /*初始化AD模块*/
  85.         m_adc_clk_config();
  86.           m_adc_gpio_config();
  87.           m_adc_Interrupts_Config();
  88.           m_adc_init();

  89.         /*初始化GPIO引脚作为放大控制引脚*/
  90.         GPIO_configure();
  91.                                           
  92.           count_in=0;
  93.         /*默认初始值为放大1倍*/

  94.         GPIO_ResetBits(GPIOA,GPIO_Pin_0);
  95.         GPIO_ResetBits(GPIOA,GPIO_Pin_1);
  96.         GPIO_ResetBits(GPIOA,GPIO_Pin_2);

  97.         GPIO_ResetBits(GPIOB,GPIO_Pin_12);
  98.         GPIO_ResetBits(GPIOB,GPIO_Pin_13);
  99.         GPIO_ResetBits(GPIOB,GPIO_Pin_14);

  100.           while (1)
  101.           {                 
  102.           }
  103. }

  104. void GPIO_configure(void)
  105. {
  106.         GPIO_InitTypeDef GPIO_InitStructure;

  107.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);
  108.           RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE);
  109.         
  110.         RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);
  111.         RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE);               

  112.           GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14;
  113.           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  114.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  115.           GPIO_Init(GPIOB, &GPIO_InitStructure);

  116.         
  117.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
  118.           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  119.           GPIO_Init(GPIOA, &GPIO_InitStructure);
  120. }

  121. void Delay(__IO uint32_t nCount)
  122. {
  123.   for(; nCount != 0; nCount--);
  124. }


  125. void Callback(uint8_t *p)
  126. {
  127.         if (GetENDPOINT(ENDP1) & EP_DTOG_RX)
  128.         {
  129.                    FreeUserBuffer(ENDP1, EP_DBUF_IN);
  130.                    UserToPMABufferCopy((uint8_t*) p, ENDP1_TX1ADDR, SEND);
  131.                    SetEPDblBuf1Count(ENDP1,EP_DBUF_IN,SEND);
  132.         }
  133.         else
  134.         {
  135.                    FreeUserBuffer(ENDP1, EP_DBUF_IN);
  136.                    UserToPMABufferCopy((uint8_t*) p, ENDP1_TX0ADDR, SEND);
  137.                    SetEPDblBuf0Count(ENDP1,EP_DBUF_IN,SEND);
  138.         }
  139. }

  140. #ifdef USE_FULL_ASSERT
  141. /*******************************************************************************
  142. * Function Name  : assert_failed
  143. * Description    : Reports the name of the source file and the source line number
  144. *                  where the assert_param error has occurred.
  145. * Input          : - file: pointer to the source file name
  146. *                  - line: assert_param error line source number
  147. * Output         : None
  148. * Return         : None
  149. *******************************************************************************/
  150. void assert_failed(uint8_t* file, uint32_t line)
  151. {
  152.   /* User can add his own implementation to report the file name and line number,
  153.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  154.   /* Infinite loop */
  155.   while (1)
  156.   {}
  157. }
  158. #endif

  159. /*******************************************************************************
  160. * Function Name  : Set_System
  161. * Description    : Configures Main system clocks & power
  162. * Input          : None.
  163. * Return         : None.
  164. *******************************************************************************/
  165. void Set_System(void)
  166. {
  167.   ErrorStatus HSEStartUpStatus;
  168.   /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/   
  169.   /* RCC system reset(for debug purpose) */
  170.   RCC_DeInit();

  171.   /* Enable HSE */
  172.   RCC_HSEConfig(RCC_HSE_ON);

  173.   /* Wait till HSE is ready */
  174.   HSEStartUpStatus = RCC_WaitForHSEStartUp();

  175.   if (HSEStartUpStatus == SUCCESS)
  176.   {
  177.     /* Enable Prefetch Buffer */
  178.     FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

  179.     /* Flash 2 wait state */
  180.     FLASH_SetLatency(FLASH_Latency_2);

  181.     /* HCLK = SYSCLK */
  182.     RCC_HCLKConfig(RCC_SYSCLK_Div1);
  183.   
  184.     /* PCLK2 = HCLK */
  185.     RCC_PCLK2Config(RCC_HCLK_Div1);

  186.     /* PCLK1 = HCLK/2 */
  187.     RCC_PCLK1Config(RCC_HCLK_Div2);

  188. #ifdef STM32F10X_CL
  189.     /* Configure PLLs *********************************************************/
  190.     /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
  191.     RCC_PREDIV2Config(RCC_PREDIV2_Div5);
  192.     RCC_PLL2Config(RCC_PLL2Mul_8);

  193.     /* Enable PLL2 */
  194.     RCC_PLL2Cmd(ENABLE);

  195.     /* Wait till PLL2 is ready */
  196.     while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET)
  197.     {}

  198.     /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */
  199.     RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5);
  200.     RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9);
  201. #else
  202.     /* PLLCLK = 8MHz * 9 = 72 MHz */
  203.     RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
  204. #endif

  205.     /* Enable PLL */
  206.     RCC_PLLCmd(ENABLE);

  207.     /* Wait till PLL is ready */
  208.     while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
  209.     {
  210.     }

  211.     /* Select PLL as system clock source */
  212.     RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  213.     /* Wait till PLL is used as system clock source */
  214.     while(RCC_GetSYSCLKSource() != 0x08)
  215.     {
  216.     }
  217.   }
  218.   else
  219.   { /* If HSE fails to start-up, the application will have wrong clock configuration.
  220.        User can add here some code to deal with this error */   

  221.     /* Go to infinite loop */
  222.     while (1)
  223.     {
  224.     }
  225.   }
  226. }
  227. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
复制代码



元件清单:
Comment
Description
Designator
Quantity

Comment


1

104
Capacitor
C1,  C2, C3, C4, C5, C6, C7, C8, C9, C10, C14, C16, C20, C25, C26, C27, C28, C29,  C30, C31, C32, C33, C34, C35, C36, C37, C38, C39, C40, C41, C42, C45, C46,  C48
34
***
20pF
Capacitor
C12, C13
2
***
10uF
Polarized Capacitor  (Radial)
C19, C21, C22, C23
4
***
47pF
Capacitor
C43, C44
2
***
LED
发光二极管
D1
1
***
1N4148
Diode
D3,  D4, D5, D6, D7, D8, D9, D10, D11, D12
10
***
DC-DC
-5V DC 模块
DC-DC
1
***
探头
信号输入接口探头
IN1, IN2
2
***
JTAG
STM32芯片JTAG调试接口
J1
1
***
100uH
Inductor
L1, L3, L5
3
***
电源入口
电源接头
P1
1
***
10K
Resistor
R1,  R2, R3, R4, R5, R6, R7, R8, R12, R15, R17, R18
12
***
330
Resistor
R9
1
***
22
Resistor
R10, R13
2
***
2.2K
Resistor
R11
1
***
3.3K
Resistor
R14
1
***
1K5
Resistor
R16
1
***
0
Resistor
R19, R21
2
***
1k
Resistor
R20, R24, R27, R28,  R36, R37, R38, R40, R41
9
***
560K
Resistor
R23, R42
2
***
100k
Resistor
R25, R35, R39, R50
4
***
240K
Resistor
R26, R44
2
***
200K
Resistor
R29, R34, R47, R49
4
***
2M
Resistor
R30, R43
2
***
5M
Resistor
R31, R45
2
***
1M
Resistor
R32, R46
2
***
500k
Resistor
R33, R48
2
***
39
Resistor
R51, R52
2
***
按键
按键
RST1
1
***
STM32F103C8/STM32F103CB
STM32F103系列处理器
U1
1
***
TL431
基准芯片
U2
1
***
7805
5V电源芯片
U3
1
***
1117-3.3
3.3V电源芯片
U4
1
***
TL082
常用运放
U5, U6, U7
3
***
CD4051BC
8-Channel Analog  Multiplexer
U8, U10
2
***
TL084
常用运放
U9
1
***
USB_B口
USB-B口
USB1
1
***
8MHz
无源晶振
X1
1
***


[赠品]虚拟示波器开源板(绿油) 全套资料下载_PDF_C5075.7z (9.07 MB, 下载次数: 455)



作者: Lighty-Mi    时间: 2016-10-6 12:53
正需要呢  谢谢楼主  下来学习学习
作者: 邰夏留    时间: 2016-10-7 08:47
下载收藏下。好东西
作者: wpppmlah    时间: 2016-10-7 11:39
灰常不错,灰常感谢!
作者: gaozhaohong    时间: 2016-10-7 12:02
谢谢楼主,谢谢楼主
作者: rain_2015_long    时间: 2016-10-8 10:36
做个记号,这个一点要顶
作者: gkseoqhd    时间: 2016-11-11 21:28
我就是想知道CD4501是怎么工作的
作者: cuihaodianzi    时间: 2016-12-22 14:44
这板子看着好眼熟,好像嘉立创买元器件会送板子。但……貌似板子上的好多元器件又会缺货
作者: gl542400    时间: 2016-12-24 19:07
做个记号,这个一点要顶
作者: zhhufe    时间: 2017-1-17 22:14
正需要呢  谢谢楼主  下来学习学
作者: 作业本    时间: 2017-1-28 21:05
早就想做一个了开始整
作者: zezy371    时间: 2017-2-1 17:31
及时雨啊,正在寻找这个东西呢!
作者: jms209    时间: 2017-2-9 17:51

谢谢分享....
作者: qjzyx    时间: 2018-1-9 21:25
好资料!谢谢分享!
作者: nulijinbu    时间: 2018-2-22 13:01
很不错,顶一下
作者: liuzx66    时间: 2018-2-25 14:14
扣了三次黑币,也没有下载成
作者: cjx96872    时间: 2018-4-12 14:27
谢谢楼主  学习学习
作者: tianyu22    时间: 2020-2-26 10:15
正好要做一个波形显示的东西,看看他的上位机代码可不可以用。。。希望是c#
作者: tianyu22    时间: 2020-2-26 10:19
呃,原来没有上位机源码。。。被控制了。。。
作者: wanjian16888    时间: 2020-3-16 21:43
学习了那么久的单片机,有幸一见,不错。
作者: shiyb    时间: 2020-3-24 21:56
太崇拜了,收藏攒币
作者: xiaohuang2020    时间: 2020-4-11 15:11
感谢楼主
作者: QDMLIT    时间: 2020-4-17 16:51
非常感谢
作者: xugh1977    时间: 2021-4-15 11:39
不错,好东西,可以试着做一个!
作者: yygdzjs    时间: 2021-5-11 17:25
芯片 涨价. STM32Fxxx 难买 也贵,看能不能 用其它国内单片机代替.
有空制作一下.  谢谢老帖.
作者: 真的学不会51    时间: 2021-6-24 23:33
正好要用到,感谢楼主无私奉献
作者: zheng_wei339    时间: 2021-11-14 13:59
我往单片机内下载了程序,PC驱动也正确安装,但程序链接没有反应
作者: 王言之    时间: 2021-11-19 15:07
下载不成功,不知道是不是个别原因!
作者: zydl123    时间: 2021-11-23 12:58
正需要呢 谢谢楼主 下来学习
作者: zydl123    时间: 2021-11-25 12:11
资料不错,收下了,有成品买吗
作者: aide51    时间: 2022-12-14 10:24
这个很不错,可以做着玩啊玩
作者: 阳光璀璨    时间: 2023-4-14 20:40
这个很不错,可以做着玩啊玩
作者: yuanbangmiao    时间: 2023-4-18 10:28
这个真不错,好好学习一下
作者: zheng_wei339    时间: 2023-6-3 17:05
已经制作成功,可惜只能在XP系统使用
作者: lksbbs    时间: 2023-11-16 17:22
有成品么,项目太多,不想都折腾
作者: XDDZ1013    时间: 2024-1-5 18:16
下载收藏一下。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1