08-17-2024 11:06 AM
Hello, I am using a RS232 cable to communicate with my computer to a Stanford Research Systems Lock-In Amplifier SR830. I have successfully been able to communicate with it, and have attached the program that I was using. I attached this file - it's the one called Lock-In - Test One Command.vi." I am trying to get the X-values out of the lock-in, but instead of just getting one value once when I run it, I want to continuously collect the data and store it into a data column set. The input command is "OUTP?1\n." I have attempted to make one that is continuously collecting data, but when I run it, nothing is coming out of the Bytes at Port. Does anything know if I have set it up correctly? There are no error codes that it is giving me as well. I know for sure it is properly communicating with the device since my other vi works, so I think I just incorrectly set this one up. This file is the one called "Lock-In Acquire Data.vi." Any help or advice would be appreciated, thank you!
Solved! Go to Solution.
08-17-2024 11:06 AM
Sorry, here are the files.
08-18-2024 11:34 AM
Hello, Sen1.
First, many long-time members of the Forum (myself included) do not run the most recent version of LabVIEW, so will be unable to open files saved in LabVIEW 2024 format. Please "Save for Previous Version" and specify LabVIEW 2019 or 2021.
Second, you are probably making the most common "mistake" (particularly when trying to read "continuous data" from a VISA connect) of using Bytes at Port. When you initialize a VISA channel with VISA Configure Serial Port, there are two inputs on the top that specify enabling a Termination character (set True, by default), and letting it be <LF> (0xA). That's what you want. When your VISA device sends you data, it probably sends a line-terminated string, so when you want to receive a message from your device, you do a VISA Read, and specify 1000 bytes (I usually specify 1024), or any number that you can safely assume is longer than the longest single message your Instrument will send. What will happen is the VISA Read will begin, and if there are no data for (by default) 10 seconds, will complain, otherwise it will read the string, stopping when it encounters the Termination character. At that point, the entire message will be available in the Read buffer. Process it, and then loop back to wait for the next Message (unless, of course, the message was "That's All, Folks!", in which case you can exit the While Loop and close the connection.
See if that helps. And don't worry, almost all of us (myself included) made that mistake unless we were taught otherwise.
Bob Schor
08-19-2024 09:11 AM
Hi Bob,
Thanks so much for your quick reply. I attached the files with LabVIEW version 19. I fixed the Bytes at Port thing that you suggested and now my file that is just one command is working correctly, so thank you! The one that is continuously collecting data though is still not working, it just keeps running and doesn't stop. I think maybe the issue has something to do with the fact that in my one command program, I have a concatenate string and search/split string and I haven't been able to make it work without that, but in the continuous one I don't have that because it's a for loop. Do you have any suggestions on what I should do?
08-19-2024 11:41 AM
@dilarasen wrote:
I think maybe the issue has something to do with the fact that in my one command program, I have a concatenate string and search/split string and I haven't been able to make it work without that, but in the continuous one I don't have that because it's a for loop. Do you have any suggestions on what I should do?
The termination character is used as an end of the message fiducial; it is not returned with the message.
08-19-2024 01:42 PM
I think I got it working now. I'm uploading the code I used in case anyone is having a similar problem. Thanks everyone for the help!