02-25-2025 08:25 AM
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!
02-26-2025 08:32 AM - edited 02-26-2025 08:40 AM
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
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
02-27-2025 12:06 PM
👍 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
02-28-2025 07:31 AM
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 😉