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: 

Two fixed lenght pulsetrains on a USB-6212

Solved!
Go to solution

Hello,

 

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.

 

Floris_1-1654260941565.png

 

For two continuous pulse trains (see below) it works but this is not what I need.

 

Floris_0-1654260491748.png

 

There are a few things I have tried but they did not result in a usable outcome.

  1. Toggle digital outputs in a software loop, this was not fast enough to give me a 500Hz pulse train
  2. Use continuous pulse trains, start the task, use a wait function the length of the needed pulse train and stop the task. Well, this was not very stable and resulted in quite a bit of jitter in the number of generated pulses.
  3. Tried something with user events based on a edge change detection of an input (routed the continuous pulse train to an input) and then just toggle a digital output. It seems the USB-6212 has no hardware for change detection and as I have seen in the first point above it will be too slow I suspect.

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.

 

Best regards,

  Floris

 

0 Kudos
Message 1 of 3
(832 Views)
Solution
Accepted by Floris

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.

 

 

-Kevin P

 

Kevin_Price_0-1654266398437.png

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 3
(816 Views)

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. 

 

 

0 Kudos
Message 3 of 3
(764 Views)