Jump to content

Pyhton or C to do For Daq and DSP?

Recommended Posts

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.



Edited by Mahbod Morshedi
Link to comment

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?



Link to comment

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 .

Link to comment

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.

Link to comment

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.




Link to comment
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.

  • Like 1
Link to comment

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 by Rolf Kalbermatter
  • Like 1
Link to comment
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.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.