adc

线性差值算法

假如想象 提交于 2020-01-07 23:20:37
点斜式: #include<stdio.h> #define N 10 float w = 10.0; float w0 = 0.0; float wn = 100.0; int adc[N+1] = {86,376,687,1021,1379,1760,2164,2592,3043,3515,4008}; float line(int x) { int i; if(x<adc[0]) return(w0); if(x>=adc[N]) return(wn); for(i=0;i<N;i++) if(x<adc[i+1]) break; return (w*i + (w*(x-adc[i])/(adc[i+1]-adc[i]))); } main() { int x; float y; while(1){ printf("\n输入A/D转换结果"); scanf("%d",&x); if(x==0) break; y = line(x); printf("\n对应温度为:%2.2f度",y); } } 来源: https://www.cnblogs.com/wy9264/p/12164030.html

How to quit the program in while loop using push-button in PyQt

浪子不回头ぞ 提交于 2019-12-31 00:46:51
问题 I have the following code which will start after clicking the 'Start' button in PyQt: def Start(self): import time import os import RPi.GPIO as GPIO import datetime GPIO.setmode(GPIO.BCM) DEBUG = 1 os.system('clear') # SPI port on GPIO SPICLK = 18 SPIMISO = 23 SPICS = 25 # set up the SPI interface pins GPIO.setup(SPIMISO, GPIO.IN) GPIO.setup(SPICLK, GPIO.OUT) GPIO.setup(SPICS, GPIO.OUT) GPIO.output(SPICS, True) GPIO.output(SPICS, False) # bring CS low while True: adcout = 0 read_adc = 0 #s

ADC应用

允我心安 提交于 2019-12-30 23:43:18
数模转换( ADC)的应用笔记 智能时代,数字信号已体现在我们生活的方方面面, A/D,D/A是重要的基础。智能手机触摸信号需要转换为数字信号才能分辨触摸位置、数字去抖;打电话或者麦克风需要将模拟声信号转换为数字信号以便存储回放、语音识别;移动通信到 4G时代,速率已经达到了 300Mbps,手机和基站之间的通信是模拟电磁信号,同样需要高性能的 ADC将其转化为数字信号,才能变成各位看到的电影、微博(当然没这么简单)。上述三个例子是典型的三种应用场景,对应 ADC的不同指标。其中速度(采样率)和精度( bit位)是选取 ADC的基础指标。各种监测可能需要实时性不高,能转换就行了;大部分医疗电子可能要求精度高,动态高,能分辨大信号下隐藏的小信号,同时速度较快;对于移动通信,您可能要求速度快,同时信号好,那对速度和精度就都有要求了,速度可能几百 Msps,精度可能 12、 14位;更高大上的,针对卫星通讯、软件无线电( SDR),带宽可达数 GHz,同时灵敏度要求更高,这种 ADC就是核心科技了,只有为数不多的几家美国厂商掌握。 关键词: ADC SDR 抗混叠滤波器无线通讯 高精度采样 本文主要介绍 ADC的模拟前端匹配技术,并分享笔者的几个设计作业,随着认识的不断深入,也会不断更新。关于 ADC的互连、中频方案选择等在系列文档中细说。 ADC的前端匹配其实是抗混叠滤波器( anti

How to obtain the highest sample rate possible in Raspbery Pi using a ADC?

亡梦爱人 提交于 2019-12-24 01:13:55
问题 I am working in a project using Raspberry Pi 3 B where I get data from a IR sensor(Sharp GP2Y0A21YK0F) through a ADC MPC3008 and display it in real-time using PyQtgraph library. The datasheet of the ADC says that at 5.0V, the sampling rate is 200khz. However I am only getting about 30 samples per second. Is it possible to achieve 200khz using Raspberry pi? If yes, what should I study or implement in order to obtain it? If not, what should I do to obtain the highest sample rate possible and

杰理AC6926X-多通道ADC设置

我与影子孤独终老i 提交于 2019-12-18 21:28:55
定义在adc_api.h 系统定义adc扫描的处理周期,2ms一次。 # if !ADKEY_SD_MULT_EN LOOP_DETECT_REGISTER ( adc_scan_detect ) = { . time = 1 , . fun = adc_scan , } ; # endif 每次扫描一个通道,总共5个通道,系统默认第一个通道为AD按键通道,在下面数组变量中体现 void adc_scan ( ) { static u8 channel = 0 ; u8 next_channel ; next_channel = channel + 1 ; if ( next_channel == R_MAX_AD_CHANNEL ) { next_channel = 0 ; } /* 这些是无关紧要的代码块 #if ADKEY_SD_MULT_EN if (next_channel == R_AD_CH_KEY) { if (adkey_sd_mult_sd_suspend() == true) { key_ad_info.key_init(); adc_value[channel++] = adc_res_api(ad_table[next_channel]); if (channel == R_MAX_AD_CHANNEL) { channel = 0; } next

ADC conversion triggered by 1ms timer not working, STM32F4

假装没事ソ 提交于 2019-12-13 18:07:00
问题 Im using STM32F429 board and my ultimate goal is to get ADC conversion(set to deliver 2.7Ksps or 2.7 samples every 1ms) using TIM8 trigger, collect 1000 samples in buffer and do DMA transfer every second. I managed to get Timer running, but for some reason ADC conversion is not triggered. Without timer ADC is running well and DMA working (just not every 1ms, but faster). APB2 Timers clock is 168Mhz. APB2 Peripherals clock is 84Mhz. TIM8 init function: void MX_TIM8_Init(void) { TIM

How to read & accumulate sensor values at high frequency, without constantly writing to disk (RPi 2 b+, MCP3304, Python)

六眼飞鱼酱① 提交于 2019-12-12 08:54:56
问题 I am attempting to use a Raspberry Pi 2 Model B+ to read analog data on IR intensity from a photodiode via an MCP3304 (5v VDD) at a rate of ~ 10kHz three times in a row (0.1 ms between readings, or a rate of 10 ksps) once every second based on an external stimulus, average those values, then write them to a text file along with the current datetime. The photodiode is simply reading out data to an amplifier, which then feeds into the MCP3304, which, via SPI, feeds data into the RPi. (In

How to change my wxpython program that read and display rain sensor data from mcp3008 to software spi?

淺唱寂寞╮ 提交于 2019-12-12 06:54:02
问题 I have a completed wxpython code that can read data from rain sensor and convert it from analogue to digital with mcp3008. The problem is the current raspberry pi that I use, already has a 20x4 lcd display that uses pin 24 or GPIO 8 which I need for my rain sensor program. I have read from https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008#software-spi on how to change my spi connection to software spi. Here is my mcp3008 pinout to raspberry pi without lcd display:

MSP430F5438 SD card using an SPI interface

僤鯓⒐⒋嵵緔 提交于 2019-12-11 12:05:59
问题 I want to connect an SD card using the SPI interface of MSP430F5438. The hardware part is correct in my design, however I could not send any data to the SD card. The source code I use is from Secure Digital Card Interface for the MSP430 . For debugging, how could I send data to the SD card? The data should be received from the ADC12MEM registers and just need to be written in the SD card. From this source code above, there is no process, when I debug and I could not send any user input to the

What is missing to make stm32 ADC DMA work? Transfer Compete does not occur

我是研究僧i 提交于 2019-12-11 01:14:14
问题 I am using a stm32f3 discovery board and the HAL from CubeMX. I am trying to use 2 ADC channels at ADC4. I configured DMA in circular mode. Befor the main loop in main, I call: HAL_ADC_Start_DMA(&hadc4, DMA_adc4_buffer, 16); I implemented the functions HAL_ADC_ConvHalfCpltCallback and HAL_ADC_ConvCpltCallback . Now the strange part: HAL_ADC_ConvHalfCpltCallback is called regularly, HAL_ADC_ConvCpltCallback is NOT. It tells me, that the ADC with DMA transfer is running fine. But why is