LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I have 2 problems with my daq card:


1- When I play with my daq card, I sent it : AI_VRead (1, 1, 1, &DataSensor)and I have a result but when I begin again this test, I have always the same result. Why?

2- When, I would like to store this result to a txt file, I can't read the result because there are some weird ascii code. I have 2 problems with my daq card:
1- pdata = malloc (sizeof(float));
if (pdata == NULL)
MessagePopup ("Malloc Error", "There is
not enough place.");
status = AI_VRead (1, 3, 1, &DataSensor);
*pdata = DataSensor;


2- hFile = fopen (save_file, "w");
fwrite (pdata, sizeof(float), 1, hFile);
fclose (hFile);
free (pdata); //malloc pointer


If you have any answer, may you
send me a mail, please. Thanks very much.
A French guy.
0 Kudos
Message 1 of 3
(3,246 Views)
Hello Ptit Seb,
I am not sure exactly what you mean by your first question. Do you read a grossly incorrect voltage? If you are reading a very small voltage, then you will need a larger gain than 1 to get a reasonable reading. Also, try connecting your board to a reliable voltage source (a 1.5V dry cell battery for example) and determine if the board is reading correctly. If this does not help you to solve the problem, then you will need to further explain your experimental setup -- you may consider doing this in the Multifunction IO group (http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=8&RFORMNUMBER=2&RHIDETAG=TRUE&UCATEGORY_0=_30&UCATEGORY_S=0) rather than CVI, as they may be better suited to answer this type of question.
Regarding your seco
nd question, you are writing the binary value pdata to a file using fwrite. The function fwrite does NOT perform any ASCII conversion or formatting, so the file will contain the binary representation of your floating point value (32 or 64 bits depending on if you use a float or double). To write an ASCII value, I would recommend looking over the Fmt() and printf() families of functions. Many of our examples under \samples make use of these functions.

Jeremiah Cox
Applications Engineer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 2 of 3
(3,246 Views)

When you refer to Datasensor are you talking about the sensor manufacturer? or the software attribute/property?

 

http://www.ctiautomation.net/DataSensor-Sensors.htm

0 Kudos
Message 3 of 3
(2,995 Views)