09-03-2009 11:56 AM
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!
09-03-2009 12:23 PM
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.
09-03-2009 03:04 PM
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!
09-03-2009 03:19 PM
09-03-2009 04:07 PM
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.
09-03-2009 05:23 PM
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?
09-03-2009 06:59 PM
09-03-2009 07:59 PM
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: