Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

measuring time using PCI-6250

I am trying to get the measure time that it take the National Instruments (“NI”) PCI-6250 DAQ to measure a specific distance. I am not able to get the right time on very short distance.  

 

Before I added the additional 5ms wait time, short distance (between 1 to 40) produced inaccurate time. It was always off by 4 to 20 ms.  Also before adding the wait time, on some short distance, I was not able to see if the motor had moved.

 

Can you someone please help me? Or give suggestion? Both would be greatly appreciated. 

0 Kudos
Message 1 of 7
(3,728 Views)

Hello Sticyfinger,

 

After looking over your code, I would suggest not to use softwaring timing to acquire your data. Using software timing causes the inaccurate timing you were noticing. Instead, you should let the hardware perform a buffered acquistion that is timed. From here, you will know exactly what the dt is between two points so you can make the correct calculations. To do this, you have to create a clock for your counter input task in order to do buffered acquistion. I have provided an example how to do this. Along with this, it is also good practice to acquire the data in one loop and process the data in another loop. This is called consumer and producer architecture. This example also employs this programming structure.

 

I would try incorporating this example into your code or just start with this example as your base and build from here.


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 2 of 7
(3,699 Views)

Jim, 

 

is there a way i can view this code in LabVIEW 8.0 ? I am not able to see the code .. 

0 Kudos
Message 3 of 7
(3,624 Views)

Hello Sticyfinger,

 

I have converted the file from LabVIEW 2009 to LabVIEW 8.0. Unfortunately, there are some functions that might not work exactly the same in the previous version so you might run into problems. If you do, I have shown the picture of the VI I created so you can try to recreate it.

Encodercodepicture.png

 

 


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 4 of 7
(3,597 Views)

 

When I run the code as is. I get an error in the DAQmx start task (3 E.) do you have any idea why I am getting this error (-50103)?

 

After I changed counter to dev1/ctro and timing clock source to dev1/ctr1 it seem to be working … what is the difference between ctr0 and ctr1 ? 

 

 

Also since I am checking to see when the motor have stopped moving should the timing source be the motor?

 

0 Kudos
Message 5 of 7
(3,560 Views)

is there a way i can stop the loop when the data has been acquired? maybe use the "daqmx is task done vi" to control an case  structure? so if it is done it will wait an additional 10 ms for the motor to settle down and then take the final measurement reading ????  

0 Kudos
Message 6 of 7
(3,556 Views)

Hello Sticyfinger,

 

Since you have several questions about this VI and how to implement it, I am going to break them down below to make it easier to read.

 

Q: When I run the code as is. I get an error in the DAQmx start task (3 E.) do you have any idea why I am getting this error (-50103)? After I changed counter to dev1/ctro and timing clock source to dev1/ctr1 it seem to be working … what is the difference between ctr0 and ctr1 ?

 

A: Yes. Ctr 0 and Ctr 1 are 2 separate counters on the board that you can perform different tasks on. So in this example, Ctr0 can be for the clock or the source and the Ctr 1 will have to be the other. One counter cannot be an output and input at the same time and that is what the code will do if you set the counter channel to the same value.

 

Q: Also since I am checking to see when the motor have stopped moving should the timing source be the motor? 

 

A: No it shouldn't be. With the encoder task, you are monitoring/recording the angular distance the motor has moved so it needs a constant timebased in order to monitor the rising edges returning. If you want to stop the program when the motor stops, I would suggest monitoring the error of the DAQmx read when the time error occurs. From here you can say the motor stopped and you can then end the while loop which will stop the program.

 

Q: is there a way i can stop the loop when the data has been acquired? maybe use the "daqmx is task done vi" to control an case  structure? so if it is done it will wait an additional 10 ms for the motor to settle down and then take the final measurement reading ????

 

A: There are two ways to implement this. First way I have described in the previous answer. The other way requires you to know the amount of distance the motor will turn. Will you know this ahead of time?

The DAQmx- Is Task Done VI won't provide you with this information because the task is continuous therefore the task will never be done. This can be used for a finite task but then you must know how long the motor will run for.

The Wait until Next Millisecond Multiple isn't a pure wait. I would suggest looking at the help for this VI and it will provide you with the best explain. Here is the LabVIEW 2010 help document on it (which will be the same as 8.0).

 

Ultimately, you should walk through this code and completely understand the functions used before modifying the code. The best way to do this is to use the Context help window which can be openned by Ctl-H or by Navigating to Help » Context Help. With this window you can hover over any node in LabVIEW and see what it does.


Jim St
National Instruments
RF Product Support Engineer
Message 7 of 7
(3,523 Views)