04-26-2015 07:59 PM
I'd like to use a position encoder to trigger a line scan camera. I have a NI X Series PCIe board that I am using for AO, so if possible I am hoping to use it for triggering from the quadrature signal.
Following tutorials online, I can easily read the position of the encoder with the X series. However, less clear to me is if I can feed the position data to another counter such that every X net distance I get trigger that can be routed to the camera? Obviously I could just read one phase and trigger from that, but I'd be sensitive to false counts while the device was stopped or dithering. If this is possible, could someone suggest the approximate way to do it or provide an example?
Thanks!
Mike
04-27-2015 04:45 PM
The following NI Community example provides a method for triggering a counter with another counter.
'NI Community: How Trigger Counter and Analog Input Simultaneously'
https://decibel.ni.com/content/docs/DOC-30013
04-27-2015 05:01 PM - edited 04-27-2015 05:03 PM
Unfortunately, I can't open labview 12 files, so I'm not sure exactly what that example does.
04-27-2015 05:33 PM - edited 04-27-2015 05:33 PM
You can configure a counter to issue a pulse every N encoder ticks in a somewhat roundabout manner.
Use Z indexing to reset the counter to a known value (the encoder interval between your triggers) every time the Z index signal is received. Use the counter's own internal output as the Z index signal. When the counter reaches 0, it will issue a pulse on its output, resetting itself back to the desired interval and starting the process over again. It will only fire in one direction--make sure A and B are such that the counter is counting down while travelling in the direction in which you wish to fire.
You may export the counter's internal output to a PFI line directly (the pulse is short though so you'll probably need to use it to trigger a second counter output that generates a longer pulse, or if you were talking about just using this to trigger the analog output then there wouldn't be any issue).
I'm using this in one of my applications and can verify that it works on X Series (PCIe-6320 and PCIe-6351). Here is a screenshot of how I am configuring the counter task (I have digital filtering in there for good measure so that the input signals are synched to the internal timebase / Z index signal, I'm not sure if it's necessary or not):
Best Regards,
04-27-2015 06:26 PM
Hi John,
Thanks for the detailed reply. I'm not great with labview, but I should hopefully be able to manage. One question though, when I try this, I get an error routing the counter output to the Z index:
Source terminal to be routed could not be found on the device.
Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names.
Property: CI.Encoder.ZInputTerm
Source Device: Dev2
Source Terminal: Dev2/ctr0/InternalOutput
I'm on the pcie-6323, which I thought should be the same as your 6320. Looking at the device routes in NI MAX, this route is permitted, so I am probably doing something wrong.
04-27-2015 07:08 PM - edited 04-27-2015 07:10 PM
Sorry, had the backslash in the wrong place. Now it works.
Thanks!
04-28-2015 11:40 PM
I'm not great with labview (only used daqmx through the c or .net interface), but I tried putting together an example to see if it would work:
Unfortunately I get no output on the Ctr2 Out (which is PFI 14 on the 6323). If I run a counter example program, I do see ticks being registered on those PFI lines, so I assume I'm wired correctly. Any idea what I'm missing?
04-29-2015 09:12 AM
Sorry I left this out of my original post, if you want to export the counter output directly you can do so with DAQmx Export Signal.vi
In my program I'm using the counter's internal output to trigger another task.
Best Regards,
05-02-2015 03:57 PM
Thanks, that fixed it. In case anyone is interested, here is the complete working example:
I tested and it produces a uniformly spaced (in distance) sampling waveform as a linear motor accelerates. I added the data indicator for completeness. One note: in X4 mode it actually counts full cycles as far as I can tell, not individual edges, so to do one trigger per 100 edges, you have to divide by 4 (hence the 25 above).
06-19-2015 12:29 PM - edited 06-19-2015 12:30 PM
I've implemented this method, and while it mostly works, it often fails and generates just a single trigger after which it will not respond until I've reset the counter. I was surprised, so I investigated and what I've found is that when it works, the counter iterates between 0 and the value counting down from, but when it fails, the value hits zero, generates the trigger event, but does not reset and instead counts down towards negative infinity.
So after triggering when the hardware is working, the counter value might be:
9
5
1
But when it fails, I get:
-2129122
-193333
-23743
Anyone have an idea how this is possible? My understanding is that it should be impossible to go below zero given that the Z-index value will reset the counter when it hits zero.