From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-10-2023 04:16 AM
Hello,
I am using NI-DAQ PCIe 6323 for my PWM signal generation. I have implemented the attached code snippet to generate a single PWM at a DO using Labview. For my experiment, I have to drive LEDs using a DO at 10-15 Hz using a PWM. But I also have to control their brightness using another PWM varying between 5-100KHz. I was thinking of making two counter signals, one to generate a PWM of 5-100KHz continuously at the DO and another one to turn the DO on or off based on the 10-15Hz PWM. I don't know if this is possible. Please suggest me some way.
Thank you.
Solved! Go to Solution.
05-10-2023 04:35 AM
I tried something like the attached code snippet, but I'm not sure if it will work and I don't want to damage the DAQ. I just implemented the same code for PWM and generate two PWM but output both of them at the same Digital Output pin. Could anyone please confirm if it looks ok?
05-10-2023 08:24 AM
I don't think that you can specify the same output terminal from two different tasks. Most likely you are going to get an error stating that the terminal has been reserved. If you don't have an actual hardware yet, you can test your code with Simulated NI-DAQmx Devices
05-11-2023 04:40 AM
You were right about the error ZYOng. I tried simulating and the code does throw the error that resources are currently in use by another route.
Do you know if I can trigger a counter based on another counter? Maybe I can output just one counter to the DO but control that counter using another counter!
Thank you.
05-11-2023 08:54 AM
@yp96 wrote:
Do you know if I can trigger a counter based on another counter? Maybe I can output just one counter to the DO but control that counter using another counter!
You can create a re-triggerable counter output task in which the start trigger is routed from another counter. You can refer to the Generate Digital Pulse With Retriggerable Digital Start Trigger from Archived: Download Legacy NI-DAQmx Shipping Examples for LabVIEW 2011 and Earlier
05-11-2023 10:34 AM - edited 05-11-2023 10:38 AM
So I tried controlling the second counter by providing the Ctr0InternalOutput as the source for the second counter sample clock. I also set the task as Retriggerable. But I got the error as 'Generation cannot be started, because the selected buffer size is too small. Increase the buffer size.'
Please check the attached snippet and let me know what you think.
Thank you.
05-11-2023 02:16 PM
For unknown reasons, I am not able to import your snippet hence I cannot modify your code directly. Here is my recommendation:
1. Use Implicit Timing for both tasks. You don't need to use the sample clock here.
2. On the second higher freq task with re-triggerable enabled, configure a Digital Start Trigger in which the source of the trigger is Ctr0InternalOutput. We are re-triggering the generation of the high freq pulse train on each incoming pulse from the lower freq counter.
3. Start the higher freq task first before you start the lower freq task. The higher freq task should be ready to receive the trigger before the lower freq task starts generating pulses.
05-12-2023 04:05 AM
Thank you ZYOng. Your suggestions seem to be working.
I tried to confirm it using NI-MAX Test Panels for my simulated device. While my LabVIEW code is running, if I try to use those counters or the PFI pin in the test panel, it throws an error saying 'Resource requested by this task has already been reserved by a different task'. I think that means the code is actually using the resources. I have also attached the snippet for future reference. I hope it will work on the actual hardware now. 🙂
Thank you again.
05-18-2023 11:06 AM - edited 05-18-2023 11:09 AM
Just a minor update. Instead of using a digital start, I had to use a digital pause. The digital start did start counter 2 with a rising edge of counter 1, but it will not pause counter 2 when counter 1 was low, so instead I added pause when low. There are still some issues with syncing at different frequencies, but for now, it serves the purpose of my main question of driving one counter using another.