Quantcast
Channel: Measurement Studio for VC++ topics
Viewing all 660 articles
Browse latest View live

Synchronize Data from analog input and digital counter input devices

$
0
0

Hello. I'm using the ANSI C library and have two cards: an NI 9237 and an NI 9401. The NI 9237 has a load cell, the NI 9401 has a linear encoder. I need to record the load and position channels in perfect synchrony. To that end, I adapted the following from an example. I configure the two channels, tie them both to the SampleClock of the analog card. The analog card task gets used to register the EveryNSamples event. The task, and I get the callbacks. But, while I always get the 1000 rows of data from both read functions, the data is not aligned in time. The position data is "ahead" of the load data. I feel like I must be missing a step syncing the data, but I can't find anything in any example where this shouldn't work.

 

Thanks in advance for any insight.

 

 

samplesPerSec_ = 10000; // 10khz

 


DAQmxErrChk(DAQmxCreateTask("AnalogInputTask", &taskHandle));
DAQmxErrChk(DAQmxCreateTask("EncoderTask", &encoderTask));

taskHandles_.push_back(taskHandle);
taskHandles_.push_back(encoderTask);

DAQmxErrChk(DAQmxCreateAIForceBridgeTwoPointLinChan(
  taskHandle,
  "cDAQ9185-1E26063Mod1/ai0",
  "Load",

  -2224.1108,
  2224.1108,
  DAQmx_Val_Newtons,
  DAQmx_Val_FullBridge,
  DAQmx_Val_External,
  10.0,
  350,

  0,

  2.3222,

  DAQmx_Val_mVoltsPerVolt,

  0,
  2224.1108,

  DAQmx_Val_Newtons, 

  NULL

));

 

DAQmxErrChk(DAQmxCreateCILinEncoderChan(
  encoderTask,
  "cDAQ9185-1E26063Mod3/ctr0",
  "Position",
  DAQmx_Val_X4,
  1,
  0.0,
  DAQmx_Val_AHighBHigh,
  DAQmx_Val_Meters,
  0.0000039976,
  0.0,
  NULL
));

 

DAQmxErrChk(DAQmxCfgSampClkTiming(
  taskHandle,
  "/cDAQ9185-1E26063Mod1/ai/SampleClock",

  samplesPerSec_,

  DAQmx_Val_Rising,
  DAQmx_Val_ContSamps,
  1000
));

 

DAQmxErrChk(GetTerminalNameWithDevPrefix(taskHandle, "ai/SampleClock", trigName));

 

DAQmxErrChk(DAQmxCfgSampClkTiming(
  encoderTask,
  "/cDAQ9185-1E26063Mod1/ai/SampleClock",

  samplesPerSec_,

  DAQmx_Val_Rising,
  DAQmx_Val_ContSamps,
  1000
));

 

DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(
  taskHandles_[0],
  DAQmx_Val_Acquired_Into_Buffer,
  1000,
  0,
  EveryNCallback,
  (void*)this

));

 

 

static int32 CVICALLBACK EveryNTest(
TaskHandle taskHandle,
int32 everyNsamplesEventType,
uInt32 nSamples,
void* callbackData
)
{

 

  DAQmxErrChk(DAQmxReadAnalogF64(
    taskHandles_[0],
    1000, // the number of samples to read
    10.0,
    DAQmx_Val_GroupByScanNumber,
    analogDataBuffer_.data(),
    analogDataBuffer_.size(), // the available size of the buffer
    &analogRead,

    NULL
  ));

 

  DAQmxErrChk(DAQmxReadCounterF64Ex(
    taskHandles_[1],
    1000,
    10.0,
    DAQmx_Val_GroupByScanNumber,
    counterDataBuffer_.data(),
    counterDataBuffer_.size(),
    &counterRead,
    NULL
  ));

 

  .. push data into FIFO queue ..

 

}

 

 

 

 


怎么用VS2005编程去操作USB4065

$
0
0

我是个刚转行的新手 我在看一些文件资料时发现提到了一些文件:nidmm.h niscope.h visa.h 还有一些对应的部分路径: <ivirootdir32>  和相应的库文件 看到我很混乱     

我目前想用vs去自己做个窗口去显示USB4065的测量值及模式选择和量程选择 下载了NI-​DMM驱动和NI-​DMM .NET​类库 但是不知道后续怎么操作了

想在这里请教一些步骤或是对应文件的下载链接 谢谢各位了

How to Program USB4065 with Visual Studio 2005

$
0
0

I don't know how to program USB4065 with Visual Studio 2005. How to call libraries and. H files.How to call libraries and. h files. There are also downloads and acquisitions of the required files. I want to use Visual Studio 2005 to make an interface that can recognize and operate USB4065.

 
 

I hope I can get help

labview to C++

$
0
0

When I used the labview program to convert to C++, I called lvanlys.dll and used the BWCoefs90 function, but there was a problem when calling lvanlys.dll. The error message: "labview.lib was not called from a LabVIEW process. ". How can I solve this? The code is as follows.
2. In addition, the data of type "InstanceDataPtr" appears in the function prototype of Hilbert transform. Is this the data of int32_t? Can I have a header file of this type?

 

#include<iostream>
#include<Windows.h>
#include<time.h>
#include<extcode.h>
#include<hosttype.h>
#include<dos.h>

typedef int(*Dllfun)(void *, void *, void *, void *, void *, const int32_t , void *, void *, int32_t *);

using namespace std;
int main()
{

Dllfun maopao1;
HINSTANCE hdll;

hdll = LoadLibrary("C:\\Users\\fs\\Desktop\\玻璃\\new\\USS9804 SDK光盘\\vs01\\DSP_BW\\lvanlys.dll");
if (hdll == NULL)
{

FreeLibrary(hdll);
}

maopao1 = (Dllfun)GetProcAddress(hdll, "BWCoefs90");
if (maopao1 == NULL)
{
FreeLibrary(hdll);
}
double fs[1] = { 500000 };
double fl[1] = { 480000 };
double fh[1] = { 520000 };
int order[1] = { 4 };
int type[1] = { 2 };
int32_t structure = 0;
int aH[20] = { 0 };
int bH[20] = { 0 };
int32_t dsperr[1] = { 0 };
int stass;

stass=maopao1(fs, fl, fh, order, type, structure, aH, bH, dsperr);
FreeLibrary(hdll);
getchar();

}

 

 

C++ errer “labview.lib was not called from a LabVIEW process.” how to solve this problem

$
0
0

I called lvanlys.dll in C++, and then I want to use the BWCoefs90 function in this dll. This error occurs at runtime. Is there any way to solve it?

best regard

How do I turn on the property Intf.LIN.Term?

$
0
0

Hello,

I recently started using the USB-8506.
How do I turn on the property Intf.LIN.Term?

I can't find such variables or structures.

 

Komao

NI PCIe-6321, PCIe-1433 - RTSI connected use

$
0
0

I've set up the trigger. However, the picture does not come out properly.

Is there another source coding method? (C++)

 

1.PNG

Image marked as vtk (500x1024)

cDAQ 9181 and 9476 system C sample

$
0
0

Hello,

 

I am using a PCI-6528 board (DI and DO) with VC++, and it runs perfectly. Now I want to switch to a simple cDAQ system composed by host board cDAQ-9181 with slot NI 9476 (only DO, it is ok for now). The 9181 chassis is connected to the pc via ethernet connection. This new system runs perfectly from NI MAX interface, now I need to automatize the operations using VC++. I read in this forum that i need to reserve the chassis before using it, however I am not able to find any documentation or example for doing this using VC++. I was wondering if someone can help me in retrieving this documentation (it seems not present in the examples installed with NI MAX software).

thanks for kind reply


VC2010链接出错:visa64.lib(visglu32.obj): error LNK2019: unresolved external symbol EnterAsyncCallback, referenced in function viEventHandler

$
0
0

在编写一个简单的通过VISA库异步读取GPIB结果的程序中,编译通过,链接时提示如题错误,还有另两个函数“ExitAsyncCallback” 和 “InStandaloneExecutable” 也是这样的提示,因为没有显示调用它们所以有点不知所措,使用Depends工具在动态库中没有找到对应的函数。经查在1996版的CVI编程手册中提到它们是定义在libsupp.h文件中,讲得很简单,不明白。而在2003版本的CVI编程手册中则去掉了这部分说明,不知是被替换了?还是怎么了?这个头文件是CVI的? 拿官方给出的简单例程AsyncIO_MSVC_VS2005来测试,也是提示了这样的错误! 我使用的是VISA提供的64位版本的导入库LIB和动态库DLL,操作系统是64位Win7中文,开发环境是VC2010。其实使用32位的也会出现这样的问题。 求高手给出解决思路!

LabView调用Dll

$
0
0

LabView Calls Dll file. I set the type but wrong code was 1097

图.jpgI do not know how to set the Type in LabView'

How to make a LIN diagnostic widh C/C++ on USB-8506 ?

$
0
0

I'm a LIN beginner. I need to make a diagnostic tool with USB-8506. I'm using USB-8506 in C / C ++, but there is no diagnostic sample. I have never used LabView, so I need support that can only be talked about with C / C ++. Can someone lead me?

Creating an Application with NI-HSDIO in Microsoft Visual C and C++

daq trigger related inquiries

$
0
0

When the master trigger is active
DAQmxCreateAOVoltageChan (m_BScanOutTask, "Dev1 / ao0", "m_BScanOutTask", -10.0, 10.0, DAQmx_Val_Volts, NULL)); Is there a way to delay m_BScanOutTask?

LabView调用Dll

Help in new project !!

$
0
0

Hi, my name is Gerardo and I want to see if they gave me their opinion on what software they would recommend me to build a coordinate measuring machine.


Acquire one sample at each trigger

$
0
0

Hi,

I'm using MATLab software to communicate with NI-DAQmx 6251 using C libraries. I want to acquire a analog voltage signal at each Digital Trigger input so that i acquire a data point per trigger.  The way I defined it in my program is, I set PFI0 at the falling edge to get the digital Trigger input and then DAQmxReadAnalogScalarF64 to acquire the data. But when it ran, the following error appears. "DAQmxErrorTrigWhenOnDemandSampTiming"  .

The whole program is working when I acquire multiple data points using DAQmxReadAnalogF64 function.

I do not understand how to solve this issue. Any help would be appreciated.

Thank you.

I'm attachting the matlab code below.

 

I'm using spincore Pulse-blaster to give the trigger input to the DAQ PFI0 and as for now battery to supply the input voltage to the AI0.

Measurement studio options for c++ in Visual Studio 2013

$
0
0

Greetings, I have installed Visual Studio 2013 and Measurement Studio 2015. When I try to select a new project with C++, there are no measurement studio options to select. However, if I select Visual Basic or Visual C#, both have measurement studio templates. Do I need to install something more?

Thanks,

Jack

Control of two voltage channel by same triggering signal

$
0
0

Hello, I'm trying to control two galvo-mirrors by DAQmx. 

I wanted to use same triggering signal for both of mirrors, so I did the below tasks for both of mirrors. 

Create task->Create voltage channels->Receive clk signal from external source->

Create internal triggering->Write voltage to mirror->start task

The code is as below, but there is an error when DAQmxWriteAnalogF64 function is run sequentially.

Is there anything wrong? Thank you Smiley Happy 

 

int hr;
if((hr = DAQmxCreateTask("",&_hMirrorB)) < 0)
return hr;
if((hr = DAQmxCreateTask("",&_hMirrorC)) < 0)

return hr;
if((hr = DAQmxCreateAOVoltageChan(_hMirrorB, DAQ_AO0,"", _cfg.bscanMin,
_cfg.bscanMax, DAQmx_Val_Volts, "")) < 0)
return hr;

if((hr = DAQmxCreateAOVoltageChan(_hMirrorC, DAQ_AO0,"", _cfg.cscanMin,
_cfg.cscanMax, DAQmx_Val_Volts, "")) < 0)
return hr;
if((hr = DAQmxCfgSampClkTiming(_hMirrorB, DAQ_EXT, EXT_CLK,
DAQmx_Val_Falling, DAQmx_Val_ContSamps, _cfg.N0)) < 0)
return hr;

if((hr = DAQmxCfgSampClkTiming(_hMirrorC, DAQ_EXT, EXT_CLK,
DAQmx_Val_Falling, DAQmx_Val_ContSamps, _cfg.N0)) < 0)
return hr;
if((hr = DAQmxCfgDigEdgeStartTrig(_hMirrorB, DAQ_INT, DAQmx_Val_Rising)) < 0)
return hr;

if((hr = DAQmxCfgDigEdgeStartTrig(_hMirrorC, DAQ_INT, DAQmx_Val_Rising)) < 0)
return hr;
if((hr = DAQmxWriteAnalogF64(_hMirrorB, _cfg.N0, 0, 10.0,
DAQmx_Val_GroupByChannel, (float64*)_bscanWaveform, NULL, NULL)) < 0) {
return hr;
}

if((hr = DAQmxWriteAnalogF64(_hMirrorC, _cfg.N0, 0, 10.0,
DAQmx_Val_GroupByChannel, (float64*)_bscanWaveform, NULL, NULL)) < 0) {
return hr;
}

 

if((hr = DAQmxStartTask(_hMirrorB)) < 0)
return hr;

if((hr = DAQmxStartTask(_hMirrorC)) < 0)
return hr;

How can I get NiVisa100D.lib?

$
0
0

First,please  allow me to introduce myself,I am a Chinese,my English is very poor,sorry to make you laught at me.

 

When I debugged my C project,the VS2012 signaled an error as the follow figure.But there is not  NiVisa100D.lib In my computer.I need help.

 

 

2.png

Convert std::string to LV path to apply to an dll generated from labview

$
0
0

Hi.

I am working with a dll-function generated from LV which needs an path type.

I would like to convert a std::string to LV-path and tried the following code.

 

    std::string v_PathAsString_o = "C:\\_work\\PowerSupply.ini";
    const char * v_path_pc = v_PathAsString_o.c_str();
    const char ** v_path_ppc = &v_path_pc;
    Path * v_Path_po = NULL;
    char **filename = 0;
    MgErr v_status_o = FStringToPath((ConstLStrH)v_path_ppc, v_Path_po);
    // v_status_o will be set to 2 (mFullErr)
    // v_Path_po remains 0x00000000

 

After sucessful compile and run I got status from FStringToPath() back and was set to mFullErr.

I cannot imagine that my Windows 7 PC is having trouble with memory space.

 

What is the right way to get a LV path variable?

Viewing all 660 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>