PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

How Do I know if I am talking to PCI_MIO-16E-4 from C++ ?

Hello MATT,
Thank you for your response. I understand that DAQmxCreateAIVoltageChan measues Voltage and so there are other functions for current and counter measuremeants. But, in my case where I am trying to measure is our own channels of different things, are you saying I could use DAQmxCreateAIVoltageChan for example to measure RPM, or pressure channels from our hardware, or this function is strictly for voltage measurings(This where  am confused). I understand how to create tasks and add channels to task, my probelm is with configuring channels and assigning the names as I can't seem to apply it to my case, even though I did read the help file. For example, if I am trying to read RPM, say MyCh1 = "RPM", MyCh2="Pressure"...so on, Are you saying I could use the following to configure and assign the channel  with something like that?

DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","RPM",DAQmx_Val_RSE ,0,32000,DAQmx_Val_FromCustomScale,UnitsArray[1])); // Assuming am trying to read RPM channel for RSE, RPM ranges from 0 to 32000//

DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai1","Pressure",DAQmx_Val_RSE ,2000,50000,DAQmx_Val_FromCustomScale,UnitsArray[2]));

and so on....

Thank you very much for your help.

0 Kudos
Message 11 of 38
(2,103 Views)

Also, I failed to mention that i am using an encoder for the RPM. I want to be able to measure RPM, degrees, pressure...etc. This makes me think that I should be configuring a counter channel instead of voltage channel. I think measuring positions should give me an insight about the degrees situation... Let me know what you think of how I might configure the channels /

Thanks again

0 Kudos
Message 12 of 38
(2,104 Views)
Hello NewBe,

The DAQmxCreateAIVoltageChan() associates a voltage input on a physical channel to the task. That means, that it will read the voltage on that physical channel. Then, you are able to relate that voltage to your actual measurement through the use of custom scales. Custom scales are discusses in detail in the NI-DAQmx C Reference Help. The basic description is as follows:

"
You can create scales to specify a conversion from the prescaled units measured by a channel to the scaled units associated with your transducer or actuator. For input channels, the scale converts samples read to the final scaled units. For example, a scale could convert a voltage to a linear position. For output channels, the scale converts samples written to the prescaled units of the channel. For example, a scale could convert a linear position to a voltage. You also can use scales to calibrate samples read or written so that the final scaled units are identical to the prescaled units of the channel."

You can create a custom linear, mapping or polynomial scale using the DAQmxCreateLinScale(), DAQmxCreateMapScale() or DAQmxCreatePolynomialScale() functions respectively. Once you have created the scale, you would apply it to your voltage channel by passing the scale name as the customScaleName[] parameter in the DAQmxCreateAIVoltageChan() function. So, to measure pressure you would create a custom scale based on the characteristics of your pressure transducer and then apply that custom scale to a voltage channel. You would add this voltage channel to your analog input task, along with any other analog input channels you have. Your previous post contains the correct format for adding an "RPM" and a "Pressure" channel to the taskHandle task. However, you would have to use a custom scale to map the minimum and maximum values of your channels to the +/- 10V range of the DAQ device.

In regards to your questions about measuring RPM, there are DAQmxCreateCI functions for both linear and angular encoders. These functions add an encoder channel to a counter input task. You can use the angular encoder channel to specify pulses per revolution and then measure the degrees or radians that the encoder has turned.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
Message 13 of 38
(2,084 Views)
Hello Matt,
I think  this was the explanation I was looking for. This makes lots of sense, as I didn't come across the topic of custom scaling before now. I appreciate your help, I am going to start the conversion of the code, if I have any problems I can post back here. I was wondering if it is possible for  you to provide me with your phone Number, or email as I am under NI support plan in case If I needed help at some point.
Thanks
0 Kudos
Message 14 of 38
(2,082 Views)

Hello Matt,

I still can't seem to read the data in the data array with all the examples in the C directory. It doesn't matter what example I do, counter, freq, pulse, voltage, I do read the number of samples, but not the data array itself. I get 0 for data array, I did make sure I am using correct format %d, %f...etc. The freq counter examples seem to hang on waiting forever, and I have to reboot to get out of it. Even though when I create a task using the MAX tool, I can't get it to display measured values. However, the test panel works, it does count up fine, so I know the transdeucer and encoder are hooked up right. Could it be the version am using? (NIDAQmx 8.5 on Vista Ultimate)

Thanks

0 Kudos
Message 15 of 38
(2,064 Views)

NewBe,

 

If you have a support contract, you may call in and talk to one on the application engineers. We all have the same knowledge and will be able to help you with the issue.

As for not being able to read in the data, DAQmx 8.5 should be fine, as this is a Vista compatible driver. Also, if the program is getting hung up on a ‘wait until done’ task, this could be an indication that the number of samples to acquire is not being met, therefore the task is not finishing and you read out an empty array (although this should throw a timeout error if proper error handling is being done). It is a good sign that the test panels are working. As you pointed out, this means that the card is working and your sensor is properly connected.

Can you please tell me which shipping example you are using? I will take a look at it on a Vista machine here to see if I can replicate the problem.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 16 of 38
(2,051 Views)

Hi Dave,

I am using 16E-4 card. Could you tell me how can i get the VC++ examples, everytime I download the drivers, it comes with the ANSI C examples, not the C++ ones. What's the trick to getting the C++ examples? During Installation, I tried installing Measuremant and atuomation C++2005, it said that I have to have Measurmeant and studio 2005 installed already.

As for the edge count example, i am still having problem getting that example to work. I can get the #of samples, but when I look inside the data array, its zeros.

Thanks

0 Kudos
Message 17 of 38
(2,050 Views)
Sorry, the examples i am using are the two examples in count edge event folder (Cnt Dig Event) & (cnt-Buf-Cont-ExtClk). For the external Clock, I tried PFI4 or PFI7 as these two work on hte test panel. With PFI7, I can get the # of samples to display sooner that when using PFI4.
Thanks
0 Kudos
Message 18 of 38
(2,046 Views)

NewBe,

The error is correct, in that you need Measurement Studio 8.0 or later to have these support and examples installed. I would refer back to Matt’s original post. Can you please post the part of code you are using to read the counter, and the code which is used to print out the array?

David L.
Systems Engineering
National Instruments
0 Kudos
Message 19 of 38
(2,036 Views)

Hello Dave,

I can live with C examples. The problem I am having is getting the counters to work. In my application, I need to measure RPM of spinning encoder, so I think I need to have a counter with PFI7 (sample clk) as a time base and counter with (PFI4) to count once per revolution. I have to count for 2 stroke (360) and 4 stroke(720). I also need to measure degrees. I am not too sure as of yet of how to accomplish that, but I figured by getting the counters to work. I was able to read voltage fine. The counter examples provided in C, spit out the # of samples read, but shouldn't I be able to look at the data count. Also, if you could provide an explanation of how you might accomplish the above would be greatly appreciated. Angular position calls are not supported in my card. One of the examples I can't get to workk is:

DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle1,"Dev1/ctr0","",DAQmx_Val_Falling,0,DAQmx_Val_CountUp));

DAQmxErrChk (DAQmxCfgSampClkTiming(taskH1andle,"/Dev1/PFI4",1000,DAQmx_Val_Falling,DAQmx_Val_ContSamps,1000));

DAQmxErrChk (DAQmxStartTask(taskHandle1));

while(1)

DAQmxErrChk (DAQmxReadCounterU32(taskHandle1,1000,10,data,1000,&read,NULL));

printf("Samples=%d",read); // this gives me 1000 samples when encoder is spining

for(int i=0;i<read;i++)

{

  printf("%u or %f,data[i]); // this data is zero

fflush(stdout);

}

Shouldn't the data array be holding the data count, so I can i use it as a time reference or latch the data according to the count?

Thanks

0 Kudos
Message 20 of 38
(2,034 Views)