LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a labview interface to control a MKS946 vacuum system controller?

Hi everyone, I am a labview beginner, and recently I am building a system setup and planning to use labview to control a MKS946 which connects to 2 mass flow controllers. I googled some info about software control and hardware connection, but get confused by things like UART and serial communication. I have a RS232 to USB adapter, so is that good enough for hardware connection to a PC?

On the software side, I really have no idea of making a hardware controller, since I have only made some simple loops with labview before. I found a image of "MKS946 laview code" online and attach it below, but it doesn't show the complete code, so it's hard for me to copy it down. I am wondering is it really a working code for MKS946? If it is, can anyone help me to complete the missing part? Thanks a lot. If anyone has made a MKS946 code before, can you share some codes with me? Or provide some similar examples? I greatly appreciate that. 

 

 

 

0 Kudos
Message 1 of 16
(2,785 Views)

It looks like a USB to RS232 converter is what you need for this. Reading page 96 onwards of the manual attached details the commands to communicate with this device

 

When you connect your USB-.RS232 converter it should be accessible as a COM port using LabVIEW's VISA drivers.

 

Look at some of the serial examples in LabVIEW (Help/Find Examples and search for serial) to get more of an idea of how to use this. Something like the continuous serial read write is a good place to start.

 

Most of these examples use while loops which poll a button to trigger a write/read. I would suggest using an event structure to trigger writes instead. You can then use the timeout case of the event structure to read from the serial port or even better a seperate parallel loop.

 

I suggest you plug it in and have a play. Once you have made some code and got stuck feel free to post what you have done here and we can give you some more advice.

0 Kudos
Message 2 of 16
(2,759 Views)

Thanks for reply! Based on the example code, I tried to change it to event structure, shown in the attached images.

 

I have a very fundamental question about the device control and serial communication. Is this a device-specific coding? The labview example and my code serves the writing and reading by sending different commands and print feedback on screen which is straightforward, but the online image (attached below, 946MKSController_Labview(1).png) has much more logic operations. Does that mean I have to recreate all operations inside the device with labview? Can I just send different commands to the device and let it do its work? Let me know if I get it wrong, thank you. 

0 Kudos
Message 3 of 16
(2,717 Views)

Hi John,

 


@johnjl wrote:

Based on the example code, I tried to change it to event structure, shown in the attached images.


Please attach real code instead of images of parts of code the next time!

And please don't use "default if unwired" tunnels for references! (In other words: "Never do that again!")

 


@johnjl wrote:

I have a very fundamental question about the device control and serial communication. Is this a device-specific coding? … the online image (attached below, 946MKSController_Labview(1).png) has much more logic operations. Does that mean I have to recreate all operations inside the device with labview? Can I just send different commands to the device and let it do its work? Let me know if I get it wrong, thank you. 


Did you read your own device manual? There you will find all the answers!

(I can recommend to read atleast chapter 9…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 16
(2,710 Views)

Just to reiterate what GerdW has said, attach code rather than pictures, you will get much more help much quicker.

 

The reason GerdW is saying don't use the 'use default if unwired' is because in your close event the reference to the serial port object is lost before it can be closed. Depending upon how you have LabVIEW setup this may mean that you never close your connection to the serial port so therefore cannot open it again when you re-write your code.

 

I see what you tried to do with the response case but it isn't doing what you hoped. I am pretty sure that code will never get called because the only thing to trigger the response indicator to change is that event which can only get called when the response indicator gets changed. That code belongs in the timeout event at a mininmum (Make sure you wire a suitable timeout to the timeout terminal of the event structure). Really the read function should go in another loop altogether because putting it in the timeout structure will cause the entire front panel to freeze whilst data is being read from the serial port (Or any code in any of your other events are being carried out)

 

Yes commands are device specific. As GerdW said, read chapter 9 to get an understanding what the author of the code you attached is achieving with every command.

0 Kudos
Message 5 of 16
(2,695 Views)

Hi Niatross and GerdW,

 

I attached the code below. I read the manual starting from page 96 to page 107 (the chapter number is wrong here, so the chapter 9 you guys mentioned is chapter 8 here) and also skimmed through other chapters. If I don't understand it wrong, chapter 8 covers all different commands. Because I only need to control MFCs, I should only implement the commands in chapter 8.13, and possibly 8.18 for system. For PID part (from 8.15 to 8.17), maybe I can set them up on the mks946 panel, because I don't think I will change the setting very frequently. Correct me if I am wrong. Other chapters basically cover the hardware setting and installation, which are not very helpful for the labview interface. I just realized the "timeout case" for event structure is in the "application" category. I move the read part into the timeout case, but not sure if that is what you mean. 

 

Best,

John 

Download All
0 Kudos
Message 6 of 16
(2,673 Views)

Hi

I added a clear button and connected all necessary shift register inputs.

I also disconnected the typedefs you had.

I like typedefs but was too lazy to build them again.

greetings from the Netherlands
Message 7 of 16
(2,633 Views)

Hi,

 

Thanks for reply. I followed the link below to set up the serial communication: 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x1jtCAA&l=en-US

There are com3, com4, and com5 shown in MAX, so I don't know which one I should connect to. I unplugged the cable and plugged it again, and com5 disappeared, so I believe it should be com5. 

However, when I send commands and test it, it doesn't give me any response. How should I fix it?

 

 

Thanks,

John

 

0 Kudos
Message 8 of 16
(2,575 Views)

Are you sure the wiring is ok?

Serial connections sometimes need swapped wires.

Especially wire 2 and 3 tx and rcv are sometimes swapped

 

greetings from the Netherlands
0 Kudos
Message 9 of 16
(2,553 Views)

I am not sure about it, because the USB/RS232 is a product from amazon, so I didn't wire it myself. Do you know where can I get a DIY kit for the adaptor? 

0 Kudos
Message 10 of 16
(2,545 Views)