10-15-2021 05:25 AM
Hello,
I am trying to read data from the gaussmeter but I am getting problem while running program, the bytes read is atomically getting zero, Before running the program I was giving value of 1000 bytes read, after compiling the program bytes read is getting zero and no data is getting potted in the chart. Could you please give me your suggestion, Did I do mistake anywhere in the program. I am attaching the front panel and block diagram of my code. Could you please check it and looking forward for your help.
Thanks
Vijay
Solved! Go to Solution.
10-15-2021 05:54 AM - edited 10-15-2021 05:58 AM
Some recommendations:
- terminate the SCPI command with a line feed otherwise it will not be recognized
- remove the Bytes at Port property and throw a large number (say 1000) into the byte count terminal input
- define a more sensible timeout (10 seconds seems too much, 1 or 2 seconds are probably enough)
EDIT: the value of the bytes read indicator before running is irrelevant
10-15-2021 06:21 AM
Do you have a manual or some documentation showing the communication details for this instrument? It is hard to give any real advice without knowing how the communication works.
10-15-2021 06:51 AM
Hello Crozzrulz,
I am attaching the manual of my device could you please check it. My aim is to determine the magnetic flux density continuously, So I am using RS 232 cable to communicate with the device (SCPI Commands), I am using the VISA function to read continuous data. Actually, I am new to LabVIEW so I am not confident that my code implementation is completely correct or not. Could you please check it and please give me your suggestions to get the continuous data from the device by giving SCPI commands.
Looking forward to hear from you
Thanks
Vijay
10-15-2021 07:38 AM - edited 10-15-2021 07:40 AM
I would say that the bytes at port before you run is important. There are times when programs using serial ports get stopped oddly and there is data sitting at the port. For this reason, as part of the init, we clear the write buffer by reading it until there is nothing else to read.
I would also suggest that you turn on slash codes with the SCPI command string so that you can see for sure that the \n or \r is there.
In your target code where you will be doing a write then an immediate read you should put a Stall Data Flow for something like 10 ms or 50 ms after the write so that the instrument has time to respond.
Lastly I would suggest that you put an error in and error out on the front panel so that you can capture any error codes that come up.
10-15-2021 08:01 AM
@Tom_Powers ha scritto:
I would say that the bytes at port before you run is important.
The questioned value was "read bytes", which is an indicator, not "bytes at port" (at least this is what I understood). "read bytes" is only written, never read, so before running it's irrelevant.
@Tom_Powers ha scritto:
In your target code where you will be doing a write then an immediate read you should put a Stall Data Flow for something like 10 ms or 50 ms after the write so that the instrument has time to respond.
If the termination character is enabled, there is no need to put a wait between write and read. VISA will wait for an answer (terminated by LF) within the full timeout.
10-15-2021 09:42 AM - edited 10-15-2021 09:43 AM
Ok, you have a few problems here.
1. The command you are writing is wrong. You are sending "*READ?" when it should be ":READ?" (you used a star instead of a colon).
2. It appears like you did not terminate your command with a Line Feed. It is really hard to tell when looking at a string in "normal" view. You might want to change that to use "\ Codes" if you are going to include it in the string. I just use Concatenate String with a Line Feed Constant to make sure it is at the end of the command.
3. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis). I could go on a big giant rant here. But to keep it really simple for you, you just need to tell the VISA Read to read more bytes than you ever expect in a response and the VISA Read will stop reading when it encounters the termination character (default is a Line Feed). This will ensure you are getting the full response back and not part of a message.
So with that said, here is the code I recommend you start with. Also attached is the VI saved in LabVIEW 2009, so you should be able to open it.
10-21-2021 05:25 AM
Hello Crossrulz,
Thank you so much for your suggestions and help. Its working now. But I have a small doubt when I try to plot the magnetic flux density its recording in Tesla [T], and in the measurement instrument the values are showing in milliTesla [mT]. How do I convert the Tesla [T] into milliTesla [mT] in waveform chart. Could you please give me your suggestion. For your reference, I am attaching a picture of my measurement in Tesla.
Thanks
Vijay
10-21-2021 05:41 AM
The Y axis legend is just a text: you can simply edit it clicking on the text or opening the graph's Properties dialog.
I'm assuming that the displayed values are actually in mT.
10-25-2021 04:07 AM
Hello pincpanter,
Thank you so much for your suggestions and help. Actually, when I try to plot the magnetic flux density in waveform chart its recording in Tesla [T], and in the measurement instrument the values are showing in milliTesla [mT]. For example in Gaussmeter if it 40.6mT (milliTesla) and that same value is getting plotted in chart as 0.04T (Tesla). So my doubt is how do I convert the values in milliTesla in waveform chart same as instrument values. I have tried in chart properties to change Y-axis decimal values by dint get the positive result. Still the values are recording in Tesla in chart. Could you please let me know your suggestion. For your reference I am attaching the pictures. Looking forward to hear from you soon.
Thanks
Vijay