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

NI-DAQmx Base : Synchronize PC clock (QueryPerformanceCounter) with PCI 6221 analog input

$
0
0

I'm running a loop in windows7 which periodically polls the parallel port for a TTL signal while continuously reading samples at 1KHz for approx 1 hour. As a test, I split the incoming TTL and *also* read it as an analog signal. To my amazement, when I put the results next to each other after the test was done, i noticed that the time of the TTL and the time inside the analog data was NOT THE SAME.

 

more specifically, the timestamp of the TTL-up in my mainloop was 100msec *before* the timestamp in the analog data where I saw the voltage go up !

 

after much teeth-grinding and googling, I found that this is most likely caused by the PC clock drifting : http://www.windowstimestamp.com/description

 

my question is now : how can I sync this ? I have several options :

 

- use the library from http://www.windowstimestamp.com/description but that is quite a bit of work and will require additional DLLs to be installed

- figure out a way to use the clock of the 6221 card inside my mainloop where I poll the parallel port. 

 

is that possible ? Is there a way to ask the time of a TaskHandle ? Or should I use the 

DAQmxRegisterEveryNSamplesEvent() routine to do this ?


Programming for NI USB 6221 by MFC (Visual C++)

$
0
0

Hi,

I have NI USB 6221 M-Series DAQ DEVICE. I want to programming for it by MFC (VISUAL C++). I use the Visual Studio 2013.

Thus, How can I do it? Who can guide to me step  by step?  Please help me?

 

Thank you very much!

 

Best,

 

Lam.

 

Measurement Studio C++ MFC Legacy for visual C++ 2010

$
0
0

Hi,

How can I install Measurement Studio C++ MFC Legacy in VIsual C++ 2010? 

 

Please help me Smiley Sad((((

 

Thank you very much!

 

Error 1304 happened on Win7 x86 while installing the package made by NI Measurement Studio Installer Builder

$
0
0

Hi,

 

We made the Installer package with the help of NI Measurement Studio Installer Builder. The Installer ran properly on Win7 x64 without any issue. But when we ran the Installer package on Win7 x86, an Error 1304 would pop-up to block the installation.

Has anybody encountered similar issue before? How to solve this problem? Please. advise.

I have attached the Screenshot for this Error and also the log created during the installation and the Merge Modules I added in the Installer for your reference. Appreciate your attention and help in advance.

 

Thanks,

Kevin 

CWButton Control classic image

$
0
0

Hi,

im using a CWButton control, classic style, with image, in an MFC dialog.   I want the image to appear "floating" on the black background but there is a thin silver frame around outside of perimeter that i cant change its color or delete it.   How can i do this?

Reading data through NI PCIe-8381 in Visual C++

$
0
0

Hi,
I would like to seek some guidance in accessing NI PCIe-8381 card using Visual C++.
The issue is that I need to read the data in my C/C++ application directly through the PCI-8381 card instead of LabView. This card is plugged in a general purpose PC and this card is connected to NI PXI-8381 card in PXI station.
I read online that DAQmx library lets you access NI cards this way, but I couldn't find any reference for PCIe-8381 as a support device.
Any guidance/help would be highly appreciated.
Kind Regards,
Bilal

ANSI C example : "DAQmx Error: No device by the given name was found."

$
0
0

Hi everybody,

 

I'm trying to build and run a DAQmx ANSI C example, which is "/Analog Out/Generate Voltage/Cont Gen Volt Wfm-Ext Clk" (Windows 7 Pro, NI-DAQmx 17.1.0, NI-MAX 17.0.0).

 

I modify it to correspond to my PXIe-6361 virtual card and to build and run it without Visual Studio but just with gcc on Cygwin.

Here is attached the modified code and a screenshot of my virtual card configurations on MAX.

 

It builds but when I run it, it says : "No device by the given name was found" without any error code.

Nano@Nano-PC ..Gen Volt Wfm-Ext Clk-old $make && ./ContGen-ExtClk.exe
gcc.exe -g   -c -o ContGen-ExtClk.o ContGen-ExtClk.c
gcc.exe -g -o ContGen-ExtClk ContGen-ExtClk.o -lnidaqmx
TEST1
DAQmx Error: No device by the given name was found.
Explanation:
No device by the given name was found.
End of program, press Enter key to quit

I think the problem occurred during this function "DAQmxWriteAnalogF64"; because my TEST2 is not printed.

 

I don't know what's the problem and I didn't find any solution on the internet for this error message.

Do you have any idea?

 

Thanks and have a nice day.

How I can run DLL generate from Labview in my MFC project?

$
0
0

Hi,

   Now, I need to use a dll ,which generated from labview,  to my MFC project. It seems like this, when I click a button on my MFC , pop the  application front panel (as see in the labveiw) . Anyone knows how can achieve it?


Suggestions for Accurate digital sampling and control program using M-series DAQ

$
0
0

Hi,

 

Recently, I found a method to develop a digital control program on C or C++,

which uses the M-series NI DAQ device just as like other microprocessor units(e.g. ARM). My device is NI-USB 6281.

I have searched for many example codes and manuals from NI.

 

I would like to share this for those who struggle to configure the DAQ settings

for a digital control program such as a conventional PID control or a Linear Quadratic Regulator.

 

This program uses internal hardware clock to make sampling time.

Since the M-series usb devices don't support any hardware-timed non-buffered actions,

sampling tasks are based on buffered operation.  

 

A counter is used as a reference clock for analog input or analog output.

 

Analog input task has an event call back function each time it gets an sample in its buffer.  

This event function works as an interrupt service routine which increases a count value for soft-timed loop in every iteration.

It fetches a sample from the buffer in the loop.

 

Analog output task writes dummy samples before it starts, and it regenerates output when

the user calls the write functions in the loop. The major problem was that the analog output task is so hard to handle using NI-DAQs.

They almost consume all of the loop sampling times. If one tries to use a OnDemand mode,(fully soft-timed mode) it will take about 2ms or more.

 

The main do-while loop will act asynchronously though the control script will be executed only once

by the flag. This ensures the idling time for control code.

(Using only flag to block the main code is really vulnerable, though. I would expect that someone could solve this and help me)

 

Using this looping method, I could achieve up to 1800Hz sampling rate without any time-delays.

However, as the main soft-timed loop depends on the speed of processor, one could get only up to 1000Hz or 1500Hz.

Nevertheless, this program ensures a rich sampling rate compared to the soft-ware timed program using Windows times.

 

If you have any inquiries or suggestions, please feel free to reply.

 

Best regards,

 

Byeong-uk, Im.

 
1492068490707_PastedImage
Im, Byeong Uk
MS Course |Active Aeroelasticity And Rotorcraft Lab.
Mechanical And Aerospace Engineering |Seoul National University

1 Gwanak-Ro, Gwanak-Gu, Seoul, 151-744, Bd. 301, Room 1357
Tel:82-2-880-1901 |C.P.:82-10-2439-0451 |W:http://helicopter.snu.ac.kr
 

SCPI command not found

$
0
0

I am developping a auto-test program according to GPIB to connect to E4404B, spectrum analyzer, than I found some example code here, 

 

/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Set Y-Axis units to dBm*/
viPrintf(viESA, "UNITSmiley TongueOW DBM\n");
/*Set the analyzer center frequency to 50MHZ*/
viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");

 

the strange thing is that "UNITSmiley TongueOW DBM" can not be found anywhere, in standard SCPI command or instrument specified command, does anyone can explain where this command comes from?

Install Measurement Studio C++ MFC Legacy for 2010

$
0
0

Where is the download for the legacy Measurement Studio C++ MFC for 2010? 

NI6509 Watchdog timer expires prematurely

$
0
0

Hello,

I am using the Watchdog functionality of NI6509 PCI board.

The problem I am experiencing is that Watchdog time sometime expires prematurely.

Especially if I stop the watch dog and restart it again.

Please see the attached NI6509Controller.cpp, where I am defining following functions:

1) SetupWatchDogTask 

2) StopBoardTask

3) RunWatchDogThread

 

Basically my thread is running the thread function RunWatchDogThread, waiting to receive following commands:

- WD_START, WD_PUMP, WD_STOP  and calls the functions as described in the code.

Usually I am starting the Watchdog with timeout = 5s and start pumping with command WD_PUMP.

At some time I am stopping it by sending WD_STOP command, 

By this point the functionality works fine.

Next time I start the Watchdog( WD_START with 5s ), it stops prematurely within a second.

Could you please help?

Thanks in forward,

HOW can i wrap the MPI parallel code into a DLL and use LabvIEW call it.

$
0
0

hi,I write my algorithm in C language by MPI (process-level parallel ). After that, I want to wrap the parallel code into a DLL(dynamic link library) and embed the DLL to LabVIEW. But the MPI must be started by mpiexec command. So, if I wrap the MPI code into a DLL, I cannot run the MPI code. can  LabVIEW support to process-level parallel in a DLL?  Can you give me some advice or else to run the MPI parallel code or else? Look forward for you replying.

Reading calibration time

$
0
0

Hello everybody

 

I try to read the latest calibration time from a instrument in my PXI chassi using C++

functions in nisyscfg.h. Below is a code snippet

NISysCfgTimestampUTC lastTimeCalibrated;

 NISysCfgUInt64 secondsSinceEpoch1970;
double fractionalSeconds;

NISysCfgGetResourceProperty(resource, NISysCfgResourcePropertyExternalCalibrationLastTime, &lastTimeCalibrated);
NISysCfgValuesFromTimestamp(&lastTimeCalibrated, &secondsSinceEpoch1970, &fractionalSeconds);

After the call a get (Copied from my debugger)

secondsSinceEpoch1970    2212122498    NISysCfgUInt64
        lastTimeCalibrated    @0x28fb38    NISysCfgTimestampUTC
            u32Data    @0x28fb38    unsigned int [4]
                [0]    2685816    unsigned int
                [1]    829144320    unsigned int
                [2]    2    unsigned int
                [3]    1    unsigned int
        fractionalSeconds    0.19305020570769565    double

I have read in the  usergoups that NI starts time calculation from 1904 and not 1970

but anyway i can't get the value of

secondsSinceEpoch1970    2212122498

to be correct. NI MAX says some date in 2016....

 

Anyone that knows what i am doing wrong ??

2212122498 Seems to be in the 2040-mm-dd

 

best regards

  Håkan

 

 

niRFSA_init

$
0
0

Hello,

 

I have followed the correct instructions to import the correct nirfsa.lib and my paths are correct.

When I comment out this line, my program compiles fine.

niRFSA_init ("PXI1Slot2", VI_TRUE, VI_FALSE, &session)

 

I am trying to build a simple driver to connect I receive the error below.

error:

LNK2019 : Unresolved external symbol _sprint referenced in function _LoadDLLIfNeeded

 

Where else I should be looking for any libs or directories? What am I missing?
I referenece the
<IVIROOTDIR32>\Include
<VXIPNPPATH>\WinNT\Visa\include additional libraries as well as

 

<IVIROOTDIR32>\Lib\msc

For the nirfsa .lib dependencies


use labview dll in visual studio c++

$
0
0

Hi, all,

 

Questions:

I want to control Microsoft Visual Studio to use the dll which generated from labview. I have some problems here. I use labview 2017 and visual studio 2015.

 

1.

I create a test project and I create a math.vi to do mathematics addition. Then I use Build Specifications under project to create shared library.

 

2.

I create a win32 console application in visual studio and create a math project.

 

project -> properties -> configuration properties -> vc++ directories -> include directories: C:\Program Files\National Instruments\LabVIEW 2017\cintools was added

 

move SharedLib.lib to ...\Visual Studio 2015\Projects\math\math

project -> properties -> configuration properties -> vc++ directories -> library directories: Visual Studio 2015\Projects\math\math was added

 

project -> properties -> configuration properties -> Linker -> Input -> Addtional Dependencies: SharedLib.lib was added

 

move the ShareLib. h to ...\Visual Studio 2015\Projects\math\math and add it from header files in solution 'math'

 

3. motify the math.cpp file

#include "stdafx.h"
#include "SharedLib.h"

int main()
{
double k = Math(3.2, 4.5);
return 0;
}

 It could successfully compiled by visual studio and then I move the dll file under ...\Visual Studio 2015\Projects\math\math.

 

But, when I build it, it give me the following error:

 

Warning LNK4272 library machine type 'x64' conflicts with target machine type 'X86' math D:\Wenxu Documents\My Documents\Visual Studio 2015\Projects\math\math\SharedLib.lib 1
Error LNK2019 unresolved external symbol _Math referenced in function _main math d:\wenxu documents\my documents\visual studio 2015\Projects\math\math\math.obj 1
Error LNK1120 1 unresolved externals math d:\wenxu documents\my documents\visual studio 2015\Projects\math\Debug\math.exe 1

 

 

All files are attached. I am pretty new to labview. Thanks for your help very much! I was confused on it for a couple days. I appreciate a lot if you could give me some hints.

Best

use labview dll in visual studio

$
0
0

Hi, all,

 

Questions:

I want to control Microsoft Visual Studio to use the dll which generated from labview. I have some problems here. I use labview 2017 and visual studio 2015.

 

1.

I create a test project and I create a math.vi to do mathematics addition. Then I use Build Specifications under project to create shared library.

 

2.

I create a win32 console application in visual studio and create a math project.

 

project -> properties -> configuration properties -> vc++ directories -> include directories: C:\Program Files\National Instruments\LabVIEW 2017\cintools was added

 

move SharedLib.lib to ...\Visual Studio 2015\Projects\math\math

project -> properties -> configuration properties -> vc++ directories -> library directories: Visual Studio 2015\Projects\math\math was added

 

project -> properties -> configuration properties -> Linker -> Input -> Addtional Dependencies: SharedLib.lib was added

 

move the ShareLib. h to ...\Visual Studio 2015\Projects\math\math and add it from header files in solution 'math'

 

3. motify the math.cpp file

#include "stdafx.h"
#include "SharedLib.h"

int main()
{
double k = Math(3.2, 4.5);
return 0;
}

 It could successfully compiled by visual studio and then I move the dll file under ...\Visual Studio 2015\Projects\math\math.

 

But, when I build it, it give me the following error:

 

Warning LNK4272 library machine type 'x64' conflicts with target machine type 'X86' math D:\Wenxu Documents\My Documents\Visual Studio 2015\Projects\math\math\SharedLib.lib 1 
Error LNK2019 unresolved external symbol _Math referenced in function _main math d:\wenxu documents\my documents\visual studio 2015\Projects\math\math\math.obj 1 
Error LNK1120 1 unresolved externals math d:\wenxu documents\my documents\visual studio 2015\Projects\math\Debug\math.exe 1 

 

 

All files are attached. I am pretty new to labview. Thanks for your help very much! I was confused on it for a couple days. I appreciate a lot if you could give me some hints.

Best

What is the ID of an Attribute?

$
0
0

Hello,

 

I am trying to make a simple get call niRFSA_GetAttributeViString. Where can I find the ID of an Attribute?

 

I am trying to make a call to the NIRFSA_ATTR_SERIAL_NUMBER but this attribute is not working. I receive the error : -1074135028

IVI: (Hex 0xBFFA000C) Attribute ID not recognized

 

Use DAQmxCreateAOVoltageChan() to create multiple output channels in VS2017

$
0
0

Hi, all:

I want to use c++ to control NI-USB-9263. 

First, when I create a single output channel as: 

DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod1/ao0","",0.0000,5.0000,DAQmx_Val_Volts,NULL));

There is no problem.

But when I want to create two output channels as:

for(;i<4000;i++)
data[i] = 5.0*(double)i/4000.0;
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod1/ao0","",0.0000,5.0000,DAQmx_Val_Volts,NULL));
DAQmxErrChk(DAQmxCreateAOVoltageChan(taskHandle, "cDAQ1Mod1/ao1", "", 0.0000, 5.0000, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",4000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,4000));
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,4000,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL));

......

an error occurs: attemped writing data that is too large or too small.

error code: -200561.

 

I am sure the voltage range is not beyond the limitation.

Could someone help to solve this question? Thank you so much.

 

Regards

Xiaoran

PXIe-1085 C code documentation

$
0
0

What C API do I use that can tell me how to get the serial from the PXIe-1085, and later send or retrieve data to any cards inserted?

 

Where can I find the C API for System Configuration API 17 functionality as well?

 

The readme for the PXI Platform Services 17.0 says to visit ni.com/info and enter the Info Code pximxisysmon." for more information about System Monitor features. This code does not exist.

 

Also, NI-DAQmx is the only API mentioned in the PXIe-1085 manual found here, is it only used for dynamic routing? Thanks.

 

Viewing all 660 articles
Browse latest View live


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