01-31-2019 08:28 AM
hi all,
I've created a VI which creates a finite pulse train, which is send to my NI-USB 6251 DAQ box.
The frequency, duty cycle, and number of pulses are input variables. The pulse train is retriggerable via a digital input.
Let's say i want to send initially 2500 pulses at a 1000 Hz; after this, i want to send 5000 pulses at 500 Hz.
The software does allow me to change the values but, it still deals with the initial values (2500 pulses, 1000 Hz).
I've tried different things, but i'm lost now. I think I'm making a beginners mistake, can someone help me out?
Solved! Go to Solution.
01-31-2019 06:51 PM
I am going to make an assumption here based on that huge Wait you have.
You are clicking "Run" and then the code runs and send the first pulse train. Then there is a digital trigger received and it sends it again. You change the front panel controls while the program is running but still the train is the same.
The problem is that the task is configured at the start, before that loop. Those front panel controls are only read once, before the loop. If you want to change the task, you need to clear it and start over while the program is running. So in this case you could put all of that code inside your while loop. You might want to look into different architectures for a more complicated program (such as using the Event structure), but that should at least get it working the way you intend.
02-01-2019 01:26 AM
That huge wait was because the initial program (somewhere from the forum i thought) restarted the pulses, without me triggering it.
with the retriggerable option, that's no longer necessary. I've set the wait function to 1000 ms now.
i can't place all of that code inside a while loop, because it then says:
"finite acquisition or generation has been stopped before the requested number of samples were acquired or generated (warning 200010)"
So i guess it leaves me with the Event structure then?
02-01-2019 02:58 AM
Hello Edwin,
pauldavey is right, the issue with your posted screenshot is that you try to reconfigure a task that has already been configured and from the code structure will never read the newly configured values.
Putting the whole DAQ task into a while loop you ran into the issue that the task is running on the hardware, and your software running on the PC is not really aware of it. Or, putting it in other words: You are using the "Is Task Done?" node. But when is a retriggerable task finished? Never?
Before I can give advice, I need to know exactly what you need.
- Do you need the pulse train retriggerable? Is this trigger coming from your Pulse Train Button? Or from an external signal?
- If from your Front Panel button, then you can use a less cumbersome approach.
- What shall your Pulse Train look like? Let's say A is 2500 pulses @1000Hz, B is 5000 pulses @500Hz, and R stands for a re-trigger. Shall it be AB RAB RAB,[...] or A RA RA [...] B RB RB [...]?
Apart from that please post your VI. It's hard to guess what you are doing without knowing the FrontPanel and several settings that one cannot see on a screenshot.
02-01-2019 03:40 AM
Hello ikaiser,
i've attached the VI, so front panel and block diagram are available.
with the pulse train button, i want to start the pulse train. if this finite pulse train is ready, i want to be able to start a new pulse train, but with a different number of pulses, or even with a different frequency.
I use a digital output for the trigger, which is read by the 'start digital edge'. If it is possible to do it within the software, that would be great.
02-01-2019 04:54 AM
Hello Edwin,
thank you for the additional information. As you start the counter output by software (clicking the button on your frontpanel), you don't need to do the detour through a hardware trigger. Also, as you want to potentially change the whole configuration for every run, you need to be able to reconfigure the whole task every time.
Have a look at the attached demo VI. I got rid of the whole trigger part, instead simply creating the DAQ task every time you click the button with the current settings. for convenience I used an event structure like you mentioned before. I put the "Block Time" part into another event, setting up this Task before, and clearing it afterwards.
Please note that I also inserted the Clear Task vis that were missing for some of your tasks before, and now the program fully terminates when you click the stop button.
Please note also that I have not tested this VI ad I don't have your hardware. So use this VI only as a start, not for actual use. There are other ways to implement the functionality you use, however this version should give you a good impression of a working solution.
My main concern about my implementation is, that the Pulse Train Event Case "hangs" as long as the Pulse Train is being generated. This can easily be solved by using this case to just start the generation, and disabling the Start Pulse Train button at the same time. Then Checking regularly in the Timeout case if the Generation task has finished, enabling the Start Pulse Train button again if it has. However, this would make the Block Diagram a bit more complicated, so I decided to not do that in this first example.
I hope this helps.
02-01-2019 06:55 AM
Thanks for your help and time.
It works on my hardware, and it covers what've requested.
I think this helps me to continue!