From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using counter and output at the same time

Hi all,

 

I'm using a NI 9401 high speed digital IO module (with a cDAQ 9174 chassis) that has 8 digital IO channels, to perform two tasks at once in Labview. I can get both of them to work independantly, but when I put them together to run simultaniousy in parallel, it does not work. My two tasks are simple: 1. Generate a continious pulse train square wave output using one of the counters linked to one of the output channels (PFI7) and 2. Output a 'high' (5V) with one of the other channels (PFI1)  when a certain logic condition is met.

 

When I run my code (attached), the pulse train output works, but the output on the other channel doesn't work when the logic condition is met. I should note that the logic condition is that when RMS current exceeds 3A, I want to output a 'true'. I am measuring current using another analog input card connected to the same chassis and this part is all working well. I think the problem is that there is some sort of interference between the pulse train output which is linked to PFI7 and the other output which is PFI1.

 

I know there is a limitation with the 9401 card that if the channels are in two groups, 0-3 and 4-7, and you must use a whole group as either all inputs or all outputs, but I don't think this should affect me, as I am using both my channels as outputs anyway, plus I am using channels 1 and 7 anyway.

 

If anybody has any ideas as to what could be wrong with my code, I would greatly appreciate it.

0 Kudos
Message 1 of 6
(3,181 Views)

Take a look at this article and see if it gives you any ideas: https://decibel.ni.com/content/docs/DOC-5765

 

 

Kenny

Message 2 of 6
(3,165 Views)

OK, you've shot yourself in the foot.

 

It is a very bad idea to modify the shipping examples.  Like testing bungee cords by juming off a cliff-  sometimes you only get to try it once.

 

Now why on earth did you not add the DI code following the example's method of wiring the error chain and closing the task after the loop?  You have duplicated code in both cases of your case structure the only difference.........(wait for it..........) There is a true constant in the true case where the false case contains a false constant.  A wait for task complete is unnecessary for a 1 sample DI task-  really the write just completes and the task stops all by itself.  the only needed thing here is a DI Write 1 Ch 1 Sample no case structure, and wire the compare output to data to write.

 

You should probably add a control task vi with a "Reserve" input prior to each start task on the CO and  AI Tasks and after the Create Task on the DO.  Its a bit technical but the result is like taking vitamins- you'll just get better performance.


"Should be" isn't "Is" -Jay
Message 3 of 6
(3,145 Views)

Thanks for the comments guys, I've implemented all of the suggestions into my code. I worked out that my code wasn't working because there was a clash with the outputs. ctr0 has to be linked to PFI3, and for the digital output I used PFI7. This seemed to fix the program.

Message 4 of 6
(3,116 Views)
sorry if any of my comment sounded a little bit harsh

"Should be" isn't "Is" -Jay
Message 5 of 6
(3,106 Views)

No problem. I didn't think they were harsh.

0 Kudos
Message 6 of 6
(3,095 Views)