Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

reading analog input with cpp

Solved!
Go to solution

Hi there,

 

Because LabVIEW cant handle this (In the VI; the value that was saved in the excel-file wasn't the same, which I saw during the measurement... This got me confused for a long time :P), I want to write a C++ programm (IDE: Dev-C++) which can read & save 2 analog inputs from the NI USB-6009 Box. For this i looked for a example from National Instruments and I found a few. But my problem is, that I can't even use any example, because it always occures a error, after i compiled and started it.

The error appears after the task was created and has the error number: -200220 with the description "Device identifier is invalid". But i dont think its invalid, because its the example xP

 

I must say that i am new into C++ programming, that means that i could have made a newbie-mistake. And i couldnt find a documentation or something for the library from NI-DAQmx.

 

Had someone similar problems with DAQmx and C++ and know how to fix it? I really dont know what I can do now without a working example or documentations...

 

Greeting Mario

0 Kudos
Message 1 of 8
(4,403 Views)

That's not making much sense. LabVIEW can certainly handle such a simple task and the device identifier in the example is irrelevant. You must use the actual device identifier that is on YOUR system. Simply look at MAX to see what it is.

0 Kudos
Message 2 of 8
(4,399 Views)

@Mari0 wrote:

 

.....

Because LabVIEW cant handle this (In the VI; the value that was saved in the excel-file wasn't the same, which I saw during the measurement...  

.....


Do you really think a Development Environment which out of history (1986) was ment to acquire, analyze, present and save data, which is used in this manner by a tremendous number of developers, is not capable of saving measurement data to excel?

 

Christian

0 Kudos
Message 3 of 8
(4,384 Views)

Dont take it the wrong way... I am not here to say that LabVIEW cant save measurement data. I did this a few times before too. But in this case it doesnt work. I cant say why.

 

But I also looked with the debugg-mode; I made a probe before the save-VI and there the value was the same like in the graph or on the numberic-indicator, but then, after the program was finished and I opened the excel-sheet, there were other values in it.

 

For example: on the numberic indicator (and graph and debugg-probe) its this value: 0.02513 and then in the excel sheet its a value like -0.01132

My first thought was that its maybe because excel understands the "," and "." wrong (I am swiss), but this wouldnt explain how the value goes negative.

 

@Christian_M with due respect but if you are so convinced of LabVIEW say; how is this possible? (I used both ways: Write to Spreadsheet File.vi and Write to text file.vi)

___

 

With the "actual device identifier" you mean where my sensor is attached? Because i certainly changed it in the example to "Dev1/ai2", like in MAX. In MAX everything works fine (and the measurement looks like in LabVIEW on the graph).

 

Mario

0 Kudos
Message 4 of 8
(4,380 Views)

Mario,

 

Please post your VI and I will have a look at your code. Keep in mind that the measurment value (usually DBL) will be converted to a string before it gets saved as a txt file which can be interpreted by MS Excel. Even though this task seems to be simple you will notice that there are several places where something could get wrong.

 

Yes, the device identifiere is e.g. "Dev1". The physical channels name could be "Dev1/ai2".

 

 

Christian

0 Kudos
Message 5 of 8
(4,377 Views)

ok, thanks. here it is (I must say that the pressure-sensor has 2 outputs..)

 

0 Kudos
Message 6 of 8
(4,374 Views)
Solution
Accepted by topic author Mari0

It is the same. You just didn't save the whole data:

 

Untitled.png

 

Please have a look at my comments in the attached VI.

 

Christian

 

0 Kudos
Message 7 of 8
(4,368 Views)

Thank you! Now it works great 🙂

0 Kudos
Message 8 of 8
(4,362 Views)