LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"0" value from AI (4-20mA) at the start of a program (needs to restart multiple time to finally work)

Solved!
Go to solution

Hi everyone,

 

I have a recurrent problem on my Labview VIs.

Actually I did two for recording and controling different lab equipment (probes, pumps, ...).

The problem is when I run the program most of the time there are probes that are giving no value "0". I have to restart the program multiple times to finally get the value. Once I have the value, the program can run without any problem for a few hours/days.

 

For both program, it was the same probes (same brand) on two different DAQ systems (1 from Advantech and 1 from NI). The other equipments that are controlled by the program seems to work (2 AO/AI mass flow controllers, 1 AO agitator, 6 other AO channels, 1 solenoid valve).

 

So either there is a problem with these particular probes, or I do something wrong when programming the VIs (I think the latter is more probable...).

You will find below the typical program I am using.

Do you see something wrong there?

Would you have any advice for me? Should I modify some parameters?

Thanks a lot!

 

Iforire_1-1726128925062.png

 

 

 

 

0 Kudos
Message 1 of 6
(334 Views)

Hi lforire,

 


@Iforire wrote:

Do you see something wrong there?

Would you have any advice for me?


  • Why do you need to convert an array (of 2 elements) into a cluster of 9 elements to unbundle the first two elements???
  • Why don't you use IndexArray when you want to index elements of an array???
  • Why don't you clean up your code? (Straight wires…)

@Iforire wrote:

The problem is when I run the program most of the time there are probes that are giving no value "0". I have to restart the program multiple times to finally get the value. Once I have the value, the program can run without any problem for a few hours/days.


Which "probes" are you talking about?

(Why do you expect "0" values at AI channels when you start your VI?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(304 Views)

Hi GerdW,

 

Thank you for your answer.

And sorry for not being crystal clear.

The image is an example, the full VI is more complex so I simplified it to the maximum so it can be better understood.


@GerdW  a écrit :
  • Why do you need to convert an array (of 2 elements) into a cluster of 9 elements to unbundle the first two elements???
  • Why don't you use IndexArray when you want to index elements of an array???
  • Why don't you clean up your code? (Straight wires…)

Yes indeed this is silly, in the final VI, I am using IndexArray, but not everywhere, I will modify that.

What do you mean by "clean up the code"? Actually my final VI is a total mess, I really need to improve that and need to learn how to do clean my code. I am gonna look for some tutorial (if you have some, I will be glad if you can share them!)

 


Which "probes" are you talking about?

(Why do you expect "0" values at AI channels when you start your VI?)


Sorry my English is not always good. When I say probes it's the pH and temperature sensors. There are a few others I am using that do the same thing. And they are of the same brand.

 

Actually, I do not expect to have a "0" value when starting the VI but a real value between 4 and 20mA. 

And something important, when I get "0" when starting the VI, it does not change and stay "0", so I cannot read the sensors values and I need to restart a few times before it can work. 

Thanks

0 Kudos
Message 3 of 6
(295 Views)

Hi lforire,

 


@Iforire wrote:

What do you mean by "clean up the code"? Actually my final VI is a total mess, I really need to improve that and need to learn how to do clean my code. I am gonna look for some tutorial (if you have some, I will be glad if you can share them!)


There is a "Style Guide" chapter in the LabVIEW help…

 


@Iforire wrote:

Actually, I do not expect to have a "0" value when starting the VI but a real value between 4 and 20mA. 

And something important, when I get "0" when starting the VI, it does not change and stay "0", so I cannot read the sensors values and I need to restart a few times before it can work.


DAQmxRead will give you a "constant 0" when there is an (upstream?) error. Are there any errors?

 

(We cannot debug your VI without your hardware, so you need to do that on your own!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(274 Views)
Solution
Accepted by Iforire

As was somewhat mentioned above, you're probably getting an error but the error is hidden so you don't see it.

 

To give more concrete instructions on what to do:

 

  • In your While loop, add a Boolean "Or" node between the "Stop button" and the "Stop" for the loop. 
    • One input should still be for the stop button, and the other one should be the error wire coming out of the DAQmx read VI.
  • At the very end, after the Clear Task VI, add an "error out" control wired up to the error output of the Clear Task VI.
  • Run your code again
  • This time, if you get zeroes, the code should stop itself right away, and you will see an error code and details in the "error out" control.
    • Take that code and those details and either do a web search or forum search on them, or post them here.

 

0 Kudos
Message 5 of 6
(243 Views)

Thank you Kyle for the suggestion. It gives me multiple errors I need to investigate!

0 Kudos
Message 6 of 6
(201 Views)