LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hyperterminal and Labview

Solved!
Go to solution

Hello, 

 

I have been using Hyperterminal to control my laser, which has been working just fine. I have just recently switched to labview, but I am unable to get it to respond to my commands. I did not have previous experience with Labveiw before this. I have read other forums on this, and it could be an issue related to the terminal commands.

Other than that, I have used the same settings as I have for Hyperterminal (please see below):

anshulseecharamgmailcom_0-1717138302096.png

In Hyperterminal, I did not have to set any setting for red highlighted parts.

 

I have a strong feeling it is the termination character, but I have done several trial and erros but cannot figure out how to solve it. 

On the manual of the laser control, it says that the termination character should be \r\n (which I have tried also). As you can see in the block diagram below, I have used GI\n (but I have also tried \r\n). This should give me the current set. 

anshulseecharamgmailcom_3-1717138842325.png

However, this returns E5 on the front panel, which is an error according to the laser manual, which means 'Illegal character'.

Here is the error in underneath 'Response' shown below on the Front panel.

 

anshulseecharamgmailcom_5-1717138929877.png

I realise this is a very specific issue to my situation, but I'm just hoping someone who has encountered a similar problem can help me out.

Any help will be much appreciated. 

 

Best regards,

Ash

 

0 Kudos
Message 1 of 6
(724 Views)
Solution
Accepted by topic author ash_1204

Hi anshul,

 

make the "display mode" indicator visible for all your string constants, controls and indicators.

Then switch to "\-code" display mode.

Now you can type the correct TermChars ("\n" etc.)!

 

Or use ConcatString with your command string as first input and the NL/CR string constants as next input(s)…

 

  • Why don't you use AutoCleanup on your block diagrams?
  • Why is the "Enable TermChar" set to OFF in your image?
  • The usual TermChar setting at the VISAConfigureSerialPort only acts upon reading incoming messages, but not for sending messages to your device…
  • Do you already know this video?
Best regards,
GerdW


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

Do you expect responses from the laser?  Sometimes responses from an instrument designed to communicate over a terminal program can be tricky to handle.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 6
(700 Views)

The simplest (and fastest, usually) way to diagnose Communications problems is to use MAX.  Plug in your device, open MAX, find your Device (maybe it is COM3?), and open a Test Panel.  

 

[Oops -- it appears that the VISA Test Panel might have been removed by NI.  I found a recent "similar request" that might be helpful -- VISA command works in MAX, but not in LabVIEW .  If you can get the Test Panel to work, this will give you a quick way to test sending your device a Command Sequence and seeing what it spits back at you (hopefully an understandable string of characters).

 

You'll also want to learn the "correct" way to handle serial devices (using VISA) with LabVIEW.  I'll try to find the "Definitive Post" by @crossrulz and attach it here.

 

The basic idea (which works for most types of serial communication) is to do the following:

  1. Configure VISA to use Termination Characters (which, I believe, is "On" by default, with "<LF>" (which also works with <CR><LF>) also "On" by default.
  2. Send a simple Command to the Device (like "Identify yourself", however that is coded).
  3. Ask VISA to read 1000 characters back (I usually ask for 1024, just to be binary).  You'll get 10-20, usually (because it will return "Gizmo-1000, 2024<CR><LF>" and the VISA Read will stop and return that string when it gets the Termination Character).
  4. If all that works, write your LabVIEW code the same way.
  5. If it doesn't work, see what, if anything, it does return.  You might have to "fiddle" with the Baud, # of bits (7 or 8), and some of the other parameters.  In any case, you should have some data that you can send in a follow-up message to us.

Here is the VISA Tutorial I mentioned:  Proper Way to Communicate over Serial.

 

Bob Schor

0 Kudos
Message 4 of 6
(649 Views)

Also, an event structure (typically) belongs in a toplevel loop. In your case, if you would change any controls while the VI is already stalled at the event structure, the new values won't be seen.

0 Kudos
Message 5 of 6
(618 Views)

Hello everyone, many thanks for all the replies on this thread. I appreciate this very much.

The LabVIEW model is now working.

 

Making the display mode visible and switching to \-code worked.

Now, I can execute commands to the laser, and it works just as well as it was with HyperTerminal.

 

There is still a lot to learn to tidy things up, and I am sure the model can be optimised further. I will get to that soon. For the time being, I am just happy that the model is working.

 

On another note, the YouTube video recommended was also very helpful. So thanks for that 🙂 

0 Kudos
Message 6 of 6
(575 Views)