zoukankan      html  css  js  c++  java
  • NiDaq 测振动加速度

    如果出现这个错误,插拔一下usb口

     1mV=100 mm/s2 ,NiDAQ的震动测试仪有一个毫伏和震动加速度的对应值 约等于10, 但每个仪器都会校准

    Public Function GetVibrationData(ByRef Wave, ByRef msg As String, Optional ByVal Slot As Integer = 0) As Integer
    '测试振动数据
     On Error GoTo ErrorHandler
                Dim taskHandle As Long
                Dim sampsPerChanRead As Long
                Dim numchannels As Long
                Dim fillMode As DAQmxFillMode
                Dim numSampsPerChannel As Long
                Dim numSampsFreq As Long
                Dim arraySizeInSamps As Long
                Dim StrChance As String
                Dim AdjustValue As Single
                Dim taskIsRunning As Boolean
                
                Dim nGain As Double
                Dim Data() As Double
    
                'If scanOrderOption.value = True Then
                    fillMode = DAQmx_Val_GroupByScanNumber
                'Else
                '   fillMode = DAQmx_Val_GroupByChannel
                'End If
                
                 
                        numSampsFreq = 51200
                        numSampsPerChannel = 51200 / 3
    
                
    '            numSampsFreq = 51200 '8192  ' 8192 ' 8000 '8192  '8192  '4096 '50000 '2048 '10240 '4096
    '            numSampsPerChannel = 12800 ' 8192 ' 51200  '34200 ' 32768  '16384 ' 32768 ' 8192 ' 8000 ' 20000 ' 8000 ' 2048 '' 10240 '4096 '10240  '8000 'CLng(samplesPerChannelTextBox.Text)
    '
    
                'StrChance = "cDAQ1Mod1/ai0:3"
                StrChance = "cDAQ1Mod1/ai" & CStr(Slot)
                
                taskHandle = OpenMyCard(StrChance)
                taskIsRunning = True
             
                DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", CLng(numSampsFreq), DAQmx_Val_Rising, _
                                DAQmx_Val_AcquisitionType_FiniteSamps, CLng(numSampsPerChannel))
                
                DAQmxErrChk DAQmxGetTaskNumChans(taskHandle, numchannels)
                arraySizeInSamps = numSampsPerChannel * numchannels
                ReDim Data(arraySizeInSamps - 1)
    
                 DoEvents
                 Dim nSamptimes As Double
                 nSamptimes = timeGetTime
                 DAQmxErrChk DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, 10#, _
                                fillMode, Data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
                 
    
                 Do While sampsPerChanRead < numSampsPerChannel - 1
                    
                    DoEvents
                    If timeGetTime - nSamptimes > 3000 Then
                        Exit Do
                    End If
                 
                 Loop
                
                Dim fMax, fMin As Variant
                Dim nMaxIndex  As Variant, nMinIndex As Variant
                Dim nMaxValueFre As Single, sngAccelerationValue As Single
    
                
                DAQmxErrChk DAQmxStopTask(taskHandle)
                DAQmxErrChk DAQmxClearTask(taskHandle)
                taskIsRunning = False
                
                Wave = Data
                Exit Function
    ErrorHandler:
                Dim nData(0) As Integer
                Wave = nData
                msg = "Error: " & Err.Number & " " & Err.Description
    End Function
    Public Sub DAQmxErrChk(errorCode As Long)
    '
    '   Utility function to handle errors by recording the DAQmx error code
    '   and message.
    '
    
        Dim errorString As String
        Dim bufferSize As Long
        Dim Status As Long
        If (errorCode < 0) Then
            ' Find out the error message length.
            bufferSize = DAQmxGetErrorString(errorCode, 0, 0)
            ' Allocate enough space in the string.
            errorString = String$(bufferSize, 0)
            ' Get the actual error message.
            Status = DAQmxGetErrorString(errorCode, errorString, bufferSize)
            ' Trim it to the actual length, and display the message
            errorString = Left(errorString, InStr(errorString, Chr$(0)))
            Err.Raise errorCode, , errorString
        End If
    
    End Sub
  • 相关阅读:
    【python cookbook】【数据结构与算法】12.找出序列中出现次数最多的元素
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5 学习教程:快速入门
    Using XSLT and Open XML to Create a Word 2007 Document
    如何在VS2010中更好的编写JavaScript代码
    [转]这五种方法前四种方法只支持IE浏览器,最后一个方法支持当前主流的浏览器(火狐,IE,Chrome,Opera,Safari)
    [转]C# 超高速高性能写日志 代码开源
    windows 2003 发布遇到问题---分析器错误消息: 未能加载类型“YWPT.MvcApplication”。
    将Oracle数据库转换为SQL Server
    SQLServer2008导出表数据为SQL脚本
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/13031453.html
Copyright © 2011-2022 走看看