Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

application with visual studio

Hi,
I bought a new card USB-6215 and want my acquisition programs work with this card too.
I understood that I need NI-DAQmx drivers, so I installed them.
I couldn't find any working instruction to write an application using Microsoft Visual Studio 6, I didn't find which files I need to include in my project (header files, libraries and so on).
Can anyone help me?
Thank you very much!

Mauro
0 Kudos
Message 1 of 16
(5,539 Views)
0 Kudos
Message 2 of 16
(5,524 Views)
Thank you cery much, but.....maybe I was not clear, my programs need to be written in C (C++), no Visual Basic, no Measurement Studio...just raw C code Smiley Happy
0 Kudos
Message 3 of 16
(5,518 Views)
HI naughtybunnie,
All CVI examples are written in raw C, so any CVI example you find in our dev zone should be a good starting point.
For instance this one ( http://zone.ni.com/devzone/cda/epd/p/id/583 ) that realizes a continous acquisition with internal clock should match someone of your needs and may be a good starting point.
If you need only function prototype and so on you can search the NI DAQmx Reference C Help in the NI-DAQ program palette this could help you figuring out how DAQmx calls work.
 
Hope this two simple tips can help you.
 
Best Regards.
 
FiloP
It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
Richard P. Feynman
0 Kudos
Message 4 of 16
(5,504 Views)
Hi FiloP,
thank you very much!! The example you gave me works with my card. Really my application is not so simple, but I think this will be a good starting point...Please don't go away, maybe I'll need you again Smiley Happy

Mauro
0 Kudos
Message 5 of 16
(5,482 Views)
Hi! still problems with my USB-6215 and Visual C. I tried to acquire multi-analog-input-channels, but I can't understand sample flow I got.
I'd like to acquire 2 channels (interleave mode) at 250 Hz.

After creating the task, I configured the channels with the following:

DAQmxCreateAIVoltageChan(
    taskHandle,         //    this task
    "Dev1/ai0:1",       //    channel identification and # of acquiring channels
    "",                 //    name to assign to channel, left blank
    DAQmx_Val_Diff,     //    terminal configuration
    -10.0,10.0,         //    the minimum and maximum value, in units, that you expect to measure
    DAQmx_Val_Volts,    //    units
    NULL
);


Then I configured timing:

DAQmxCfgSampClkTiming(
    taskHandle,         // this task
    NULL,               // internal clock of the device is used
    250*2,              // sampling rate in samples per second per channel
    DAQmx_Val_Rising,   // active edge.....
    DAQmx_Val_ContSamps,// sampleMode: acquiring samples continuously
    0                   // I tried this with many values, very high too, but always the same result
);

After I registered my NSamplesEvent callback. I want to get samples every 100 ms, I wrote 50 in the third parameter, that is 250 (sampling frequency) every 1/10 seconds for 2 channels.

DAQmxRegisterEveryNSamplesEvent(
    taskHandle,                     //    this task
    DAQmx_Val_Acquired_Into_Buffer, //    for input task
    50,                             //    The number of samples after which each event should occur
    0,                              //    the callback is called in a DAQmx thread
    EveryNCallback,                 //    the callback function
    NULL                            //    parameter for the callback function
);

My callback is regularly called every 1/10 seconds and it is very simple, it contains the following:

int16                        data[32000];

DAQmxReadBinaryI16(
    taskHandle,       // this task
    DAQmx_Val_Auto,   // # of samples,per channel,to read. DAQmx_Val_Auto reads all available samples
    10.0,             //    timeout, in seconds, to wait for the function to read the samples
    DAQmx_Val_GroupByScanNumber,// fillMode: group samples by scan number (interleaved)
    data,             // the array to read samples into, organized according to fillMode
    sizeof(data),     // the size of the array, in samples, into which samples are read.
    &read,            // sampsPerChanRead: tThe actual number of samples read from each channel.
    NULL
);

Each buffer is sent to a Java application, no trasmission errors occur, no DAQmx errors occur.
I attached my 2nd channel to a device which output an analog triangular wave (tested with an oscilloscope).

You can see the result in the attached image.

I can't really understand why I get this result. It looks like a jump on the signal. Linearity of the triangular wave is ok within the 1/10 second buffer, then there is a jump...
Note that data is correct within 1/10 seconds. If I change configuration to get data every 1/5 seconds, then I get a correct line lasting 200 ms!
I'm sure that there is something wrong in configuration. This is the only one solution.
What' s wrong?
Can anyone help me?

Thanks a lot!

Mauro
0 Kudos
Message 6 of 16
(5,406 Views)

HI,   

 It looks like you're not acquiring in a continuous manner.
The shape you can see in the picture looks very closely to a triangular   wave acquired only for a few samples at a time.   
I try to explain me better, if the whole slope of your wave is 1000 samples and you aquire only 50 samples at a time and join toghether each acquisition 
the result is likely to be the one you're obtaining.
The "jump" is the joint between the previous and the next span of points you acquired, you are actually   missing something between each "jump".   

 My tip is the same, looks the examples about  continous acquisition and try to understand what you need to work your code properly.

 Hope this tip helps   

 

Best regards

 

 

 

FiloP
It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
Richard P. Feynman
0 Kudos
Message 7 of 16
(5,362 Views)
Thank you very much.
your reply is really useful, but I followed examples about continuous acquisition you gave me. Such examples involve only 1 channel, and my program works fine with only 1 channel...
As I configure 2 or more channels, I get the problem!
Do you know if there is some example involving multi channel acquisition?
0 Kudos
Message 8 of 16
(5,342 Views)
Hi,
In order to aquire two or more channel you have to put them in the same task, for the same timing circuitry is used.
The best way to do that is to separete the channels with a comma.
Try to use the same example I pointed to you separating the channels with a comma.
 
Physical Channel=Dev1/ai0,Dev1/ai1
 
Hope this time you can hit the target.
 
Bye
 
FiloP
It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
Richard P. Feynman
0 Kudos
Message 9 of 16
(5,313 Views)
Hi FiloP, thanks for suggestion.
I used the notation "Dev1/ai0:1" because programming manual writes that this is a correct sintax.

Bytheway I've already done many other tests:
I tried "Dev1/ai0,Dev1/ai1" and result is the same
I tried configuring channels 1 by 1, in this way :
    DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Diff,-10.0,10.0,DAQmx_Val_Volts,NULL);
    DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai1","",DAQmx_Val_Diff,-10.0,10.0,DAQmx_Val_Volts,NULL);
but I always get the same result...
There should be some example involving many channels, but unfortunately I couldn't find.
Now I hope to find some example with LabView, trying to understand how this work...

thank you again, see you soon on this forum

/X\au|2()
0 Kudos
Message 10 of 16
(5,276 Views)