03-25-2010 03:58 PM
Hi,
I have a PCI-6221 board with a BNC-2110 DAQ box and LabVIEW 2009. I also have a quadrature encoder with A, B, and Z index outputs. I have successfully created a VI block of Input -> Counter Input -> Edge Counter and a numeric output display in a while loop. When I connect my encoder's A channel to PFI 8 (Labview told me to in the block) I can count the encoder clicks in the "count up" direction. It will not work in count down direction. I repeated this with channel B connected to PFI 8 and it works the same. When I select "externally controlled" count direction, and wire A to PFI8 and B to P0.6, the clicks jumps to 4 billion or so upon first movement and then decrease no matter the direction the encoder turns.
Can someone help with how I am supposed to wire this? I put channel B to P0.6 only due to things I have read online. I am new to working with Labview and encoders. All I want to do is get directional counting and then convert that to distance traveled. (500 clicks = 6.000 inches for my encoder)
Thank You,
Steven
03-25-2010 06:13 PM
Hi Steven,
The following chart shows the default terminals for M Series devices and should help you out as far as connecting signals goes:
Using default terminals, B should be wired to PFI 10 for the AUX line (you may also select p0.6 if necessary but this is not the default).
One other thing to point out... instead of an Edge Count task with an external direction control I would use an Encoder Task (the connections should be the same: A goes to PFI 8 and B goes to PFI 10 for counter 0). The Encoder Task will allow you to use the Z index among other things. The Measure Angular Position.vi shipping example is a good starting point and can be found at:
Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Counter Measurements >> Position >> Measure Angular Position.vi
If you have any questions or run into any issues don't hesitate to post back!
Best Regards,
03-26-2010 10:33 AM
Hi John,
I have tried to work with that VI but my BNC - 2110 DAQ does not have a PFI 10 listed on it, only PFI 1 to 9. I see the DAQmx and has a linear encoder configuration which would be helpful, but fail to see where the physical channel defaults are listed, or how I can change them to channels that are actually on my DAQ. Where is this option? Also, I am confused as to why there are three DAQmx boxes, one inside the loop and two outside in that VI.
Thanks,
Steven
03-26-2010 10:47 AM - edited 03-26-2010 10:48 AM
Hi Steven,
The linear encoder task will use the same default lines as the angular encoder task which I posted earlier (for A, B, and Z inputs). The 2110 should have PFI10 on it--the digital section of your terminal block look should like this:
If desired you may change the PFI lines to be used with a DAQmx Channel Property node, it would look something like this:
The VI is set up so that the configuration of your DAQ device takes place once (before the loop). Then, counter is polled continuously inside the loop. The task is then cleared after the loop.
Best Regards,
03-26-2010 03:22 PM
Thank you, I was able to get my encoder set up now with all three channels working. I took out the metronome inside the loop and noticed my readings were taken faster, did the metronome time the execution of the loop? And finally, could you recommend a way to output these results to a spreadsheet? I have tried the write to spreadsheet block but it did not want to take the output of the counter inside the loop.
Thanks,
Steven Porter
03-29-2010 05:45 PM
Hi Steven,
The metronome is called the Wait Until Next ms Multiple and it does control the speed of the loop. As far as writing the data to spreadsheet, it depends what kind of timing you need. If you need hardware timing, you will have to implement a buffered counter task. There are examples of how to do this in the Example Finder, located at Help >> Find Examples. When this opens, double click Hardware Input and Output >> DAQmx >> Counter Measurements >> Position>> Meas Angulaar Position-Buffered -Cont Ext Clk.vi. This VI will allow you to create a hardware timed acquisition using an external clock. You will have to create an external clock using the other counter on the board then route the signal either externally or internally. I have modified the example to give you an idea of how to do this.
You can then write the array to a spreadsheet file using either the Write to Measurement File Express VI or the Write to Spreadsheet File VI.