adc

Serial monitor showing unexpected input from Arduino Mega

↘锁芯ラ 提交于 2020-12-12 04:40:06
问题 I'm using an Arduino Mega to control a CS1237 ADC. I'm sending a signal to the clock pin and after each clock pulse, waiting 1ms and then reading the response, according to the datasheet I found (via https://github.com/SiBangkotan/CS1237-ADC-cpp-library). This seems to be working in some capacity, because when I do Serial.println() for each bit received, and for the resulting dataword, I get a 24 bit dataword that matches the 24 separate bits I got. However, when I take out the extra

How to fix error message “__builtin_avr_delay_cycles expects a compile time integer constant make”?

北城余情 提交于 2020-12-10 14:29:52
问题 My program isn't being compiled using a GCC AVR compiler. It's a small game on a microprocessor and an LCD screen. move_delay = 200; _delay_ms( move_delay ); It doesn't like that this _delay_ms is a variable, but it needs to be a variable because I can adjust the screen action through an ADC. Is there a way I can make it a constant but still usable with the ADC? 回答1: You could roll you own by looping around the minimal delay you need as often as necessary to get the other delays you need.

How to fix error message “__builtin_avr_delay_cycles expects a compile time integer constant make”?

别说谁变了你拦得住时间么 提交于 2020-12-10 14:28:49
问题 My program isn't being compiled using a GCC AVR compiler. It's a small game on a microprocessor and an LCD screen. move_delay = 200; _delay_ms( move_delay ); It doesn't like that this _delay_ms is a variable, but it needs to be a variable because I can adjust the screen action through an ADC. Is there a way I can make it a constant but still usable with the ADC? 回答1: You could roll you own by looping around the minimal delay you need as often as necessary to get the other delays you need.

How to fix error message “__builtin_avr_delay_cycles expects a compile time integer constant make”?

北战南征 提交于 2020-12-10 14:28:21
问题 My program isn't being compiled using a GCC AVR compiler. It's a small game on a microprocessor and an LCD screen. move_delay = 200; _delay_ms( move_delay ); It doesn't like that this _delay_ms is a variable, but it needs to be a variable because I can adjust the screen action through an ADC. Is there a way I can make it a constant but still usable with the ADC? 回答1: You could roll you own by looping around the minimal delay you need as often as necessary to get the other delays you need.

How to fix error message “__builtin_avr_delay_cycles expects a compile time integer constant make”?

怎甘沉沦 提交于 2020-12-10 14:26:54
问题 My program isn't being compiled using a GCC AVR compiler. It's a small game on a microprocessor and an LCD screen. move_delay = 200; _delay_ms( move_delay ); It doesn't like that this _delay_ms is a variable, but it needs to be a variable because I can adjust the screen action through an ADC. Is there a way I can make it a constant but still usable with the ADC? 回答1: You could roll you own by looping around the minimal delay you need as often as necessary to get the other delays you need.

RMS calculation DC offset

﹥>﹥吖頭↗ 提交于 2020-05-17 08:49:19
问题 I need to implement an RMS calculations of sine wave in MCU (microcontroller, resource constrained). MCU lacks FPU (floating point unit), so I would prefer to stay in integer realm. Captures are discrete via 10 bit ADC. Looking for a solution, I've found this great solution here by Edgar Bonet: https://stackoverflow.com/a/28812301/8264292 Seems like it completely suits my needs. But I have some questions. Input are mains 230 VAC, 50 Hz. It's transformed & offset by hardware means to become 0

STM32 ADC转换时间

旧巷老猫 提交于 2020-03-12 14:54:24
STM32F103XX的ADC的采样时钟最快14MHz,最快采样率为1MHz。 ADC时钟: 这个ADC时钟是从哪来的呢。我们看下面这个STM32的时钟结构图: 我们大多使用STM32的最快PCLK2系统时钟72MHz。 ADCCLK的时钟由72MHz的6分频能瞒住14MHz以下的要求 为12MHz。 RCC_ADCCLKConfig(RCC_PCLK2_Div6); //72M/6=12,ADC最大时间不能超过14M ADC转换时间: 有如下公式: TCONV = 采样时间+ 12.5 个周期 其中12.5个周期是采集12位AD时间是固定的,另外一个采样时间可以取下面几个参数由SMPx[2:0]寄存器控制,每个通道可以单独配置。    000:1.5周期 100:41.5周期 001:7.5周期 101:55.5周期 010:13.5周期 110:71.5周期 011:28.5周期 111:239.5周期 当我们选择1.5周期时。转换时间 = 1.5+12.5 = 14周期。 当时钟配置为12MHz时 转换时间 = 14/12 = 1.167us. 其中有人就有疑问 为什么系统时钟72MHz 竟然达不到手册上说的1MHz- 1us的采样 。 其实我们要了解,真正决定ADC转换速度的不是系统时钟72MHz 而是不超过14MHz的 ADCCLK。 当我们配置系统时钟为72MHz的时候

STM32多通道ADC操作

删除回忆录丶 提交于 2020-03-12 14:45:03
转载自: http://www.cnblogs.com/nixianmin/p/3190531.html 今天尝试了下STM32的ADC采样,并利用DMA实现采样数据的直接搬运存储,这样就不用CPU去参与操作了。   找了不少例子参考,ADC和DMA的设置了解了个大概,并直接利用开发板来做一些实验来验证相关的操作,保证自己对各部分设置的理解。   我这里用了3路的ADC通道,1路外部变阻器输入,另外两路是内部的温度采样和Vrefint,这样就能组成连续的采样,来测试多通道ADC自动扫描了,ADC分规则转换和注入转换,其实规则转换就是按照既定的设定来顺序转换,而注入转换就是可以在这顺序队列中插队一样,能够提前转换了。   初始化设置: 1 //PC0 FOR ANAGLE SAMPLE 2 static void Protect_ClkInit(void) 3 { 4 RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1|RCC_APB2Periph_GPIOC,ENABLE); 5 RCC_ADCCLKConfig(RCC_PCLK2_Div6); 6 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); 7 } 8 9 static void Protect_GPIOInit(void) 10 {

stm32之ADC

不打扰是莪最后的温柔 提交于 2020-03-12 14:11:56
  将模拟量转换为数字量的过程称为模式(A/D)转换,完成这一转换的期间成为模数转换器(简称ADC);将数字量转换为模拟量的过程为数模(D/A)转换,完成这一转换的器件称为数模转换器(简称DAC). 模拟信号的采集与处理:   数据采集系统由模拟信号采集、A/D转换、数字信号处理三大部分组成: A/D转换的原理:   A/D转换中通常要完成采样保持和量化编码两方面。所以AD转换是需要转换时间的,一般AD转换的时间在uS级别;(量化编码所需要的时间决定采样保存的时间),如下图: 将采样后得到的样点幅值转换为数字量即为量化,编码的过程。量化编码过程是模/数转换的核心。所谓量化编码,就是以一定的量化单位,把数值上连续的模拟量而时间上的离散的模拟信号通过量化装置转变为树枝上离散的阶跃两的过程。常见的量化编码技术:计数式、双积分转换,逐次逼近式转换,并联式转换; AD转换器的主要参数:   1、分辨率  2、相对精度   3、转换速度; 有16个多路通道。可以把转换分成两组:规则的和注入的。在任意多个通道上以任意顺序进行的一系列转换构成成组转换。例如,可以如下顺序完成转换:通道3、通道8、通道2、通道2、通道0、通道2、通道2、通道15。 􀁺 规则组由多达16个转换组成。规则通道和它们的转换顺序在ADC_SQRx寄存器中选择。规则组中转换的总数写入ADC_SQR1寄存器的L[3:0]位中。

stm32 嵌入式开发 用标准库进行 ADC 实验总结

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-09 10:00:04
------------恢复内容开始------------ 硬件原理图 ,滑动电位器与芯片PC3引脚连接 根据开发板可知: STM32F429IGT6 有 3 个 ADC ,每个 ADC 有 12 位、 10 位、 8 位和 6 位可选,每个 ADC 有 16 个外部通道。         每个ADC 同时还有3个内部通道:通道16/17/18         工作模式有3种: 独立模式、双重模式和三重模式 。 转换顺序可分为:规则序列,注入序列。如下图所示: 规则序列寄存器设置根据表由上到下选择通道进行配置 注入序列寄存器JSQR转换顺序为JSQR [X] [4:0],                   X=4-JL,JL为需要转换的通道 触发源可选择:ADC2_CR2->ADON        外部事件触发:内部定时器、外部IO (EXTSEL[2:0] JEXTSEL[2:0]控制 ) 时间设置: ADC 的输入时钟ADC_CLK由PCLK2经过分频产生36MH最大z频率 采样时间:每个通道可以设置不同的采样频率,最小的采样时间是3个周期1/ADC_CLK     ADC总转换时间= 采样时间+12个时钟周期 数据寄存器:ADC_DR 1个32位寄存器,最低16位有效。独立模式时使用,可以开启DMA模式       ADC_JDRX 4个32位寄存器,低16位有效