Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

RS 232 communications with Thermionics Step Motor Controller (SMC)

Hi,

I am relatively new to LabVIEW and require some help using a RS 232 (COM 1 port) to communicate to a Thermionic Step Motor Controller (SMC) to help control the movements of a substrate in a vacuum chamber. However I am having trouble communicating to the SMC using LabVIEW 8.6.1. I have successfully communicated (sent and received messages, change settings on the SMC and moved the controller around) using Window's Hyper terminal application. However when I attempt to use LabVIEW I only get an echo-like response back. 

 

I have also installed the latest NI-Serial (v 3.5) and  NI-VISA (v. 4.6) and attempted to communicate with it though the measurement and automation explorer. When I open the program, I find the correct serial port (currently I only have one rs-232 port on the computer) and select "open VISA test panel". From there I use the viWrite tab to write the command "sn" (which ask: "how many axis are there?")  and then I use viRead, it then shows a returns status of "BFFF0115" in red, and the buffer reads "sn". note that I do not change anything else under the other tabs.  The correct response that I get from hyper Terminal is "S N 6 OK"I have also tried using the example Vi that are associated with the VISA and Serial Vis, however they also just return the "sn" when I write "sn"

 

I have checked the port settings on my computer and on the SMC and they do match.

Baud rate:      9600

Data Bits:       8

Parity:            None

Stop bits:       1

Flow Control: None

 

I believe that my write commands are not being sent to the SMC, because the echo-like response are in lower case, and all responses are suppose to be in capital letters; even the errors.

 

Any advice or things to check would be a great help. I have attached the manual for the SMC and a very simple Vi that I also tried using but go a similar echo-like response. 

Thanks!

 

 

Download All
0 Kudos
Message 1 of 8
(5,536 Views)

Why don't you terminate your string with either a CR or LF like the manual says and like Hyperterminal does? The VISA test panel write includes \n as a default. This is a LF character and you must have deleted it and in the LabVIEW examples. A CR is a \r. Note that in order to send this correctly, your string control/constant has to be set to '\' Codes Display. You can also use the constants on the string palette and concantanate them with your command. See the Advanced Serial Write and Read Example to see how to configure VISA to append or the other.

 

p.s. NI-Serial is only required if you are using NI's serial devices.

0 Kudos
Message 2 of 8
(5,531 Views)

Hey Dennis,

Thanks for the quick reply. I had tried the "sn\n" but the reply when I did that was just a double "sn\n\n" So that lead me to believe that the \n was a default. But on a good note, the "sn\r" solve the problem, well at least when I use the VISA test panel. Also I did not know how to set the "\ code display" that you mentioned. Could you point me in the right direction?

 

Also I am now experience another problem. This has to do with the read subvi in the actual LabView program (ie not the VISA test panel). I used the previous Vi that I posted and I get a timeout expired error when I try to write "sn\r\n" or "sn\r". Do you have any ideas how to tackle that? 

 

Below are the errors:

Error -1073807339 occurred at VISA Read

VISA:  (Hex 0xBFFF0015) Timeout expired before operation completed.

 

Thanks again!

0 Kudos
Message 3 of 8
(5,514 Views)
  • You need a pause between your Write and Read. Start with something like 20mS.
  • You should let LabVIEW find out how many bytes are at the port (using VISA Bytes at Serial Port), then read that number of bytes.
  • The return count comming out of Write is how many bytes your command was, it has nothing to do with how many bytes the message will be.

 

Richard






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

Amazing things happen when you use the right mouse button. Just do that over the string control/constant and see what's there.

 

And, as I also said, you could use the constants or set up VISA to automatically append the termination character.

0 Kudos
Message 5 of 8
(5,505 Views)

Hey Broken Arrow,

 

Thanks for the tip, I had tried a time delay earlier but it did not help, but I think that was because I had placed it incorrectly.

So I added the time delay backing to the sequence, and also I use the VISA bytes at the Serial Port subvi. Which solve the problem of the two errors mentioned above. Thanks!

 

But when I use that VISA bytes VI, I am receiving that there is zero bytes at the port; which makes me believe that the initial write command is not reaching the SMC. Even though measurements and instruments program and hyper terminal are able to successfully communicate. I attached the updated Vi to the post.

 

Any thoughts? 

 

 

 

 

 

0 Kudos
Message 6 of 8
(5,488 Views)
You are still not sending the correct termination character. AS I SAID -turn on '\' Codes Display. If you don't do that, you will not have any success. Did you even bother to right click on the string constant? Did you bother to try the CR and LF constants on the string palette. Did you bother to look at the example I mentioned? Did you even bother to do a search for this issue? It can't be less than several hundred posts about the exact same mistake you keep making.
0 Kudos
Message 7 of 8
(5,483 Views)

Ashish_P wrote:

Hey Broken Arrow,

 

Thanks for the tip, I had tried a time delay earlier but it did not help, but I think that was because I had placed it incorrectly.

So I added the time delay backing to the sequence, and also I use the VISA bytes at the Serial Port subvi. Which solve the problem of the two errors mentioned above. Thanks!

 

But when I use that VISA bytes VI, I am receiving that there is zero bytes at the port; which makes me believe that the initial write command is not reaching the SMC. Even though measurements and instruments program and hyper terminal are able to successfully communicate. I attached the updated Vi to the post.

 

Any thoughts?


No throughts other than these two:

 

  • 1) read what Dennis said.
  • 2) hyperterm is prolly working because to send a command, you have to hit enter, thus you are sending a CR.

you'll get there
Richard






0 Kudos
Message 8 of 8
(5,480 Views)