LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Python Node Return Value/Output

Solved!
Go to solution

How do I specify four inputs to a Python node (call them a, b, c, and d) and return just one value (call it e) which is calculated in Python based on the four inputs, but not a direct terminal pair return value of the four inputs? I tried wiring from the "Return Value" terminal, but this just returns the value of the control wired to the "Return Type" terminal. I have attached a snip from my block diagram for reference. 

0 Kudos
Message 1 of 7
(5,077 Views)

Based on what I understood from your question, exactly how you showed it should be fine for LabVIEW.

Can you post a simplified version of your Python code?

 

Also, what do you mean by "not a direct terminal pair return value"?

 

In the last part, you're mentioning it returns the value of the input data type terminal. You got this even when the value was not the "default default value" (i.e. 0 for doubles, false for boolean)?

 

I also guess you'd have mentioned this if there was an error, but can you confirm you don't see any errors in the indicator you showed?


GCentral
Message 2 of 7
(5,069 Views)

For some reason everything is working fine now. For a while, I was getting an output equal to the input I had wired into the "Return Type" terminal, but that is no longer the case. For example, I had the ambient pressure of 14.7 as the first input to the Python Node and also had split off from this to wire to the return type terminal. When I ran it, my output was 14.7. Now, I am no longer having that issue so I'm not sure what was going on there. 

 

What I meant by "not a direct terminal pair return value" was that my output is not just one of the inputs with some math applied to it. For example, my output isn't 2*InputA, but rather a result of the four inputs. 

 

It had been returning the value of the input data type terminal when I had it configured as the picture attached shows, but now I have it the exact same way and it is working fine. I'm really not sure what was going on here. 

 

I did not see any errors on the indicator. 

 

It's a little concerning we can't explain why one minute I had an issue and the next it worked fine, but it works!

 

Thanks for taking the time to help!

0 Kudos
Message 3 of 7
(5,051 Views)
Solution
Accepted by zhale

Well, I'm glad it's working out now. Blindly guessing, I'd say perhaps your Python script was being difficult about something, especially if it's a bit more complicated.

 

Python can be picky about a whole range of things, or perhaps you had the script open and were making changes but they weren't saved, then you ran LabVIEW's code, and got a wrong answer. When you saved it (or closed it, and it saved, etc) and tried again, it worked.

 

In any case, hopefully it continues to work as you expect. Good luck (and consider dropping the Dynamic Data Type wires if you can - they almost always seem to be the cause of endless troubles...)


GCentral
Message 4 of 7
(5,043 Views)

Thanks! I'll try to drop the Dynamic Data Type wires as well. 

0 Kudos
Message 5 of 7
(5,033 Views)

I am having the same issue with the indicator for the return value just showing the value of the control I used as a return data type.

 

Did you ever figure out what the issue was and why it suddenly started working properly?

 

 

0 Kudos
Message 6 of 7
(2,138 Views)

I think I've figured out the issue(s) (at least some of them).

 

The file directory path shouldn't have any spaces

 

Try running the code as a python script first to ensure you're getting what you would expect as well.

 

Mine is working now after fixing those 2 things.

0 Kudos
Message 7 of 7
(2,135 Views)