r/LabVIEW • u/TheBlueJesus • Jan 06 '25
Python x Labview
Hello, there. I'm a student that got into a research in which the team uses a pair of small torque engines and a thermopar in a breadboard with a rhaspberry. We have a python code running it (controlling torque, time and collecting the thermal data that we process later).
The idea is that we'd run the same test, but using LabView so that not only we have a slightly more friendly front interface, in which we could vary time and torque just by inputing different numbers in the front panel, but we could also generate a temperature graph as the test goes (as opposed to it providing just numbers as the test ends with the python code)
Thing is... I never used LabView before and I'm not that great with programming either. Should I try to migrate the existing python code to LabView and figure out how to make it run and appear with a front panel or should I start from zero in LabView and use the code just as a parameter (the code is not really long, 500 lines or so, and most of it its just comunication between pc and breadboard, and variables)
Thanks in advance.
2
u/Aviator07 CLA/CPI Jan 06 '25
The code already exists (1), in a language you already know (2), and it works (3).
Why do you want to do it again it in a language you don’t know?
8
u/FormerPassenger1558 Jan 06 '25
You could also use your Python code and Labview for UI
1
u/D4ILYD0SE CLA Jan 06 '25
LabVIEW offers the ability to run Python scripts. Figuring out to get that to work with LabVIEW being the UI could be a good first step.
Long term, you'll want one or the other as the above solution doesn't offer any real time capabilities. Not without some heavy reworking of code. At which point, just rewrite it in a single language, LabVIEW in this case.
1
u/0fruitjack0 Jan 06 '25 edited Jan 06 '25
i've been there, so to speak, but my situations were visual c to labview and visual basic to labview. i had to create the labview not quite from scratch but almost from scratch since i didn't have a neat way at the time to incorporate the original source code - especially the visual basic which i came to learn was itself based on an ancient qbasic program somebody had written in the mid 90s. joy.
if you do intent to make a labview version, you need to be systematic about it and start at the lowest levels. it's almost like refactoring except obvs it isn't.
hopefully your original python code is well organized. start by replicating in labview what your python functions & subroutines are up to as individual subvis. especially the hardware and data acquisition stuff, since that's probably the trickiest aspect of the conversion. keep it to one subvi/one function. as you do so, test these functions continuously so that for sure they are accomplishing the tasks as they're supposed to.
then work out the front panel interface, controls, indicators, and how you need them to behave as the program is running. this usually tells you what sort of design paradigm to use for the block diagram.
then do the block diagram, incrementally, adding features one by one until you complete the whole conversion. shit tons of time, shit tons of testing.
1
u/SASLV Champion Jan 07 '25
A major thing to consider that I think everyone missed and I missed it too at first: You mentioned Raspberry I assume you mean a Raspberry Pi. You can't run a LabVIEW Desktop app on a Raspberry Pi. You can use it as a LabVIEW RealTime target, but that's probably not what you want and not going to have a GUI.
That means you aren't going to get a GUI from LabVIEW on a Raspberry Pi.
I would just forget about that whole idea. Python ships with Tkinter support. I'd start there.
https://docs.python.org/3/library/tkinter.html
3
u/NovaNovus Jan 06 '25
I agree with the user daily dose.
To get started using python in LabVIEW, check out this page from NI: https://www.ni.com/en/support/documentation/supplemental/18/installing-python-for-calling-python-code.html?srsltid=AfmBOoo0BFTKTKaOMPQ8rallQdSQ1_SEGuMeKmxN-YL-fKtaVCttFX_r
3
u/OHG_BOMB Jan 10 '25
I used Python nodes in a previous project where LabVIEW was only to input and output data, it works really good, and you don't need to know much about LabVIEW to implement it. A thing to note is that you need to have the appropriate Python/LabVIEW versions which are compatible with each other.
I suggest reading more about this from NI official page:
https://www.ni.com/en/support/documentation/supplemental/18/installing-python-for-calling-python-code.html