03-07-2016 03:08 AM
Hello guys. I want to trigger a counter of NI USB-X 6353 by pressing a button on the front panel to generate a finite pulse. To do so, I made a vi but I am not sure whether it is a good or not. I tested it on a simulated device, it works. I just want to know your suggestions on it. Maybe, there is a better way to do it. Thanks, in advance.
03-07-2016 03:11 AM
03-07-2016 03:54 AM
Hello GerdW,
You are right, it can be problematic. So, does deleting the stop task vi make it better?
I want this counter to be retriggerable from the front panel button, that's why I use latch button and reset. I thought that using latch button can be problematic in terms of loop speed. Which button mechanical action is more suitable?
I have changed the vi according to your suggestions. What do you think? Instead of case structure for retriggering, utilizing an event structure is better or not?
Thank you very much.
03-07-2016 03:58 AM
Hi Engeman,
- when your VI depends on the state of your CTR task you can read it's state using "DAQmx Task Is Done?" function…
- in your first image you used a switching button as latched buttons don't allow local variables…
- why do you use InsertIntoArray when all you need is BuildArray?
03-07-2016 04:34 AM - edited 03-07-2016 04:35 AM
Hi GerdW,
-Actually, my VI does not depend on the state of this finite counter generation. I use this counter to send a finite signal to trigger a device to generate high voltage. I want to trigger this counter manually while other counters and AOs or AIs are still operating. I also change this part like in the screenshot. Is using a stop vi better or not in this way?
-I have changed the mechanical action of that button from switching to latch one.
-I use insert into array because, sometimes I stop the whole vi, so it is possible to lose previous values, and as I said I can use that counter as retriggerable. If I use buildarray, I can lose old values, I thought.
03-07-2016 09:46 AM
@newbieeng wrote:Hi GerdW,
-I use insert into array because, sometimes I stop the whole vi, so it is possible to lose previous values, and as I said I can use that counter as retriggerable. If I use buildarray, I can lose old values, I thought.
That's not the answer to the question.
The question is why are you using Insert Into Array rather than Build Array? Build Array should be used about 95% of the time, Insert into Array 5% of the time. When you know you are going to build data onto the beginning or end of an array, then Build Array is the correct function to use. It is very straightforward. Only use Insert Into Array if you need to insert elements into the middle of an array.
03-08-2016 03:28 AM
Hi RavesFan,
I got the point. I misunderstood the functionality of the buildarray function. Thank you.