Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder position and analog data to file

Hello,
 

I am using NI USB-6211 and PCI-6036E DAQ boards with LabView 8.2 and  an encoder with A,B and Z indexing. I would like to sample and write my data to a file at a sampling rate of 100-500 Hz. Each time that I write the analog data to a file I want to write the corresponding angular position. I am sorry but I am not very familiar with LabView so if someone could please outline how I would do this or give me a simple VI that I could build upon I would greatly appreciate it. I have found examples of the analog signal sampled at each pulse of the encoder but I want to insure that I measure my analog data at a constant time step.

 

Noel
0 Kudos
Message 1 of 12
(5,514 Views)

Hello,

It sounds like you are currently using an Analog Input task to measure the encoder lines.  Are you limited to just using analog channels?  National Instruments ships examples with Labview, which are located in the Example Finder under the Help Menu inside of Labview.  Please take a look at the examples in the Browse tab under the folders <Hardware Input and Output> <DAQmx> <Counter Measurements> <Position>.  These examples use a counter to measure the angular position for you.  By using one of the examples that use a DAQmx Timing VI, you will be able to specify the "constant time step" with the rate supplied by an external clock or select a sample clock from one of the boards as sample clock source.  The example would just need to be modified to write to a file.

The shipping examples that use a DAQmx Timing VI are the first three in the folder.  I would recommend Meas Angular Position-Buffered-Cont-Ext Clk.vi.

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 2 of 12
(5,493 Views)

Hello.

I am not limited to just analog channels. The NI USB-6211 has two counters and allows for z indexing. The angular position measurement uses both of my counters on the board so does that mean that I will be unable to use an internal clock or am I required to use an external trigger? When I write the angular position to a file how do I provide a time stamp to it? If I write an anaglog sample I just read my data as a waveform and that write the time and value but the counter does not offer that option.  

Noel

0 Kudos
Message 3 of 12
(5,488 Views)

Hello,

You can use either the ai/sample clock or ao/sample clock as the source for the DAQmx Timing.vi in the angular position example.  However, you will need to run an AI or AO task in the background to enable and configure the sample clock.  This would be considered a workaround to providing an external clock for this example. 

I notice you are interested in a time stamp with the data.  You are correct the angular position example does not provide timing data with the counter task.  If you decide to use the angular position example with the AI sample clock, we could synchronize the counter task with the AI task via a trigger. (This would place the AI task in the same code and would eliminate the AI task running in the background.) Since they are using the same sample clock, timing data can be shared.  Please let me know if you are interested in this setup. 

I also wanted to note that the angular position example does not official use two counters.  If you are creating the external clock by using a counter task to generate a pulse train, then yes the example will require two counters.

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 4 of 12
(5,466 Views)

It is nice that you mentioned running a AI or AO along with the angular poisition because that was my next challenge. I've been trying to build my VI in small steps because I'm so new to LabView. I have added an AI to measure a voltage but I don't understand how I will synchronize that with my angular position. I've tried putting in a timer but I get the following error when I try running this. Could you explain to me how I would sync these two?

Possible reason(s):

Measurements: External sample clock source must be specified for this application.

Unspecified Property: SampClk.Src
Channel Name: Dev2/ctr0

Task Name: _unnamedTask

 

Thank you

Noel

0 Kudos
Message 5 of 12
(5,462 Views)
Here is my VI
0 Kudos
Message 6 of 12
(5,461 Views)

I've pieced together some synchronizing from a random example posted on this message board. This seems to be giving me results that I am looking for but I was wondering if you could look at it to see if there is something redundant or inherently wrong.

0 Kudos
Message 7 of 12
(5,458 Views)

It gives me the output I am looking for but I've found out that it is only able to run for 10 seconds before giving me the following error.

Possible reason(s):

Measurements: Attempted to read a sample beyond the final sample acquired. The acquisition has stopped, therefore the sample specified by the combination of position and offset will never be available.

Specify a position and offset which selects a sample up to, but not beyond, the final sample acquired. The final sample acquired can be determined by querying the total samples acquired after an acquisition has stopped.

Attempted to Read Sample: 1000

Property: RelativeTo
Corresponding Value: Current Read Position

Property: Offset
Corresponding Value:


Task Name: _unnamedTask<33>

 

I don't understand what is causing this error and I don't know how to correct this error. Any suggestions?

Thank you

Noel 

0 Kudos
Message 8 of 12
(5,439 Views)
Please disregard that last post. I was getting that error because I forgot to set my sample mode as "continuous samples" for my sample clocks.
 
Noel
0 Kudos
Message 9 of 12
(5,436 Views)

Hello,

I do not think that you are doing any thing wrong or redundant.  I am assuming that you have already fixed the last issue so your external clock is the internal ai/sample clock.  I have attached a VI that has a slightly different sturcture than your last post.  Please review and maybe add your File I/O.  Please let me know if I am leaving any of your questions unanswered, since I am a little uncertain where you stand.

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 10 of 12
(5,432 Views)