zoukankan      html  css  js  c++  java
  • 使用NI-DAQmx进行振动数据采集

    安装NiDAQ 20.0, 这是for win7 最后一个版本了.  有同事安装的版本不对,就会出现如下的错误

     插上USB口的NI采集设备, 在NiMax程序里就能看见

    如果没有Ni设备,可以安装仿真设备, 在[设备与接口]处点右键,[新建...]

     

     仿真仪器采集回来的数据是一个正弦波

     没有插Ni仪器出来的异常

    Additional information: Device cannot be accessed.  Possible causes:
    
    Device is no longer present in the system.
    
    Device is not powered.
    
    Device is powered, but was temporarily without power.
    
    Device and/or chassis driver support may have been removed.
    
    Device is damaged.
    
    Ensure the device is properly connected and turned on. Ensure the device and/or chassis is supported in the current version of the driver. Check the device's status in NI MAX. Turn the computer off and on again. If you suspect that the device is damaged, contact National Instruments at ni.com/support.
    

      

    同一个vb振动测试程序, 一个exe是用NiDAQ 编译的,这个exe在另一台电脑上运行就会出现这个错误。代码运行则运行到采样哪里才会报错

    9174可以同时采集4个插槽的数据.采集例子如下:

           /// <summary>
            /// 
            /// </summary>
            /// <param name="ChannelName">物理通道的名称,类似cDAQ1Mod1/ai0:3</param>
            public void Sample(ref double[,] data,string ChannelName = "cDAQ1Mod1/ai0:3", int SamplePerChannel = 8192)
            {
              
                long sampsPerChanRead, numChannels, numSampsPerChannel, numSampsFreq, arraySizeInSamps;
                string StrChance;
                float AdjustValue;
                double nGain;
                Double[] TempData;
                try
                {
                    // 创建采集任务(NationalInstruments.DAQmx命名空间里的Task,不是线程的Task)
                    using (Task myTask = new Task())
                    {
                        // 创建虚拟通道
                        myTask.AIChannels.CreateVoltageChannel(ChannelName, //
                                                            "",//自定义通道名称
                                                        (AITerminalConfiguration)(-1), // -1表示使用缺省值
                                                        -5, // 最小电压值
                                                        5,  // 最大电压值
                                                        AIVoltageUnits.Volts //测量类型:电压
                                                        );
    
                        // 配置时域参数    
                        myTask.Timing.ConfigureSampleClock("",//外部时钟源线或使用“”作为内部时钟
                        25600, // 外部时钟的预期速率或内部时钟的实际速率
                        SampleClockActiveEdge.Rising, //上升或下降边缘获取
                        SampleQuantityMode.FiniteSamples, // 连续或有限样本
                        SamplePerChannel   // 要获取或用于缓冲区大小(如果连续)的有限样本数
                        );
    
                        // 校验任务
                        myTask.Control(TaskAction.Verify);
                        //多通道读取器,从任务中的一个或多个模拟输入通道读取样本       
                        AnalogMultiChannelReader myAnalogReader = new AnalogMultiChannelReader(myTask.Stream);
    
                        // 读取数据
                        //for (int i = 0; i < SamplePerChannel; i++)
                        {
                            //从通道读取数据
                           
                            data = myAnalogReader.ReadMultiSample(SamplePerChannel);                    
                            
    
                        }
    
                    }
                }
                catch (Exception)
                {
                    
                    throw;
                }
                /
            }
  • 相关阅读:
    蛙蛙推荐:五分钟搞定网站前端性能优化
    蛙蛙推荐:AngularJS学习笔记
    蛙蛙推荐:如何实时监控MySql状态
    这6种思维,学会了你就打败了95%文案!zz
    10分钟,解决卖点没创意的难题zz
    总感觉自己工作沟通想问题时没有逻辑,这可怎么办?| 极简逻辑指南
    「零秒思考」是个神话,不过这款笔记术你值得拥有zz
    关于提高沟通能力的书单 | 章鱼书单zz
    日常沟通的 3 种模式zz
    关于提高沟通能力的书单zz
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/15261738.html
Copyright © 2011-2022 走看看