06-13-2025 02:00 AM
Hi!
Seems you are not familiar with LabView?
The dark violet line is just a connection handle / reference, you can't see the data running through the interface there.
The magic happens in the Sub-VI on the right, where all values are connected to.
I'd expect some formatting of values into a string and sending that via VISA Write inside there.
06-14-2025 03:25 PM
Yes, I’ve just started learning. Do you know any resources that could help me learn? Could you please share them with me?
06-14-2025 09:49 PM
It is pretty clear that you have very little, if any, experience with LabVIEW, have never had a class in LabVIEW, have never had a mentor who discussed how to "think LabVIEW" and write good LabVIEW code.
It is also unclear why you are using LabVIEW, particularly since your original post mentioned something about "a Python script for this". If you know Python, do it in Python (surely Python can read and write to COM ports, but since I've never used Python, I might be totally wrong about this ...).
We could give you a lot more "good advice" if you were to give us more information. Start by telling us what you want to do (forget, for the time being, how you are going to do whatever it is). You mention a Microscope stage -- tell us what the Stage does, what you want it to do, what else you need to do while the stage is being raised/lowered/moved right/moved left, etc. Are you taking other measurements? Does "time" enter into consideration here? [LabVIEW treats "time" as an important variable, as you might already know].
Are you taking any measurements? Of what? With what parameters (i.e. "how often")? Are data being saved? Any thoughts about data format?
Do you know the Three Principles of Data Flow Programming? [Have you ever heard about Data Flow Programming?]
One thing a beginner should never do -- Never use a Sequence Structure!
One thing a beginner (and experts) should (almost) always do -- utilize the Error In/Error Out terminals (lower corners of many Functions, and should be present on almost all sub-VIs you develop). Not only will they provide an Error (with explanation of "what went wrong") when your wiring is wrong, but they help keep your code neat (try to keep the Error Line straight, left-to-right).
Write (lots of)/(mostly) sub-VIs that do one thing. Use the default 4-2-2-4 connector pane for (almost) all sub-VIs. When getting started, make the VI Icon a blank square (get rid of the default symbol NI puts inside the square, replace it with 3 lines of 10 point text (short words!) that say what the sub-VI does.
Bob Schor
06-15-2025 12:54 AM
Yes, here is a clear explanation of my project:
I need to build a Python program to control a microscope stage. The system includes two stages (left and right) , both capable of moving along eight axes using stepped morters. In the current setup, these movements are controlled by commands sent from a LabVIEW program.
I’ve attached a screenshot of the LabVIEW front panel, which I hope helps clarify my objective.
Although LabVIEW is the commercially available software for controlling the stage—and may even be more efficient—this task is more like an assignment to help me improve my programming skills, particularly in Python.
I’m a complete beginner in LabVIEW and just started learning it. With the help of Google and AI tools, I’ve gained a basic idea of what I need to focus on as an initial approach to building the code.
Based on some feedback I received, I understand that it’s important to figure out exactly how LabVIEW communicates with the microscope stage. It sends ASCII string commands to a COM port to control the device.
I’m now trying to generate similar ASCII commands using Python and send them through the COM port. However, I realize my initial approach may have been incorrect due to my limited knowledge of LabVIEW. Moving forward, I will continue trying to achieve this using Python, without relying on LabVIEW. Any comments on this greatly appreciated.
Thank you.
06-15-2025 01:58 PM
@Sachith97 wrote:
Yes, here is a clear explanation of my project:
I need to build a Python program to control a microscope stage. The system includes two stages (left and right) , both capable of moving along eight axes using stepped morters. In the current setup, these movements are controlled by commands sent from a LabVIEW program.
Aha! Allow me to paraphrase your previous response:
There is an old saying, "When Life gives you a lemon, make lemonade".
If you have installed LabVIEW, you probably (!) have MAX (Measurement and Automation Explorer) installed. If you are going to use Python to "talk with" your Device, you are probably going to connect to it with a cable that transmits the (resumably) serial "messages" over a VISA interface. If so, you should be able to plug in your Microscope Stage, open MAX, and see the serial port connected to the Stage.
So now you use MAX (and the instruction manual that describes how to communicate with the Stage over a serial connection) to configure the Serial Port (probably 9600 baud,8 data bits, 1 stop bit). You should be able to expand the Test Panel (click on tabs) and try sending simple commands (I don't remember the exact format, but something similar to IDN, with additional punctuation and probably a final <Enter> should get the Stage send back its "Identification" string).
I'd suggest that if you decide to try this route, you should do the following:
Do you have a User's Manual (in PDF form) for the Stage you are trying to control? If so, and if you want specific advice on "next steps", please attach the PDF when you reply.
Bob Schor
06-17-2025 10:32 AM - edited 06-17-2025 11:31 AM
I appreciate your support, and your understanding of my message is exactly right.
Attached herewith is a screenshot of the MAX interface.
The stage is not directly connected to the PC—it is connected through a temperature controller device. This device appears to have two functions: one for controlling the heating element on the stage and another for controlling the stepper motor. Eight ports from the stepper motor connect directly to the corresponding ports on the temperature controller, and a single connection from the controller goes to the PC.
I do have a manual, but I'm not sure whether it includes information about the communication protocol for the stage control. It seems to focus more on temperature control. The manual is in Chinese. I’ve attached both the manual and the screenshot with this message.
06-17-2025 02:27 PM
THe document you shared describes the communication protocol to the controller. It uses a MODBUS implementation.
Basically you write/read from / to the serial port to send commands / reads from the controller.
The exact description of each commnad is described in the document. The LaBVIEW code you shared basically implements the communication protocol and interprets the user interface into the Serial commands.
From the code you share there are some files missing that probably are translating the data from the numbers into the hex code to be send/received by the controller.
The Pink lines on the LabVIEW Code represent Strings, that are then used to transfer the data into the serial ports.
The purple line represents the COM port number.
In the diagram bellow the numbers are sendto the subvi(the box wieh interrogation mark) where the "magic" of translation happen (the implementation of the manual you shared into String hex code that is then writtten and then after 100 ms it reads the bytes at the port as the response from teh controller.
The code bellos is under an "event" structure, it contains cases for eac of the buttons on the user interface. labVIEW sits idle until some button is pressed, then it executes the code on that part of the diagram.
When nothing is pressed, it executes thte case Time out.
The program writes the string 0903 2000 0003 0F43 and reads the measured temperature. Then reads the serial port and compares the response to light the LEDs.