• 示波器时基计算,采样率,采样点数,降采样点数,块与块采集间隔


    1、关于示波器时间计算的分析

    • 125MS /s采样率,理论1S采集125M个点
    • 125/50 = 2.5MS采集工频的波形一个周期20ms,即采集一个工频完整波形返回2.5M个点
    • 降采样系数(假设500),则最大或最小值的缓存数组长度 = [5000]
    • 块模式一次采集2.5M个数返回5000个数,开始下一次块采集
    • 块模式采集样本的数量是由参数(在触发事件之后返回的样本数 = 2.5M)决定的

    由此过程设置了示波器采集的样本总数,返回的样本数,以及在工频下最大采样率采集一个周期返回的最大样本个数

     2、时基计算

    •         //        This function calculates the sampling rate and maximum number of samples for a
              //given timebase under the specified conditions.The result will depend on the number of
              //channels enabled by the last call to ps5000aSetChannel.
              //This function is provided for use with programming languages that do not support the
              //float data type.The value returned in the timeIntervalNanoseconds argument is
              //restricted to integers.If your programming language supports the float type, then
              //we recommend that you use ps5000aGetTimebase2 instead.
              //To use ps5000aGetTimebase or ps5000aGetTimebase2, first estimate the
              //timebase number that you require using the information in the timebase guide.Next,
              //call one of these functions with the timebase that you have just chosen and verify that
              //the timeIntervalNanoseconds argument that the function returns is the value that
              //you require.You may need to iterate this process until you obtain the time interval
              //that you need.

     

     

    在公共类CSettingPico里面定义变量

     1      /// <summary>
     2         /// 典型值50Hz
     3         /// </summary>
     4         internal float fPeriodOfSignal = 50;
     5         
     6         /// <summary>
     7         /// 15-bit8-bit:
     8         ///   Range : 3 ~ 2^32 - 1
     9         ///   Sample interval formula: (timebase - 2)/125,000,000
    10         ///   Sample interval examples:
    11         ///             3 => 8ns
    12         ///             4 => 16ns
    13         ///             5 => 24ns
    14         ///             ...
    15         ///             2^32 - 1 => ~34.36s
    16         /// </summary>
    17         internal uint nTimeBase = 0;

    在公共类CSettingPico里定义方法 SampRateToTimeBase()

     /// <summary>
            /// 通过参数获取 TimeBase值
            /// </summary>
            /// <param name="FACBASE">每秒最大采样数125M</param>
            /// <param name="Rate">设定每秒采样数≤125M (必须>0)</param>
            /// <param name="signalPeriod">信号周期,典型值50Hz</param>
            internal void SampRateToTimeBase(int Rate, float signalPeriod, ref int buffLen)
            {
                const int FACBASE = 125000000;
                
                if (Rate == 0 || signalPeriod == 0) return;
    
                //获取采样时间长 ns, 1,000,000,000ns = 1s
                //int timeLen = (int)(1000000000 / signalPeriod);
    
                //获取采样间隔 Rate = 每秒采集点数
                //eg. 8ns : Rate = 125,000,000, TimeBase = 3
                nTimeBase = (uint)(FACBASE / Rate) + 2;
                //1S采集(Rate = 125M)个点数,1个周期采集2.5M个样本250W,上传到电脑2500000/downSampleRatio(1000) = 2500个数据
                buffLen = (int)(Rate / signalPeriod); 
            }

    在公共类CSettingPico里定义公开方法 

    调用了上一步定义的方法,计算得出了数组的长度

           /// <summary>
            /// 得到存放最大值最小值数组的长度
            /// </summary>
            internal void InitSettings()
            {
                SampRateToTimeBase(this.nSampRate, this.fPeriodOfSignal, ref this.nBufferLength);
                if (this.nBufferLength > 0)
                {
                    this.nBufferMax = new short[this.nBufferLength / this.downSampleRatio];
                    this.nBufferMin = new short[this.nBufferLength / this.downSampleRatio];
                    this.noOfPostTriggerSamples = this.nBufferLength; //在触发事件之后返回的样品个数,注意不是降采样后返回的,而是pico采集的实际样品个数
                }
            }
  • 相关阅读:
    《Rubu基础教程第五版》第一章笔记
    《Linux Command Line and Shell Scripting Bible》Part 14 处理用户输入
    Phpstorm-Xdebug配置
    Phpstorm-svn配置
    Phpstorm-sftp配置
    3前端案例-遮罩
    2前端案例-选项卡样式
    1前端案例-tag标签+随机位置
    Phpstorm-php在线手册配置
    mysql语句总结
  • 原文地址:https://www.cnblogs.com/12xiaole/p/7474704.html
Copyright © 2020-2023  润新知