Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Error running NI-DAQmx ANSI C example in Windows 7 virtual machine

Solved!
Go to solution

I am running a Windows 7 guest system with an Ubuntu 14 host, using VirtualBox, and have run into a problem running even the simplest examples provided by National Instruments, using the ANSI C API for NI-DAQmx.

The first time the DAQ Device is powered on, I can run a single measurement, and after that, any other measurement displays the following error message:

 

Attempted to read samples that are no longer available. 
The requested sample was previously available, but has since been overwritten. 
Increasing the buffer size, reading the data more frequently, or specifying 
a fixed number of samples to read instead of reading all available samples 
might correct the problem.

Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos
Property: DAQmx_Read_Offset
Corresponding Value: 0

Task Name: _unamedTask(0)
Status Code: -200279

 

In order to be able to start a new measurement, I have to restart the DAQ device, probably in order to clear any internal buffers that are being overridden.

I am interested in running a basic continuous voltage measurement using a callback function. (The ContAcq_IntClk example provided by NI)

The exact same configuration, same version of NI-DAQmx(9.7.5), and running on Visual Studio 2012, runs smoothly on a machine running Windows 7 directly.

I suspect the problem is with the internal buffer being somehow messed up because of the connection with the Virtual Machine, but can't figure out an elegant solution to fix it.

The device I am using is NI USB-6289.

0 Kudos
Message 1 of 5
(6,548 Views)

Hello razvan017

 

Could you tell us what values you are specifying in the front panel of that example so we can try to reproduce the behavior?

 

What happens if you simulate a different device? Do you get the same error with a simulated device?

 

Regards

Frank R.

0 Kudos
Message 2 of 5
(6,525 Views)

Hello fromm8

 

I have connected a voltage source to the ai0 port of the device in order to perform analog input measurements.

The C code is the one provided in the example, without any modifications.

 

        /*********************************************/
	// DAQmx Configure Code
	/*********************************************/
	DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
	DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
	DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));

	DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
	DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

	/*********************************************/
	// DAQmx Start Code
	/*********************************************/
	DAQmxErrChk (DAQmxStartTask(taskHandle));

	printf("Acquiring samples continuously. Press Enter to interrupt\n");
	getchar();

 

When using a simulated USB-6289 device, the example runs just fine, but I can't seem to get it to work on my physical device.

0 Kudos
Message 3 of 5
(6,516 Views)

Hello razvan017

 

I see the code attached and I now it is the shipping example without modifications. I tested the code and I know it should work fine.

 

1. I think the next step should be to test the real device using MAX test panels and create analog input tasks in NI MAX as well in order to verify if the behavior is the same.

 

2. Other thought... the way you are stopping the task. How are you stopping this example?

 

Regards 

Frank R.

0 Kudos
Message 4 of 5
(6,489 Views)
Solution
Accepted by topic author razvan017

Hello fromm8

 

Thank you very much for your help, I managed to locate the problem.

It wasn't from the actual code, or anything like that, it was a problem of communication between the VirtualBox machine and the physical device.

The MAX test panels kept throwing a simmilar error as the C program.

 

I fixed the issue by switching to VMWare, which seems to have better compatibility with USB devices.

 

Cheers!

0 Kudos
Message 5 of 5
(6,467 Views)