示波器時基計算,采樣率,采樣點數,降采樣點數,塊與塊采集間隔


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-bit\8-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采集的實際樣品個數
            }
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM