0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

如何制作一个简易的Sigma Delta ADC?

电子森林 来源:电子森林 作者:电子森林 2021-04-01 10:27 次阅读

本文为备战电赛的案例之一,涉及到的知识技能:

FPGA的使用

ADC的原理及构成

PWM的产生

比较器的应用

数字滤波器的使用

使用的平台:

多数FPGA芯片上没有ADC的功能,而一些应用则需要用到ADC对一些模拟信号,比如直流电压等进行量化,有没有特别简单、低成本的实现方法呢?

在要求转换速率不高的情况下,完全可以借助一颗高速比较器(成本只有几毛钱)来实现对模拟信号的量化,Lattice的官网上一篇文章就介绍了如何制作一个简易的Sigma Delta ADC,如果FPGA能够提供LVDS的接口,连外部的高速比较器都可以省掉。由于我们的小脚丫FPGA核心模块在设计的时候没有考虑到LVDS的应用场景,所以还是需要搭配一个高速的比较器来实现Lattice官网上推荐的简易Sigma Delta ADC的功能。

让小脚丫FPGA通过锁相环PLL运行于120MHz的主时钟(还可以更高,提速到240MHz、360MHz都应该没有问题),测试1KHz以内的模拟信号是没有问题的。

Lattice的官网上就可以下载到简易Sigma Delta ADC的Verilog源代码,可以非常方便地用在其它品牌、其它系列的FPGA上。

下面的截图就是采用120MHz的主时钟实现的对1KHz模拟信号的采样,并通过DDS/DAC输出,口袋仪器M2000采集并显示的模拟信号波形。

b31525ca-9245-11eb-8b86-12bb97331649.png

M2000口袋仪器显示的1KHz的波形

工作原理

详细的工作原理介绍可以参考项目https://www.eetree.cn/project/detail/255 及项目页面中的参考资料,在这里以几幅图片来示例一下。

b32101f6-9245-11eb-8b86-12bb97331649.png

简易Sigma Delta ADC的工作原理

b3503caa-9245-11eb-8b86-12bb97331649.png

直接连接 - 被测模拟信号的幅度范围为0-3.3V

b35b174c-9245-11eb-8b86-12bb97331649.png

通过电阻分压网络输入,并在比较器+端提供参考电压,则被采集模拟信号的电压变化范围可以扩展

b36482a0-9245-11eb-8b86-12bb97331649.png

简易Sigma Delta ADC的性能与逻辑电路的工作频率

b36d37f6-9245-11eb-8b86-12bb97331649.png

在不同的FPGA平台上消耗的逻辑资源

以下就是我们的电赛综合训练板上简易Sigma Delta ADC部分的电路连接

b379f7e8-9245-11eb-8b86-12bb97331649.png

核心代码:

顶层调用代码:

wire [7:0] sd_adc_out; // sigma delta adc data output

wire sample_rdy; // flag for adc conversion

ADC_top my_adc(.clk_in(clk_hs),.rstn(1‘b1),.digital_out(sd_adc_out), .analog_cmp(comp_in),.analog_out(ad_pwm),.sample_rdy(sample_rdy));

assign dac_data = sd_adc_out;assign dac_clk = clk_hs; //120MHz generated by PLL

Sigma Delta ADC顶层程序

//*********************************************************************//// ADC Top Level Module////*********************************************************************

module ADC_top ( clk_in, rstn, digital_out, analog_cmp, analog_out, sample_rdy);

parameter ADC_WIDTH = 8, // ADC Convertor Bit PrecisionACCUM_BITS = 10, // 2^ACCUM_BITS is decimation rate of accumulatorLPF_DEPTH_BITS = 3, // 2^LPF_DEPTH_BITS is decimation rate of averagerINPUT_TOPOLOGY = 1; // 0: DIRECT: Analog input directly connected to + input of comparitor // 1: NETWORK:Analog input connected through R divider to - input of comp.

//input portsinput clk_in; // 62.5Mhz on Control Demo boardinput rstn; input analog_cmp; // from LVDS buffer or external comparitor

//output portsoutput analog_out; // feedback to RC networkoutput sample_rdy;output [7:0] digital_out; // connected to LED field on control demo bd.

//**********************************************************************//// Internal Wire & Reg Signals////**********************************************************************wire clk;wire analog_out_i;wire sample_rdy_i;wire [ADC_WIDTH-1:0] digital_out_i;wire [ADC_WIDTH-1:0] digital_out_abs;

assign clk = clk_in;

//***********************************************************************//// SSD ADC using onboard LVDS buffer or external comparitor////***********************************************************************sigmadelta_adc #( .ADC_WIDTH(ADC_WIDTH), .ACCUM_BITS(ACCUM_BITS), .LPF_DEPTH_BITS(LPF_DEPTH_BITS) )SSD_ADC( .clk(clk), .rstn(rstn), .analog_cmp(analog_cmp), .digital_out(digital_out_i), .analog_out(analog_out_i), .sample_rdy(sample_rdy_i) );

assign digital_out_abs = INPUT_TOPOLOGY ? ~digital_out_i : digital_out_i;

//***********************************************************************//// output assignments////***********************************************************************

assign digital_out = ~digital_out_abs; // invert bits for LED display assign analog_out = analog_out_i;assign sample_rdy = sample_rdy_i;

endmodule

Sigma Delta ADC主程序

//*********************************************************************//// SSD Top Level Module////*********************************************************************

module sigmadelta_adc ( clk, rstn, digital_out, analog_cmp, analog_out, sample_rdy);

parameter ADC_WIDTH = 8, // ADC Convertor Bit PrecisionACCUM_BITS = 10, // 2^ACCUM_BITS is decimation rate of accumulatorLPF_DEPTH_BITS = 3; // 2^LPF_DEPTH_BITS is decimation rate of averager

//input portsinput clk; // sample rate clockinput rstn; // async reset, asserted lowinput analog_cmp ; // input from LVDS buffer (comparitor)

//output portsoutput analog_out; // feedback to comparitor input RC circuitoutput sample_rdy; // digital_out is readyoutput [ADC_WIDTH-1:0] digital_out; // digital output word of ADC

//**********************************************************************//// Internal Wire & Reg Signals////**********************************************************************reg delta; // captured comparitor outputreg [ACCUM_BITS-1:0] sigma; // running accumulator valuereg [ADC_WIDTH-1:0] accum; // latched accumulator valuereg [ACCUM_BITS-1:0] counter; // decimation counter for accumulatorreg rollover; // decimation counter terminal countreg accum_rdy; // latched accumulator value ’ready‘

//***********************************************************************//// SSD ’Analog‘ Input - PWM//// External Comparator Generates High/Low Value////***********************************************************************

always @ (posedge clk)begin delta 《= analog_cmp; // capture comparitor outputend

assign analog_out = delta; // feedback to comparitor LPF

//***********************************************************************//// Accumulator Stage//// Adds PWM positive pulses over accumulator period////***********************************************************************

always @ (posedge clk or negedge rstn)begin if( ~rstn ) begin sigma 《= 0; accum 《= 0; accum_rdy 《= 0; end else begin if (rollover) begin // latch top ADC_WIDTH bits of sigma accumulator (drop LSBs) accum 《= sigma[ACCUM_BITS-1:ACCUM_BITS-ADC_WIDTH]; sigma 《= delta; // reset accumulator, prime with current delta value end else begin if (&sigma != 1’b1) // if not saturated sigma 《= sigma + delta; // accumulate end accum_rdy 《= rollover; // latch ‘rdy’ (to align with accum) endend

//***********************************************************************//// Box filter Average//// Acts as simple decimating Low-Pass Filter////***********************************************************************

box_ave #( .ADC_WIDTH(ADC_WIDTH), .LPF_DEPTH_BITS(LPF_DEPTH_BITS))box_ave ( .clk(clk), .rstn(rstn), .sample(accum_rdy), .raw_data_in(accum), .ave_data_out(digital_out), .data_out_valid(sample_rdy));

//************************************************************************//// Sample Control - Accumulator Timing// //************************************************************************

always @(posedge clk or negedge rstn)begin if( ~rstn ) begin counter 《= 0; rollover 《= 0; end else begin counter 《= counter + 1; // running count rollover 《= &counter; // assert ‘rollover’ when counter is all 1‘s endendendmodule

数字低通滤波器模块,做平滑滤波

//*********************************************************************//// ’Box‘ Average //// Standard Mean Average Calculation// Can be modeled as FIR Low-Pass Filter where // all coefficients are equal to ’1‘。////*********************************************************************

module box_ave ( clk, rstn, sample, raw_data_in, ave_data_out, data_out_valid);

parameter ADC_WIDTH = 8, // ADC Convertor Bit PrecisionLPF_DEPTH_BITS = 4; // 2^LPF_DEPTH_BITS is decimation rate of averager

//input portsinput clk; // sample rate clockinput rstn; // async reset, asserted lowinput sample; // raw_data_in is good on rising edge, input [ADC_WIDTH-1:0] raw_data_in; // raw_data input

//output portsoutput [ADC_WIDTH-1:0] ave_data_out; // ave data outputoutput data_out_valid; // ave_data_out is valid, single pulse

reg [ADC_WIDTH-1:0] ave_data_out; //**********************************************************************//// Internal Wire & Reg Signals////**********************************************************************reg [ADC_WIDTH+LPF_DEPTH_BITS-1:0] accum; // accumulatorreg [LPF_DEPTH_BITS-1:0] count; // decimation countreg [ADC_WIDTH-1:0] raw_data_d1; // pipeline register

reg sample_d1, sample_d2; // pipeline registersreg result_valid; // accumulator result ’valid‘wire accumulate; // sample rising edge detectedwire latch_result; // latch accumulator result

//***********************************************************************//// Rising Edge Detection and data alignment pipelines////***********************************************************************always @(posedge clk or negedge rstn)begin if( ~rstn ) begin sample_d1 《= 0; sample_d2 《= 0; raw_data_d1 《= 0; result_valid 《= 0; end else begin sample_d1 《= sample; // capture ’sample‘ input sample_d2 《= sample_d1; // delay for edge detection raw_data_d1 《= raw_data_in; // pipeline result_valid 《= latch_result; // pipeline for alignment with result endend

assign accumulate = sample_d1 && !sample_d2; // ’sample‘ rising_edge detectassign latch_result = accumulate && (count == 0); // latch accum. per decimation count

//***********************************************************************//// Accumulator Depth counter////***********************************************************************always @(posedge clk or negedge rstn)begin if( ~rstn ) begin count 《= 0; end else begin if (accumulate) count 《= count + 1; // incr. count per each sample endend

//***********************************************************************//// Accumulator////***********************************************************************always @(posedge clk or negedge rstn)begin if( ~rstn ) begin accum 《= 0; end else begin if (accumulate) if(count == 0) // reset accumulator accum 《= raw_data_d1; // prime with first value else accum 《= accum + raw_data_d1; // accumulate end end //***********************************************************************//// Latch Result//// ave = (summation of ’n‘ samples)/’n‘ is right shift when ’n‘ is power of two////***********************************************************************always @(posedge clk or negedge rstn)begin if( ~rstn ) begin ave_data_out 《= 0; end else if (latch_result) begin // at end of decimation period.。. ave_data_out 《= accum 》》 LPF_DEPTH_BITS; // 。.. save accumulator/n result endend

assign data_out_valid = result_valid; // output assignment

endmodule

原文标题:如何在FPGA上用一个比较器实现ADC的功能?

文章出处:【微信公众号:FPGA入门到精通】欢迎添加关注!文章转载请注明出处。

责任编辑:haq

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • FPGA
    +关注

    关注

    1602

    文章

    21320

    浏览量

    593178
  • adc
    adc
    +关注

    关注

    95

    文章

    5651

    浏览量

    539454

原文标题:如何在FPGA上用一个比较器实现ADC的功能?

文章出处:【微信号:xiaojiaoyafpga,微信公众号:电子森林】欢迎添加关注!文章转载请注明出处。

收藏 人收藏

    评论

    相关推荐

    RZ MPU Delta-sigma的工作原理 Delta-Sigma的应用简介

    目前隔离式Delta-Sigma模数转换器在伺服驱动的相电流检测中得到越来越广泛的应用。
    的头像 发表于 03-22 13:55 1126次阅读

    关于在PSoC 5LP上驱动Delta Sigma ADC的问题求解

    我想问些关于在 PSoC 5LP 上驱动 Delta Sigma ADC 的问题。 首先,简单介绍下我的用例:我想使用
    发表于 01-23 07:05

    请问sigma delta ADC的噪声如何分析?

    ADC的噪声有哪些,这些如何计算和分析? 我在ADI的资料里看到了很多关于ADC噪声的资料,但感觉都只讲了些关于ADC噪声的某个方面,没有找到系统
    发表于 12-07 07:49

    MAX11214: 24-Bit, 5mW, 140dB SNR, 32ksps Delta-Sigma ADC with Integrated PGA Data Sheet MAX11214: 24-Bit, 5mW, 140dB SNR, 32ksps Delta-Sigma

    电子发烧友网为你提供ADI(ADI)MAX11214: 24-Bit, 5mW, 140dB SNR, 32ksps Delta-Sigma ADC with Integrated PGA Data
    发表于 10-17 18:35
    MAX11214: 24-Bit, 5mW, 140dB SNR, 32ksps <b class='flag-5'>Delta-Sigma</b> <b class='flag-5'>ADC</b> with Integrated PGA Data Sheet MAX11214: 24-Bit, 5mW, 140dB SNR, 32ksps <b class='flag-5'>Delta-Sigma</b>

    MAX11208: 20-Bit, Single-Channel, Ultra-Low-Power, Delta-Sigma ADC with 2-Wire Serial Interface Data Sheet MAX11208: 20-Bit, Single-Channel,

    电子发烧友网为你提供ADI(ADI)MAX11208: 20-Bit, Single-Channel, Ultra-Low-Power, Delta-Sigma ADC with 2-Wire
    发表于 10-13 19:21
    MAX11208: 20-Bit, Single-Channel, Ultra-Low-Power, <b class='flag-5'>Delta-Sigma</b> <b class='flag-5'>ADC</b> with 2-Wire Serial Interface Data Sheet MAX11208: 20-Bit, Single-Channel,

    ADFS7124-4: 4-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA and Reference Data Sheet ADFS7124-4: 4-Channel, Low Noise, Low

    电子发烧友网为你提供ADI(ADI)ADFS7124-4: 4-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA
    发表于 10-12 18:31
    ADFS7124-4: 4-Channel, Low Noise, Low Power, 24-Bit, <b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b> with PGA and Reference Data Sheet ADFS7124-4: 4-Channel, Low Noise, Low

    ADFS7124-8: 8-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA and Reference Data Sheet ADFS7124-8: 8-Channel, Low Noise, Low

    电子发烧友网为你提供ADI(ADI)ADFS7124-8: 8-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA
    发表于 10-12 18:30
    ADFS7124-8: 8-Channel, Low Noise, Low Power, 24-Bit, <b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b> with PGA and Reference Data Sheet ADFS7124-8: 8-Channel, Low Noise, Low

    AD4129-8:32 微A,超低功率,16-Bit Sigma-Delta ADC,综合PGA和FIFO数据表 ADI

    电子发烧友网为你提供ADI(ADI)AD4129-8:32 微A,超低功率,16-Bit Sigma-Delta ADC,综合PGA和FIFO数据表相关产品参数、数据手册,更有AD4129-8
    发表于 10-10 19:21
    AD4129-8:32 微A,超低功率,16-Bit <b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b>,综合PGA和FIFO数据表 ADI

    AD4131-8:32 微A,超低功率,16-Bit Sigma-Delta ADC,综合PGA数据表 ADI

    电子发烧友网为你提供ADI(ADI)AD4131-8:32 微A,超低功率,16-Bit Sigma-Delta ADC,综合PGA数据表相关产品参数、数据手册,更有AD4131-8
    发表于 10-10 19:18
    AD4131-8:32 微A,超低功率,16-Bit <b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b>,综合PGA数据表 ADI

    AD7124-8:8个通道、低噪音、低功率、24Bit、Sigma-Delta ADC,PGA和参考数据表 ADI

    电子发烧友网为你提供ADI(ADI)AD7124-8:8个通道、低噪音、低功率、24Bit、Sigma-Delta ADC,PGA和参考数据表相关产品参数、数据手册,更有AD7124-8:8个通道
    发表于 10-10 18:35
    AD7124-8:8个通道、低噪音、低功率、24Bit、<b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b>,PGA和参考数据表 ADI

    STM32F37x/38x SDADC(Sigma-Delta ADC)入门

    电子发烧友网站提供《STM32F37x/38x SDADC(Sigma-Delta ADC)入门.pdf》资料免费下载
    发表于 09-21 11:29 3次下载
    STM32F37x/38x SDADC(<b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b>)入门

    增量式Sigma-Delta ADC与传统结构的区别在哪?

    Sigma-Delta ADC设计中,应用于高精度窄带信号,例如生物医疗,仪表测量等领域的Sigma-Delta ADC通常被称为增量式(Incremental)
    的头像 发表于 07-03 16:54 1522次阅读
    增量式<b class='flag-5'>Sigma-Delta</b> <b class='flag-5'>ADC</b>与传统结构的区别在哪?

    深入理解sigma-delta调制技术

    分享第一个Topic,sigma-delta技术。
    的头像 发表于 06-02 15:28 3403次阅读
    深入理解<b class='flag-5'>sigma-delta</b>调制技术

    sigma_delta和PWM的区别是什么?

    调暗 LED。但后来我想 - 等下!... 这不是 PWM 的 sigma_delta 东西吗?这两者有什么区别?
    发表于 05-31 06:13

    delta-sigma调制过后的高频噪声是怎么去掉的?

    平均值等于输入(假如量化器的4输出的平均值等于输入),那么后端的DPWM(假如是计数器结构的)到底使用这4值中的哪一个?如果4都作为占空比信号的话那么对
    发表于 05-06 17:43