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

USB 6008 programming in C#

$
0
0

Okay, this seems to be the right place... kinda empty in here though.

So, I'm making a hardware test fixture using a 6008 and a 6501 module. I seem to have the digital I/O working on the 6008, and the Analog measurements are working now as well. So, how can I read a freq? I need to check 4 of them, I was going to use tri-states or optoisolators to switch the 4 freqs into one input (counter).

So far the examples aren't helping. The bleeding things won't run! In VS2008 or VS2005. The also seem to be made by the most complicated manner possible. An example shouldn't use reference by value or 4 methods being called.

Any help? Pseudo code or the like much appreciated.


Installing DAQmx and c# code examples

$
0
0

Hi

I'm a bit rusty with all this, but it seems harder than it ought to be to install the DAQmx driver and write a C# program in Visual Studio 2013. (I just want a plain C# app, not measurement studio, and had fondly imagined there would be a simple example I could copy to start me off).

So I have my brand new USB 6001 working with MAX and Test Panels on my Win7 32-bit system. Bits toggle, voltages are read  - all good! But I can't find the .NET example code anywhere. I've read that in VStudio, I need to add 2 references to my Windows Forms app:

NationalInstruments.Common is present - no problem,

NationalInstruments.DAQmx is missing - why is that?

Searching around the C drive, I found NationalInstruments.DAQmx.dll dated 2010, left-over from a previous project. Could it be that DAQmx 18.5 doesn't work alongside older versions?

 

Elsewhere on this forum, someone had a similar problem and was told to install extra stuff manually, so I tried the same procedure, but Control Panel won't allow the installation to be modified - it has to be done by the original install program.

 

I tried the original installer, using the typical settings, and a message comes up saying no app development environments have been found on the PC, which is a little surprising as I have VS 2013. Otherwise, the installer seems to think it did everything it was supposed to do.

 

Please can someone help me get started with this?

Thanks

Roy

Error to use Dispose API of NI-VISA in C++

$
0
0

Hi,

I installed NI-VISA v18.00. and tried to create power supply control program in C++.

Refer to example code from NI-VISA  "Examples\.NET\17.5\SimpleReadWrite"

I could send USB command to control Keithley power-supply 2230G  properly. 

but when I would like to close the connected session. the compiler show the error message as below :

error C2039: 'Dispose' : is not a member of 'NationalInstruments::Visa::MessageBasedSession'

Does anyone have idea about this?  Thanks

Operation System : Win10 x64 VS2013

//my sample code

MessageBasedSession^ mbSession;

NationalInstruments::Visa::ResourceManager^ rmSession = gcnew ResourceManager();

 

strResource = rmSession->Find("USB?*0x2230?*INSTR");
for each (System:Smiley Frustratedtring^ strCom in strResource)
{
resourceID = strCom;
}
try {
     mbSession = (NationalInstruments::Visa::MessageBasedSession^)rmSession->Open(resourceID);

}
catch (...) {
}
try {
     mbSession->RawIO->Write("OUTP ON");
     Sleep(500);
}
catch (...) {
}
    Sleep(1000); //wait for Power supply stable
    mbSession->Dispose();  //compile error

 

Implementing VISA protocol in STM32F7 module

$
0
0

Hi everyone,

 

I'm trying implementing VISA protocol into my STM32 module to communicate it with LabVIEW.

 

Any ideas? I´m stuck.

 

Please help.

Visual Studio 2010 hanging due to Measurment studio error.

$
0
0

Visual Studio 2010 just started hanging badly when I open a project. It was working fine until recently. I am working in Windows 7 and getting the following error from the windows event logs.

 

Error Message: version == String.Empty Exception: ArgumentException Suggestion: Repair or re-install Measurement Studio. Stack Trace: at NationalInstruments.MeasurementStudio.ParameterCheck.ValidateNotEmpty(String value, String parameterName) at NationalInstruments.MeasurementStudio.Tools.Services.Component..ctor(String name, Guid guid, String version, String description, String installDate, String path) at NationalInstruments.MeasurementStudio.Tools.Services.InstallService.LoadComponents(String componentsKeyName, RegistryKey key)

Any suggestions as to what could have caused this to start happening?

DAQmxReadBinaryI16

$
0
0

DAQmxReadBinaryI16 doesn't works as I expected. Am I wrong in understand that  "sampsPerChanRead"  had to be updated after each sample ? I'm using USB6211 and some example in ANSI C code. Everything works fine acquiring 1000 samples but sampsPerChanRead is updated only at the end of DAQmxReadBinaryI16. Is it right?

MAX - Panel Configuration n'affiche rien

$
0
0

Bonjour,

J'ai un problème avec le logiciel Measurement and Automation Explorer. Lorsque j'ouvre l'application, rien ne s'affiche dans le panel de gauche 'Configuration', là où je devrais trouver les différents périphériques et interfaces branchés sur mon PC. Il m'est donc alors impossible de contrôler mes périphériques. 

Savez-vous comment régler ce problème ? Si jamais c'est un problème de driver ou autre ?

Cordialement,

Paul Fruton

NI8452 32/64 bit DLLs

$
0
0

Hi all,

 

I do have a question regarding the 32/64 bit version of the DLLs for the NI8452. I used the tipp from the this page: Using the USB-845-x API Functions

 

My programming environment is Visual Studio 2017 and I develop a DLL for usage in LUA, the 32 bit version as well as the 64 bit version.

In my build script I added the the DLLs as well as the *.lib. For 32 bit DLL this is working as expected. My problem is that the 64 bit version does not build and I assume that I need another *.lib for that version.

 

I found the original *.lib in the "Program Files (x86)" directory:

2019-05-13_11h32_48.png

 

Without the *.lib the appropriate functions inside the DLL are not found and I get a linker error. Does anybody know how to compile my DLL for 64 bit?

 

Kind regards

Sebastian


ASYST

$
0
0

Kan noen hjelpe meg?

Jeg har funnet fram noen 25 år gamle datafiler fra programsystemet ASYST 2.0 (dos) som jeg gjerne skulle ha lest.   Alt datautstyret fra dengang er kondemnert.  Hver fil inneholder ett array som deklarert:  REAL DIM[ 1000 ] ARRAY TEST.

Har forsøkt notepad++, word etc, men har ikke lyktes.

Ville vært svært takknemlig om noen kunne lese filene og konvertere dem til excel (helst) eller notepad++

Mvh

Magne

--

Professor emeritus Magne Waskaas, dr.philos

University of South-Eastern Norway

Faculty of Technology, Natural Sciences and Maritime Sciences

Kjoelnes Ring 56, P.O. box 203, N-3901 Porsgrunn, Norway

Telephone: +47 35026200

Cellphone: +47 93036286

Help Project!!

How to set the number of samples to process per second?

$
0
0

I created the source as below...

 

DAQmxCreateTask("", &m_task[0]);
DAQmxCreateAIAccelChan(m_task[0], "cDAQ9189-1DD988AMod1/ai0:2, cDAQ9189-1DD988AMod2/ai0:2, cDAQ9189-1DD988AMod3/ai0:2, cDAQ9189-1DD988AMod4/ai0:2, cDAQ9189-1DD988AMod5/ai0:2", "", DAQmx_Val_PseudoDiff, 0.0, 200.0, DAQmx_Val_AccelUnit_g, 50, DAQmx_Val_mVoltsPerG, DAQmx_Val_Internal, 0.004, NULL); DAQmxCfgSampClkTiming(m_task[0], "", 100, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000); DAQmxRegisterEveryNSamplesEvent(m_task[0], DAQmx_Val_Acquired_Into_Buffer, 100, 0, EveryNCallback, this);
DAQmxStartTask(m_task[0]);

I thought there were 100 samples per second of the sample collected 100, callback sample 100, but there is not.

How do I need to implement it in code?
I want to receive only the specified number every second.

 

 

Specifying Channel Read order Ni-DAQmx.

$
0
0

Hi, I am currently upgrading C code from Ni-DAQ legacy to the Ni-DAQmx format and was wondering if it is possible to specify a channel read order? ie. reading channels 1,7,2,7,3,7,4,7,5,7,6,7 in that specific order? Any help is appreciated

Help with problems when calling C++ DLLs

$
0
0

Using ts to call the C++ module DLL written by vs. The parameters of the function have not been displayed. Is my interface written in C++ wrong?Sincerely ask for help捕.PNGThis is my module editing interface, there is no function variable a, b获.PNGThis is my Cpp捕获.PNGThis is my header file捕.PNGThis is my module editing interface, there is no function variable a, b

SetReadChannelsToRead/Reading channels in a specfic order.

$
0
0

I have been trying to update our Ni-DAQ legacy scripts to Ni-DAQmx scripts and have encountered one large problem. I am trying to perform an Analog Block Read. The channel number and order is determined by some parameters supplied by another program. These values are contained in an array such as 0,7,1,7,2,7... etc where 7 is used to "zero" the voltage in between reads. This process works with 7 channels, but when I switch to a DAQ with 14 or 28 channels,I receive error 200082, which provides useless information in my opinion to solving the problem. I am wondering if there is a maximum amount of channels that can be specified in DAQmxSetReadChannelsToRead. The function in question is below, but some parameters may not be referenced. 

 

 

 

DLLEXPORT union data_val CALLBACK AIBConfig(void)
{
union data_val dev, mode, polarity, samp, gain, chvect, SampRate, ScanRate, ret;
int16* gains;
int16* vect;
int i;
int error = 0;
int32 read = 0;

// Configure all analog input ports for double buffered data collection.
get_param_val(&dev, ING, FIRST); // Retrieving Parameters from Splot
if (dev.i < 1 || dev.i > MAXDEV)
sntx_err(OUT_OF_RANGE);
AIBdev = dev.i;
get_param_val(&mode, ING, MID);
get_param_val(&polarity, ING, MID);
get_param_val(&samp, ING, MID);
if (samp.i < 0)
sntx_err(OUT_OF_RANGE);
nsamp[dev.i] = samp.i;
if (minpeakind == 0)
minpeakind = samp.i / 20; // default to match previous hard coded value
get_param_val(&gain, PTRT, MID);
if (gain.pv.p == NULL)
sntx_err(NULL_PTR);
if (gain.pv.pinfo->btype != SHRT)
sntx_err(TYPE_MISMATCH);
nchan[dev.i] = gain.pv.pinfo->dim[0];
gains = (int16*)gain.pv.p;
get_param_val(&chvect, PTRT, MID);
if (chvect.pv.p == NULL)
sntx_err(NULL_PTR);
if (chvect.pv.pinfo->btype != SHRT)
sntx_err(TYPE_MISMATCH);
if (chvect.pv.pinfo->dim[0] != (int)nchan[dev.i])
sntx_err(INDEX_OUT);
vect = (int16*)chvect.pv.p;
get_param_val(&SampRate, DUB, MID);
get_param_val(&ScanRate, DUB, LAST);

// allocate buffers
nibufsize[dev.i] = nchan[dev.i] * nsamp[dev.i] * 2; // *2 for double buffered
if (piBuffer[dev.i] != NULL)
free(piBuffer[dev.i]);
piBuffer[dev.i] = (int16*)malloc(nibufsize[dev.i] * sizeof(int16));
if (piBuffer[dev.i] == NULL)
sntx_err(OUT_OF_MEM);
if (piHalfBuffer[dev.i] != NULL)
free(piHalfBuffer[dev.i]);
piHalfBuffer[dev.i] = (int16*)malloc(nibufsize[dev.i] / 2 * sizeof(int16));
if (piHalfBuffer[dev.i] == NULL)
sntx_err(OUT_OF_MEM);
if (piXferBuffer[dev.i] != NULL)
free(piXferBuffer[dev.i]);
piXferBuffer[dev.i] = (int16*)malloc(nibufsize[dev.i] / 2 * sizeof(int16));
if (piXferBuffer[dev.i] == NULL)
sntx_err(OUT_OF_MEM);
if (diff[dev.i] != NULL)
free(diff[dev.i]);
diff[dev.i] = (int*)malloc(nchan[dev.i] * sizeof(int));
if (diff[dev.i] == NULL)
sntx_err(OUT_OF_MEM);


for (i = 0; i < (int)nchan[dev.i]; i++) // Assigning respective gains to channels
{
switch (gains[i])
{
case 1:
{
voltsLow[i] = (float)-5;
voltsHigh[i] = (float)5;
}
break;
case 2:
{
voltsLow[i] = (float)-2.5;
voltsHigh[i] = (float)2.5;
}
break;
case 5:
{
voltsLow[i] = (float)-1;
voltsHigh[i] = (float)1;
}
break;
case 10:
{
voltsLow[i] = (float)-0.5;
voltsHigh[i] = (float)0.5;
}
break;
case 20:
{
voltsLow[i] = (float)-0.25;
voltsHigh[i] = (float)0.25;
}
break;
case 50:
{
voltsLow[i] = (float)-0.1;
voltsHigh[i] = (float)0.1;
}
break;
case 100:
{
voltsLow[i] = (float)-0.05;
voltsHigh[i] = (float)0.05;
}
break;
default:
voltsLow[i] = (float)-5;
voltsHigh[i] = (float)5;
break;
}
}
time_step[dev.i] = 1.0 / ScanRate.d; // Calculating timestep
error = DAQmxCreateTask("", &taskHandle); // Creating Task
handleError(error, taskHandle);

for (i = 0; i < (int)nchan[dev.i]; i += 2)
{
char devAIB[256]; // Retrieving dev/chan # from splot
sprintf_s(devAIB, 256, "dev%d/ai%d", dev.i, vect[i]);
char inputMode[256]; // Retrieving dev/chan # from splot
sprintf_s(inputMode, 256, "DAQmx_Val_%d", mode.i);

if (vect[i] == LOOPBACKCH)
continue;
if (mode.i == 0) // Setting the terminal configuration
{
error = DAQmxCreateAIVoltageChan(taskHandle, devAIB, "", DAQmx_Val_Diff, voltsLow[i], voltsHigh[i], DAQmx_Val_Volts, NULL);
handleError(error, taskHandle);
}
else if (mode.i == 1)
{
error = DAQmxCreateAIVoltageChan(taskHandle, devAIB, "", DAQmx_Val_RSE, voltsLow[i], voltsHigh[i], DAQmx_Val_Volts, NULL);
handleError(error, taskHandle);
}
else if (mode.i == 2)
{
error = DAQmxCreateAIVoltageChan(taskHandle, devAIB, "", DAQmx_Val_NRSE, voltsLow[i], voltsHigh[i], DAQmx_Val_Volts, NULL);
handleError(error, taskHandle);
}
}
char controlChannel[256]; // Retrieving dev/chan # from splot
sprintf_s(controlChannel, 256, "dev%d/ai%d", dev.i, LOOPBACKCH);
error = DAQmxCreateAIVoltageChan(taskHandle, controlChannel, "", DAQmx_Val_Diff, -5, 5, DAQmx_Val_Volts, NULL); // Might not be always ai7? Therefore might need to be fixed to receive from splot.
handleError(error, taskHandle);
error = DAQmxCfgSampClkTiming(taskHandle, NULL, ScanRate.d, DAQmx_Val_Rising, DAQmx_Val_ContSamps, nibufsize[AIBdev]/2); // Configuring the Sample timing
handleError(error, taskHandle);
error = DAQmxSetAIConvRate(taskHandle, SampRate.d); // Modifying the AI convert clock rate
handleError(error, taskHandle);
error = DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, 2048, 0, EveryNCallback, NULL); // Creating Callback event
handleError(error, taskHandle);
error = DAQmxRegisterDoneEvent(taskHandle, 0, DoneCallback, NULL); // Creating done event
handleError(error, taskHandle);

char chanreadstr[2048];
char tempchread[80];
char rvect[2048];
chanreadstr[0] = '\0';

for (i = 0; i < (int)nchan[dev.i] - 1; i++)
{
//if (vect[i] == LOOPBACKCH)
//continue;
sprintf_s(tempchread, 80, "dev%d/ai%d, ", AIBdev, vect[i]);
strcat_s(chanreadstr, tempchread);
}
sprintf_s(tempchread, 80, "dev%d/ai%d", AIBdev, LOOPBACKCH);
strcat_s(chanreadstr, tempchread);
error = DAQmxSetReadChannelsToRead(taskHandle, chanreadstr); // Setting specific array of channels to read
handleError(error, taskHandle);
//error = DAQmxGetReadChannelsToRead(taskHandle, rvect, 2048);
//handleError(error, taskHandle);
error = DAQmxStartTask(taskHandle); // Starting the task
handleError(error, taskHandle);

ret.i = error;
return ret;

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.


C++ codes with PXIe-6547

$
0
0

Hi guys,

I am struggling to use C++ codes with PXIe-6547, and it makes error as follows. 

"Error description: This attribute or function is not supported in this session. Ensure that you are not using an acquisition-only attribute or function in a generation session or a generation-only attribute or function in an acquisition session."

I attached one of the c++ code that makes an error. Is there anyone can help me to solve this problem?

Thanks in advance!

Windows 10 not recognizing NI 9211 in NI USB-9162 frame

$
0
0

Windows 10 is not recognizing my NI 9211 in my NI USB-9162 carrier.

 

I am just getting back into this stuff, so please assume I know nothing. I have been away from this stuff for the last decade or so...

 

I installed the latest NI-daqmx, version 19 in my windows 10 computer today, and have started to try getting my NI measurement hardware running again. I was able to get a driver created and signed for my USB instrument carrier, a NI USB-9162. It now shows in device manager, and I can pull up the VISA test panel from MAX. Not sure how to tell if it is really working though.

 

When I load my NI 9211 thermocouple conditioner instrument into the USB-9162, I do not see it in MAX, or device manager.

Any ideas on how to get it to be recognized?

I want to at least get it working in a test panel for now.

 

Thanks,

Jim

 

Get coordinate and unhealthful Muscles

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 🙂 

 

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;

pxie-6341 generate sawtooth signal

$
0
0

i am using visual studio c++ with NIDAQmx.h library. I can use PXIe-6341 DAQmxCreateAOVoltageChan create constants voltage output. But when I change it to DAQmxCreateAOFuncGenChan, it return -200432 error code. Is it possible to use pxie-6341 to create sawtooth signal?

daqmxState = DAQmxCreateAOFuncGenChan(TaskHandle_AnalogOutput, "PXI1Slot4/ao1", "", DAQmx_Val_Square, 100, 3, 2);

 

Viewing all 652 articles
Browse latest View live