Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog output synchronized with external signal

Dear all,

I’m struggling with what initially seemed like a simple task, but I haven’t been able to find a working solution. I have an external 10 kHz signal generated by a microcontroller timer, and I need to update four analog outputs at each rising and falling edge of this signal. The output values will be read from a CSV file, though that part shouldn’t be an issue.

I’m using a USB-6343 and have attempted various implementations in both Python and LabVIEW without success. I also tried the approaches discussed in these threads:

Unfortunately, none of them worked for my case (or I could not modify them properly).

Could you guide me toward a solution or provide some example code? I have experience with MATLAB and Python but am relatively new to LabVIEW, and I’d like to learn and understand how to achieve this properly.

Thank you!

0 Kudos
Message 1 of 4
(206 Views)

Not able to test it in real, but have your tried something like this:

read a digital port with change detection (and ignore the read result) and use the change detection event to clock the output

change detection.png

don't know if the read is really needed if one could commit the digital change detection setting..

 

if the csv file is big, I would use an independend loop to read the file in blocks and use a pipe to stream it to the daq-write

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 2 of 4
(183 Views)

👍 I heartily endorse Henrik's suggestion.  Change detection is the key technique when you need to respond to both rising and falling edges of the same signal.  Just a couple little "food for thought" comments:

 

1. Setting up change detection purely for its "Change Detection Event" signal and then reading but ignoring/discarding the data is a fine approach.  I might suggest you wire the magic value -1 to be the # samples to read because that means "read all samples available at the moment".  Such an approach will probably be a little more robust and universal across a wider range of sample rates, etc.

 

2. Another approach I've taken is to configure a DAQmx Property node that allows the DI task to "overwrite unread samples".   (I *think* it's a Read property, but can't check now.  If not, look under Channel properties instead.)  Then you don't even need to do any DI reads inside the loop at all.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 3 of 4
(170 Views)

Just saw a  minor bug in my code, the coarse sampling frequency should be 20k not 10k , since both slopes of a 10kHz square are expected 😉

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 4 of 4
(162 Views)