PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

PXIe-6738 analog write out data issue

I’m developing a driver for a NIDAQ device (PXIe-6738) and have run into an issue. The program reads data from a file and then writes those data to two output channels (I and Q).  

 

My analog write output function is

 

       DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle1, samples_per_channel,0,10.0,DAQmx_Val_GroupByChannel,*I_chan_buffer,NULL,NULL));

 

The issue is with the argument “*I_chan_buffer”. When I build my code, I am greeted with an error telling me that the type of *I_chan_buffer, which is int16, is not compatible with the argument type, which is an array of floats: float64[].

 

But I do not understand why I am getting this error. I took the following steps to initialize and populate “I_chan_buffer”

 

std::int16_t* I_chan_buffer = (std::int16_t*) calloc(ulCount / 2, sizeof(float));

std::int16_t* Q_chan_buffer = (std::int16_t*) calloc(ulCount / 2, sizeof(float));

ulCount = filesize/(sizeof(std::int16_t)); // This is equal to the total number of data points for both I and Q

 

       for (i=0; i<ulCount;i++)

       {

              fread(&TempBuffer, sizeof(std::int16_t), 1, fp);

              if (i%2 == 0){

                     I_chan_buffer[i] = (float)(TempBuffer - 0x8000);

              }

              else{

                     Q_chan_buffer[i] = (float)(TempBuffer - 0x8000);

              }

       }

       fclose(fp);

 

 

based on this assignment of a float to each element of the I and Q channel, I reason that the dereferencing of the associated array pointers should be of type float. That is,

 

*I_chan_buffer should resolve to an array of floats. I have also attempted passing I_chan_buffer and Q_chan_buffer directly but I get the same error telling me that the input argument is of type int16 which is incompatible with float64[].

 

Is anyone aware of what I may be doing wrong here?

 

Thanks

0 Kudos
Message 1 of 2
(1,002 Views)

You're using DAQmxWriteAnalogF64, I would assume F64 stands for Float 64-bit

 

When you write an Analog signal it will be a float value, if you want to write an unscaled raw signal, you have to use a different function.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 2
(986 Views)