1. 程式人生 > 其它 >案例分享:Qt高頻fpga採集資料壓力位移速度加速度分析系統(通道配置、電壓轉換、取樣頻率、通道補償、定時採集、距離採集,匯出exce、自動XY軸、隱藏XY軸、隱藏顯示通道,檔案回放等等)

案例分享:Qt高頻fpga採集資料壓力位移速度加速度分析系統(通道配置、電壓轉換、取樣頻率、通道補償、定時採集、距離採集,匯出exce、自動XY軸、隱藏XY軸、隱藏顯示通道,檔案回放等等)

需求

  1.0-7通道壓力採集,採集頻率1~100Khz(1,10,20,30…1000Khz);
  2.0-7通道壓力,可設定補償值,測量範圍;
  3.編碼器0,1脈衝採集,計算位移,速度,加速度;
  4.所有通道可設定別名,隱藏/顯示狀態;
  5.支援定時採集,指定距離採集(以編碼器周長,解析度與脈衝計算);
  6.支援分組,可將通道0-7分為2組,並且可以分別採集和停止;
  7.對設定設定介面和主介面的所有相關配置引數進行儲存,並在下次啟動時恢復最後一次啟動的配置資料
  8.支援日誌系統,對相關操作和資料進行日誌輸出
  9.支援座標軸縮放;
  10.支援不同y座標進行加權操作,使其顯示在同一個圖中;
  11.使用udp重傳控制機制,保障傳輸大量資料時,資料傳輸速度快,穩定,可靠。
  12.支援需要的資料可列印;

相關部落格

  《案例分享:Qt高頻fpga採集資料壓力位移速度加速度分析系統(通道配置、電壓轉換、取樣頻率、通道補償、定時採集、距離採集,匯出exce、自動XY軸、隱藏XY軸、隱藏顯示通道,檔案回放等等)
  《案例分享:Qt多通道資料採集系統(通道配置、電壓轉換、取樣頻率、通道補償值、定時採集、匯出excel和圖表、自動XY軸、隱藏XY軸、實時隱藏顯示通道)
  《案例分享:Qt多段Y軸折線圖框架(雙Y軸段折線、支援拽拖、浮動遊標顯示X值各段Y值、支援大量實時顯示下位機資料)
  《案例分享:Qt多通道資料採集系統(通道配置、電壓轉換、取樣頻率、通道補償值、定時採集、匯出excel和圖表、自動XY軸、隱藏XY軸、實時隱藏顯示通道)


  《Qt開發筆記之QCustomPlot:QCustomPlot介紹、編譯與使用
  《Qt開發筆記之Qwt(一):Qwt介紹、編譯與Demo

體驗下載地址

  特別注意:釋出用的模擬資料方式,過程中的演示Demo,模擬資料方式與資料處理相關的功能不可用。
  CSDN(免積分):https://download.csdn.net/download/qq21497936/23361384
  QQ群:1047134658(點選“檔案”搜尋“highFreq”,群內與博文同步更新)

Demo演示

  
  

Demo v1.20.1

  

Demo v1.7.1(提供模擬採集演示版本)

  
  
  
  
  回放,可檢視之前採集的資料(回放之後,可匯出當前回放的資料到excel表)
  

  資料匯出為excel表,檢視資料:
  

相關標頭檔案原始碼

#ifndef HIGHFREQCOLLECTMAINWINDOW_H
#define HIGHFREQCOLLECTMAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
#include <QAbstractButton>
#include <QCheckBox>
#include <QFrame>
#include <QElapsedTimer>
#include <QTimer>

#define SIMULATION  (1)     // 是否模擬

namespace Ui {
class HighFreqCollectMainWindow;
}

class HighFreqCollectMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit HighFreqCollectMainWindow(QWidget *parent = 0);
    ~HighFreqCollectMainWindow();

protected:
    void loadCfg();
    void saveCfg();
    void updateEncodeStep();

protected:
    void initControls();
    void updateControls();
    void updateControlsPlayback();                                  // 更新控制元件回放控制元件
    void initCustomPlot();

protected slots:
    void slot_initControls();

protected slots:
    void slot_lineVisibleButtonClicked(bool checked);               // 是否顯示通道槽函式
    void slot_startCollect();                                       // 開始採集槽函式
    void slot_startCollect2();                                      // 開始採集槽函式
    void slot_timeOutCollectEnd();                                  // 定時器停止
    void slot_timeOutCollectEnd2();                                 // 定時器停止
    void slot_startPlayback();                                      // 開始回放
    void slot_stopPlayback();                                       // 停止回放

private slots:
    void on_pushButton_apply_clicked();

#if SIMULATION
    void on_pushButton_startSimulationAll_clicked();                // 開始採集所有
    void on_pushButton_startSimulation_clicked();                   // 開始採集組1
    void on_pushButton_startSimulation2_clicked();                  // 開始採集組2
#endif
    void on_pushButton_stopAll_clicked();                           // 停止所有
    void on_pushButton_stop_clicked();                              // 停止組1
    void on_pushButton_stop2_clicked();                             // 停止組2

    void on_pushButton_group_clicked();
    void on_pushButton_channelSet_clicked();
    void on_pushButton_paramSet_clicked();
    void on_pushButton_playback_clicked();
    void on_pushButton_export_clicked();
    void on_pushButton_exit_clicked();

private:
    Ui::HighFreqCollectMainWindow *ui;

#if SIMULATION
public: // 模擬
    void startSimulation();
    void startSimulation2();
    void stopSimulation();
    void stopSimulation2();

protected slots:
    void slot_timeOutSimulation();
#endif

protected slots:
    void slot_playback();

private:
    bool _collecting;
    bool _collecting2;
    bool _collectFinished;
    bool _collectFinished2;

private:
    QList<QString> _listChannelName;
    QList<QColor> _listChannelColor;
    QList<double> _listChannelOffset;
    QList<double> _listChannelMin;
    QList<double> _listChannelMax;

    int _c;
    int _c2;
    int _n;
    int _n2;
    int _freq;
    int _mode;
    QString _saveDir;

    QList<QLabel *> _listLabelName;
    QList<QPushButton *> _listPushButton;

    QString _cfgFile;

    QList<QCheckBox *> _listCheckedBox;

private:
    QElapsedTimer _elapsedTimer;

#if SIMULATION
private:
    double _nowX;                       // 當前X值,即當前採集時間,從0開始
    double _nowMinY;                    // 最小Y值
    double _nowMaxY;                    // 最大Y值
    QTimer *_pTimerSimulation;          // 模擬採集時使用的定時器
    int _intervalSimulation;            // 模擬採集間隔
#endif

private:
    QTimer *_pTimerCollectEnd;          // 採集固定式時間時使用
    QTimer *_pTimerCollectEnd2;         // 採集固定式時間時使用
    double _distanceEnd;                // 採集固定距離時使用
    double _distanceEnd2;               // 採集固定距離時使用
    double _encoder0Count;              // 當前採集位移0脈衝數
    double _encoder1Count;              // 當前採集位移1脈衝數
    double _encoder0Step;               // 編碼器0的脈衝位移
    double _encoder1Step;               // 編碼器1的脈衝位移

private:
    QList<int> _listGroup1;             // 組1組成
    QList<int> _listGroup2;             // 組2組成

private:
    bool _playback;                     // 當前是否回放
    QString _record;                    // 回放的記錄名稱(資料夾名稱,yyyy-MM-dd hh-mm-ss)
    QTimer *_pTimerPlayback;            // 回放讀取資料定時器
    bool _firstPlayback;
};

#endif // HIGHFREQCOLLECTMAINWINDOW_H

若該文為原創文章,轉載請註明原文出處
本文章部落格地址:https://hpzwl.blog.csdn.net/article/details/120345072