From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring Angular Position with vc++

Hello.

 

I'm using PCI6229 to measure ang position with a quadrature encoder, everething runs fine in LV, but I need this application to run in some text based languaje, so I ran the extample from Measurement Studio located here:

 

C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Measure Position\Angular Position-Buff-Cont

 

But it only gets to this line:

 

printf("Continuously reading. Press Ctrl+C to interrupt\n");

and nothing else appears on the DOS prompt. It is supposed to go over this line but this is all i get

 

I'm using VC++ 2005 express edition on a wvista computer to run this example (I could've used the specific example for this program but VC++ asks me for the windows.h file, which i don't have so I decided to run this ANSI C example.)

 

Any suggestion? any help will be apreciated.

0 Kudos
Message 1 of 13
(3,867 Views)
Hi ZainZeus, i ran the same program but using Windows XP and everything is ok. Probably Windows Vista is blocking something you should try to run it in another machine using Windows XP. I also will check it in the same enviroment as you.

Regards.
Arturo Gómez | Applications Engineering
Certified LabVIEW Associated Developer

National Instruments Latin America
01-800-010-0793
ni.com/support
0 Kudos
Message 2 of 13
(3,823 Views)

I apreciate your concern

Thanks for your answer

 

I already tried to use the next version of daqmx and a vista compatible version of vc++ but still not working, i'll try some other things that i haven't tried and then definetly give up.

 

 

0 Kudos
Message 3 of 13
(3,817 Views)

Sorry about that, ricarmen answer is actually ZainZeus answer, who is me.

 

It's just that ricarmen and I use the same computer in campus and she didn't logged off from her user and i didn't realize about that

but again the answer above this one is ZainZeus posted,

 

Apologies

ZZ

0 Kudos
Message 4 of 13
(3,815 Views)
Hi ZZ, don't worry,

Be sure you have NI-DAQmx 8.8 which is compatible with Vista, It's such difficult programming using this OS but not impossible, you have to be sure the firewall is not blocking tha application neither your Antivirus. If you have NOD32 Antivirus, it could be also the problem because this antivirus causes problems using DAQ and other drivers in MAX.

Try to disable the firewall and your antivirus and be sure you have change the properties of the folders and applications to allow full control in the OS.

I have XP and VB 6 and everything is ok, maybe you should try in this OS.

Regards.
Arturo Gómez | Applications Engineering
Certified LabVIEW Associated Developer

National Instruments Latin America
01-800-010-0793
ni.com/support
0 Kudos
Message 5 of 13
(3,805 Views)

How long will does it pause at DAQmxReadCounterF64(taskHandle,1000,10.0,data,1000,&read,0).  Have you waited longer than 10 seconds before aborting the program?  If you wait 10 seconds I would expect you to get a time out error saying that the board has not acquired all the samples that you asked for before the timeout period elapsed.  For the DAQmxReadCounter to return before the 10 second timeout you must supply a clock to PFI 8 and have it wired correctly.  The clock must be running fast enough that the board will get 1000 clock ticks (the number of samples requested) before the 10 second timeout has elapsed.

 

Regards,

 

Neil S.

Multifunction DAQ

Product Support Engineer

National Instruments

0 Kudos
Message 6 of 13
(3,798 Views)

You were rigth arturo, i had to wait 10 sec, if I move the encoder before 10 seconds i get "Acquired 444936 data", several times if i move it too much, if i don't move it i get:

Daqmx error: Measurements: Some or all of the examples requested have not been aquired,

Where do I see the data acquired?

This happened after i installed Daqmx 8.7.1 but with 8.5.2 it just showed press ctrl+c to interrupt,

Furthermore probably the problem is that i don't really understand this command. could somebody explainme a little about it?

 

In the other hand when I installed Daqmx 8.7..1 (which comes from the ni ftp server, meaning: I downloaded it ) the installation erased the examples I was using and only left the ones which had a debug folder on it, but it has not the code and only left the .exe file that vc++ created, can somebody send me those? They are the ones that says: ANSI C Examples.

 

Thank you people, keep helping me please.

 

 

0 Kudos
Message 7 of 13
(3,783 Views)

I think the examples were just moved.  The examples are now placed at C:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.

 

When your run this example data is read into the "data" variable.  If you want to see the data you will need to print it out in some way.  An easy way to do this would be to do something like:

 

int i;

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

   printf( "%f, ",data[i]);

}

 

The way  this example works is it programs the counter to measure the position of an angular encoder.  The encoder position is then moved into a buffer every time the board sees a pulse on PFI 8.  You can think of this as sampling the position of the encoder using PFI 8 as the sample clock.  I hope this clears it up a bit, although I think it might be more helpful if you let us know what you are wanting to do and there may be a more suitable example.

 

Regards,

 

Neil S.

 

 

0 Kudos
Message 8 of 13
(3,760 Views)

Hi Neil.

Sorry I confused you with arturo in the last post.

So you mean this example is not like in LV, where you just put daqmx assistant inside a while loop and see encoder's position every time as you move it? What use could it have having it read in a buffer and being able to "see" encoder's position only every certain time?

I don't see how for loop you posted work, because it only puts position every certain changes in encoder's angle. By the whay, Do i need to put :  

"DAQmxErrChk (DAQmxReadCounterF64(taskHandle,xxx,xxx,data,xxx,&read,0));"

 

at every reading? I mean does it has to be inside while loop?

 

You may not understand what I just said, so to put this simple: I just want -like in LV- beeing able to see encoders position as it changes, and it should has no time limmit, like in the example when it says: "Some or all of the examples have not yet been acquired" well i don't want that to appear, I want the reading to be time undefined.

 

ZZ

0 Kudos
Message 9 of 13
(3,734 Views)

ZZ,

 

You can change the timeout to -1 and the DAQmxRead will continue indefinitely until all the samples you requested are acquired.  However, since you are acquiring 1000 samples it may take a while for the read to complete, during which time your program will just sit there and do nothing.  If you would like a more responsive program you could either use the EveryNSamples event architecture like the  AI ContAcq-IntClk.c example, or you could poll the Available Samples property to find out when a sample or samples are available for reading.

 

Regards,

 

Neil S.

0 Kudos
Message 10 of 13
(3,717 Views)