Mahbod Morshedi Posted November 28, 2021 Report Share Posted November 28, 2021 (edited) Hi All, I am a Physical Chemist and am just starting Labview (a long way to go, as you may suspect). I would need to do a lot of Daq and DPS but with a low budget (using Arduino and NI-Dev boards for my projects). I would like to have the option of going hybrid programming (text-G) and since I do not have much programming experience i wanted to know which one would suit my purposes better, C/C++ or python. I have worked with formula nodes, and it is easy for making base computations and mathemathical formula and I was sad by the fact that you either have to use C/C++ syntax or Mathscript as in Math nodes; meaning MatLab inside labview codes. I am fully willing to put work in if C/C++ is the answer, but I wanted to know which should I pick? I really appreciate any help you can provide. Cheers, Mahbod Edited November 28, 2021 by Mahbod Morshedi Quote Link to comment
ShaunR Posted November 28, 2021 Report Share Posted November 28, 2021 There are Python primitives that enable you to work with Python scripts; there is no Python Node like the Formula Node. Search the examples for "Python". Quote Link to comment
Mahbod Morshedi Posted November 28, 2021 Author Report Share Posted November 28, 2021 Thank you for your reply ShaunR, Indeed, I already know about python's prim itive connections. However, this does not answer my original question. The question was if I have to put my efforts into a text-based programming in combination with LabVIEW for my particular needs, which would be a better option, C or python, given that MatLab (price-wise) is out for me? Cheers, Quote Link to comment
sam Posted November 29, 2021 Report Share Posted November 29, 2021 Hi Mahbod, Why do you even want to use LabVIEW? What I'm getting it is we need to know your requirement and train of thought better to help in "detail". Here are some ideas to get you started. Use C as dll and have LabVIEW as overall programming language Use Python as script and have LabVIEW as overall programming language Use LabVIEW as script and use Automation ActiveX from other languages to call LabVIEW. many examples if you google it use Dot NET, C# . coming back to my first question. DAQ or any HW access is not going to be an issue. so ... you see so many different ways are present but details matter . Quote Link to comment
jacobson Posted November 29, 2021 Report Share Posted November 29, 2021 I would generally suggest just using the language you're most comfortable with. I think Python is generally easier to integrate with but you are limited in data types (no classes). If you're just doing some signal processing though that may be able to develop an interface around that limitation without much difficulty. I also don't think LabVIEW supports the ability to call Python from a specific virtual environment which is definitely annoying. I think the C/C++ integration is a little less straightforward than Python but if you're comfortable with the language and you read the help documentation on the Call Library Function Node and how LabVIEW stores data in memory it's not that bad. You may also have to mess with some LabVIEW memory management functions which can be annoying the first time you use them. Quote Link to comment
Mahbod Morshedi Posted November 29, 2021 Author Report Share Posted November 29, 2021 Hi Jacobson, Thank you for the advice. I think the way it goes; I may have to just suck it up and go with C/C++. I have used call DLLs from Labview very briefly, and I know it works, and from What I have seen, G language in its core does the same thing for many of its VIs. Cheers, Mahbod Quote Link to comment
Mahbod Morshedi Posted November 29, 2021 Author Report Share Posted November 29, 2021 Hi Sam, A very fair question that I have been struggling to answer too. I am (at the moment developing a z-scan experiment which in reality an f-scan, focal point scan using an Optoune variable focal lens, the driver of which is written in LabVIEW). Apart from that, I am an electronic enthusiast (just starting, really) and have a few additions to the project in mind; and instead of using commercial systems, I want to build them myself using Arduino (not yet FPGA, and I don't think I have the talent or the knowledge to touch DSP processors). That is why (since LabVIEW mostly have made the job of DAQ easier) I think I would be using Labview as the primary language and call either scrips or DLLs from within the Labview programme. As you can guess, I am not a programmer (just a chemist), but I would love to develop my own experiments. So far, I have been developing with existing pieces of equipment, but I am keen to learn how to make some of them myself. Maybe I am taking the wrong approach here, and if so, please feel free to let me know. Cheers, Mahbod Quote Link to comment
JKSH Posted November 30, 2021 Report Share Posted November 30, 2021 2 hours ago, Mahbod Morshedi said: I am not a programmer (just a chemist), but I would love to develop my own experiments. So far, I have been developing with existing pieces of equipment, but I am keen to learn how to make some of them myself. One thing to keep in mind: LabVIEW and Python are high-level languages, while C and C++ are low-level languages. High-level languages are easier to get started with, and they provide some protection against common errors. For example, if you use an invalid reference in LabVIEW, you get a helpful error messsage telling you where the issue is; if you use an invalid pointer in C/C++, you could get silent memory corruption. Low-level languages can be more powerful and efficient if you know how to use them properly. However, it does take a lot longer to learn them properly. Whichever path you choose, the guidance of an good experienced teacher can get you further and faster then online tutorials. 1 Quote Link to comment
Mahbod Morshedi Posted November 30, 2021 Author Report Share Posted November 30, 2021 Thank you, JKSH, For the comments, and I hear you. Unfortunately, having a tutor is out of the question, no low-level programmers at the research school of chemistry. But I will take your advice to heart. Cheers, Mahbod Quote Link to comment
Rolf Kalbermatter Posted November 30, 2021 Report Share Posted November 30, 2021 (edited) Despite having created LabPython about two decades ago, I always prefered to go with C. LabPython (and Python itself too) are also written in pure C. One reason I think is that Python is also a high level programming language like LabVIEW. What I could do in Python I could also always do in LabVIEW, but certain things are simply not really possible (or at least not with reasonable effort) in both of them and require a lower level language. But C(++) is quite a different thing to work in for sure. It gives great power and control but that comes with great responsibilities too. While you have to really try hard to crash a LabVIEW or Python program, it's a matter of seconds to do that in C(++). This means programming in C is a little different than doing the same in LabVIEW or Python. If something goes wrong in your C program or library it is often not just an error code that is returned, but your test program simply dies without any warnings, questions or dialogs if you would maybe like to save your intermediate data results. In LabVIEW you get typically an error cluster out, look at it, determine where the problem is, fix it and start your program again, without any need to completely start LabVIEW itself again or sometimes even restart the whole computer just to be sure. Once you are used to that, it is not really much different anymore, but it is certainly something to be aware of before making the decision. Edited November 30, 2021 by Rolf Kalbermatter 1 Quote Link to comment
Mahbod Morshedi Posted December 1, 2021 Author Report Share Posted December 1, 2021 Thank you Rolf, Great comments. I think I will be going with C++ as well; as I said I am willing to put the work in and am not in a rush I will take my time, since there are many other things I need to learn along side this, such some electronics. Cheers, Mahbod Quote Link to comment
JKSH Posted December 1, 2021 Report Share Posted December 1, 2021 On 11/30/2021 at 12:06 PM, Mahbod Morshedi said: Unfortunately, having a tutor is out of the question, no low-level programmers at the research school of chemistry. Does your institution have a school of computer science, software engineering, or similar? If you are allowed to, perhaps you could sit in on some of their introductory lectures. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.