LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to a device using TELNET

Solved!
Go to solution

Hello all,

 

I am afairly new at using LabVIEW... I have only the basic subset of skills thus far.  So I would like to respectfully request that when you respond to be a all-encompassing as possible please.  In fact, an example project with lots of explanation would be absolutely fantastic.

 

Essentially, I have a Kollmorgan AKD motor controller device (specifically the AKD-x00306 model) that controls a servo controller.  It uses the TELNET protocol, amongst others, to communicate with it.  Thus far, I have been able to use MS TELNET service and Kollmorgans workbench to communicate with the device with great success.  Although the Kollmorgan workbench is a good program, I am looking for more accurate control.

 

Here is the question:

What is the best method of sending mulitple commands like that of the TELNET protocol (to where I can enter one command, have the Kollmorgan execute, enter another command, execute,... for multiple iterations of this... with out disconnecting)?  In other words, I want to be able to enter several commands, one at a time, and the Kollmorgan execute each command after each time the enter key has been hit (with out having to restart the application... due to the disconnection).  So far, I have set up a while loop (with no success) and a for loop (with no success). 

 

With out the involvement of a loop, I can send a command and have it execute just fine... the connection just gets disrupted/disconnected.  Attached is my working model of the program with out the loop.  You will find that it only allows for one execution (using the "run once").  if you use the "continuous run" button, the buffer is overrun (as you most likely know). 

 

Thanks in advance.

0 Kudos
Message 1 of 8
(4,114 Views)

A for loop should work just fine if you create an array of commands and pass it through the for loop. A for loop auto-indexes an array input. In other words, for each iteration, the next element of the array is read from the array until all elements have been read. The for loop iteration count is equal to the number of elements in the array.

 

Next time you have a problem, post the code that you are having a problem with - i.e. the code with a loop. Much easier to fix something when someone can see what you have done.

 

0 Kudos
Message 2 of 8
(4,107 Views)

Okay... so a couple of questions please.    What type of array are you suggesting? 

 

I originally tried this for a WHILE and a FOR loop.  When using the FOR loop in trying to connect the "telnet connection out" from the "telnet write" to the "telnet close connection" , I get a broken wire symbol on both the TELNET CONNECTION  and the ERROR IN.  Essentially it is an "indexing error."  I am not sure what is going on here.  Would you mind explaining this please?

 

Thank you much.

 

 

0 Kudos
Message 3 of 8
(4,098 Views)

The type of array is exactly what is shown - a string array. It's a string you are trying to write, correct?

 

By default, a for loop will auto-index every output. That means it will create an array. Just right click on the exit tunnel and select 'Disable indexing'.

0 Kudos
Message 4 of 8
(4,096 Views)

And of course, there's always the help...

 

For Loop and While Loop Structures 

0 Kudos
Message 5 of 8
(4,082 Views)

I gotcha!  What you say makes sense; however, when I "highlight the execution," the data is shown to pass from the array and the TELNET connection to the outside walls of the loop.  Once there, the connection stops and I get timed out.  This is very interesting because without the loop, it works (and so long as there is only one character string that is being inputted). 

 

Please take a look at my setup and tell me what I am doing wrong.

 

Again, thank you.

0 Kudos
Message 6 of 8
(4,070 Views)
Solution
Accepted by topic author TheJTUX

You have 2 problems:

  1. Do not wire a value to the N terminal of a for-loop and auto-index at the same time. One or the other. In your case you are auto-indexing. Delete the 9 constant.
  2. Your strings are not correct. If you want to enter special characters such as linefeed and carriage returns your string must be in '\' display mode. Otherwise the characters get interpreted exactly as you enter them. You were sending your string, then the "\" character, and then the "n" character. That's not the same thing as the linefeed character. Right-click on the string element and select this mode on the popup. You will see there are two "\" character before the "n" and "r" characters. Change all of the double-backslashes to single ones.
0 Kudos
Message 7 of 8
(4,063 Views)

Thank you for all your help.  You know... it is always the simplest things that we overlook that cause the majority of the problem.  I was able to get it to work with the FOR loop.  Thank you tons for the insight.

 

 

0 Kudos
Message 8 of 8
(4,053 Views)