From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-03-2021 07:07 AM
Hi,
I read an instrument with visa. I quite often get '23E-5' or '.23E-5' instead of '+1.23E-5'.
What's the reason behind getting inappropriate format by chance?
Kind regards,
Balázs
03-03-2021 07:14 AM
Hi Balazs,
@LTBALAZS wrote:
I read an instrument with visa. I quite often get '23E-5' or '.23E-5' instead of '+1.23E-5'.
What's the reason behind getting inappropriate format by chance?
Most probably the reason is the VI you use to read the strings from COM (?) port…
Wrong code produces wrong results!
03-03-2021 07:47 AM
Hi GerdW,
I attached my VI. Would you please have a look at it?
Can i avoid getting data in wrong format?
Kind regards,
Balázs
03-03-2021 08:08 AM - edited 03-03-2021 08:12 AM
DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)
Just go watch this and all of your questions will be answered: VIWeek 2020/Proper way to communicate over serial
Before even looking at your code, I knew you were using the Bytes At Port. Instead, just tell VISA Read to read more bytes than you ever expect in a message and, because of the termination character, you will get your full value.
03-03-2021 08:35 AM - edited 03-03-2021 08:36 AM
I went ahead and cleaned up your VI with some comments...
03-03-2021 10:22 AM - edited 03-03-2021 10:24 AM
Hi, thanks a lot.
I tried to use given number of bytes, e.g. 50. Also read visa 3 times before while loop. (it helps to avoid wrong read at startup!)
During measurement i can get inappropriate value as 0.00E-00 or get measurement value in wrong format just like before. Measurement value must be higher than zero though. I get no error after all on com port.
A) Old instrument is using 10m of shielded serial cable crossing plenty of EM cables. Our old application.exe was using the instrument with no truble. But it may have been using reinitialization run time, that i want to avoid now.
B) New instrument is using 10m of active USB cable is using the same VISA read method with 'bytes at port'. (Yes!) Communication is stable.
I was just wondering if i can have stable communication with old instrument without reinitializing its communication. ( just like the way i do with new instrument)
Balázs
03-03-2021 10:54 AM - edited 03-03-2021 10:56 AM
First, you need to understand the string being sent by the instrument.
One should only use bytes at port [IF and ONLY IF] there is an expected handshaking with a known number of bytes expected similar to ACK / ENQ {Acknowledge / Enquiry} coding.
03-03-2021 11:42 AM
@LTBALAZS wrote:B) New instrument is using 10m of active USB cable is using the same VISA read method with 'bytes at port'. (Yes!) Communication is stable.
Really? You are twice the specified maximum length of USB2.0 (5m). USB3.0 is even shorter (3m).
@LTBALAZS wrote:
I was just wondering if i can have stable communication with old instrument without reinitializing its communication. ( just like the way i do with new instrument)
I would suspect a hardware issue of some kind. It could be a "damaged" cable, a bad connection somewhere, not enough shielding (ie you are in a VERY high noise environment), bad card or chip on the motherboard, etc. More likely, you just reached the limits of the cable being able to consistently transmit RS-232 signals. When going over more than a few meters, I recommend converting over to RS-422 to get a more stable communication.