LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Highlighted

I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Hi,

 

I just started to use LabVIEW and after checking the tutorials I have some questions. I want to control a machine with three different temperature zones. The machine is controlled by sending a fixed set of commands like "soll=1,3700;" (this means: set channel 1 to 37 °C). To send the commands via USB connection I use the basic visa read/write example (I have the visa drivers). For the temperature input I created the commands using a numeric control and "format into string". With this setup it is possible to set the temperature of one channel.

Since I want to control the temperature of three channels I added multiple numeric controls and "concatenate strings". From there on I have a few questions/problems:

 

1) If I run the program once it will only set the temperature of channel 1. Is "concatenate strings" the wrong tool to get multiple commands into the visa write? The tool only sends the first command right and the rest gets mixed up. Do I need a break between the commands?

If I run the program continuously it will sometimes update all the channels correctly, but this leads to another problem:

 

2) If the program runs continuously it will constantly send commands. I want the program to only send commands when I change the numeric input for a specific channel. Do I have to use a case structure for that and how do I wire it?

 

3) There is also a temperature probe that can be read with the command “is=6;”. I would like to constantly read the temperature. If I use the visa write/read I will get an answer like “read,is=6,4000k” (this means: channel 6 is 40 °C). How can I extract the 40? I tried “scan from string” but it didn’t work.

 

Thanks in advance for your help and comments!

 

Here's my current progress:

 

labview.png

 

 

0 Kudos
Message 1 of 16
(815 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Hi MiSchi,

 

why don't you cleanup up your VI before posting?

 

1) If I run the program once it will only set the temperature of channel 1. Is "concatenate strings" the wrong tool to get multiple commands into the visa write? The tool only sends the first command right and the rest gets mixed up. Do I need a break between the commands?

This is answered in the manual of your device.

It will tell you, which string format you have to use to send multiple commands!

 

2) If the program runs continuously it will constantly send commands. I want the program to only send commands when I change the numeric input for a specific channel. Do I have to use a case structure for that and how do I wire it?

How does your program run continuously when there is no loop in the VI?

That "run continuously" button is ONLY for debugging purposes!

To have something done when a value changes you need to compare current value with previous value and use a case structure. Or you use an event structure to act on user input events…

 

3) How can I extract the 40? I tried “scan from string” but it didn’t work.

See this:

check.png

Both solutions give the same value…

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 16
(799 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Thank you very much for your answer! What do you mean by cleaning up my VI? Do you mean the information windows? I'm sorry if it's too crowded. I just started using labVIEW  and I have to learn a lot. I also didn't know that "run continuously" is only for debugging.

 

Sadly i don't have a manual. I only have a list of commands.

 

Thank you very much for your example! That's helping me a lot. I will try to implement it and learn about the event structures for my user Input.

 

0 Kudos
Message 3 of 16
(789 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Hi MiSchi,

 

What do you mean by cleaning up my VI? Do you mean the information windows? I'm sorry if it's too crowded.

No, I mean the AutoCleanup button in the menu line: it cleans up your block diagram automatically…

 

I just started using labVIEW  and I have to learn a lot.

LabVIEW comes with a huge help, one of its first chapter is for beginners.

You also have a huge library of example VIs you can study.

And NI offers a lot of free resources to learn LabVIEW, one of them is this one.

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 16
(780 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?


@MiSchi wrote:

What do you mean by cleaning up my VI?


Avoid crossing wires.  Avoid wires going backwards.  Avoid wires going under nodes and structures.  Try to show some organization to your code.

 

But a quick way is the little broom button in the toolbar (Diagram Cleanup).  Or the keyboard shortcut is Ctrl+U.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 5 of 16
(777 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Thank you both for your answers. I will definately try to organize it more. Since I want to add al lot of other functions later, it might get really confusing.

0 Kudos
Message 6 of 16
(773 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Also "One Big Loop" is never a good program architecture. Break your task down into steps. A quick look at your diagram I see these steps.

  1. Configure serial port 
  2. set temperatures
  3. wait
  4. read temperatures (?)
  5. close communications

Make each one of these steps a state in a State Machine, then looping back to other states to maintain temperature is trivial. 

 

Also lose the "Bytes at port" and configure your  communications to use a Termination Character, then set the VISA Read to read a larger number of bytes than you expect. Now the VISA read will read until the Term Char or it times out.

 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 7 of 16
(736 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Thank you very much for your advice!

I have a follow up question: I'm not sure how to do this. If i delet the "bytes at port" and set a fixed number I get an error saying "timeout expired before operation completed". Can you tell me more how to set this up?

 


@RTSLVU wrote:

 

Also lose the "Bytes at port" and configure your  communications to use a Termination Character, then set the VISA Read to read a larger number of bytes than you expect. Now the VISA read will read until the Term Char or it times out.

 


Also another question:

To set the three different temperatures I now use an event structure. If I run the program, I can cange the temperature for channel "lid" and "glass". But the channel "plate" doesn't Change. If I check the visa read I can see the three commands, but the middle "plate" command is always to short and it will not be recognized as a command. Why does the middle command always get cut off?

It looks a bit like that : set=1,4000OK;se3900unknown;set=3,3800OK

It should be more like: set=1,4000OK;set=2,3900OK;set=3,3800OK

 

The command is not too long and i also tried it with 2 Inputs. Then the second one does not work.

Sometimes (every 30th value change) it works. But mostly it doesn't get the command right.

Unbenannt.PNG

0 Kudos
Message 8 of 16
(714 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

Hi MiSchi,

 

you know we cannot debug images using LabVIEW?

Attach your VI!

 

It should be more like: set=1,4000OK;set=2,3900OK;set=3,3800OK

Well, in your image you use "soll" instead of "set". There also is no "OK" for those FormatIntoString visible. And it looks like the ";" constant for the "plate" is different then the other ";" constants…

Did I mention you should attach your VI for debugging?

Where and how did you test your formatted string?

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 9 of 16
(706 Views)

Re: I want to control multiple temperature zones with visa read/write. How do I set up multiple numeric controls in labVIEW?

It looks like your device is echoing back each of your commands followed by its responses. Instead of cramming through all three commands and then reading the echoes and responses of all three after the fact, I'd suggest you send them one at a time, and read back the echo and response for each one, before proceeding to the next one. It also looks like when you're writing the commands to the device the termination character (the character that always marks the end of a command) is a semicolon (rather than something more typical like a carriage return or linefeed character). However, from the read back data you quoted, it's not clear if there's a different termination character after the echoed command or the response, though I suspect there is. Does the documentation you have show any character that always comes at the end of a transmission from the device? That's what you'd want to configure the VISA Read to stop on, instead of using Bytes at Port.

0 Kudos
Message 10 of 16
(700 Views)