I'm trying to simulate a rotary encoder with an USB-6212 multifunction IO device. This means that I want to generate two pulse trains with a 90 degree phase shift and with a fixed number of pulses, so not continuously ...... unfortunately this doesn't work on a USB-6212. Thinking that the USB-6212 has two counters that can be routed to a PFI pin I was under the impression that it should be able to work. However, I found out that a single output generating a pulse train with a finite amount of pulses already uses both counters so when creating the second channel a error happens with a message that the resources needed are already in use, see image below for what I wanted.
For two continuous pulse trains (see below) it works but this is not what I need.
There are a few things I have tried but they did not result in a usable outcome.
Is there an option to generate the needed finite pulse trains that I'm not aware of. I have no experience with USB DAQ devices and DAQmx and normally program for a cRIO based system. Changing hardware is not really an option given the (very) long delivery times now days.
Thank you in advance for your answers.
Solved! Go to Solution.
You'll need to borrow a controllable sample clock from another task and then set up your counter tasks in terms of "Ticks" of this known frequency. Here's a minimal example with hardcoded constants for the pulse timing params. You can make it more flexible by calculating them from the AO sample rate.
Oh wow, that actually works really well, it is possible to get an exact number of pulses at different rates by varying the combination of 'samples per channel' ,the number of high and low ticks and finally the initial delay. This is great.😊
I just changed the suggested AO task to an AI task as I already use both AO outputs and every time a pulse train is generated you also put some new data on there. But it works the same.
Thank you very much for the quick response, much appreciated.