Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from instrument with COM serial port

Solved!
Go to solution

Hello, first time swiched from GPIB instruments to COMport instrument. I'm strugling to understand how to set it to work properly. Wached hours of serial port labView tutorials. Went through dozen of tutorials can not find the problem.

 

I've connected instrument to USB -> com port. I'm sending a command "freq". Got the right feedback from instrument, but with timeout.

 

Labview1.jpg

 If I Enable Terminaton Char in VISA configure serial port, i receive just the first line.

"SPECTRUM COMPACT HARDWARE 6.10, FIRMWARE 5.3.10.2, 07.11.2023 11:21"

 

Is there anything I can do to receive all the data with single VISA Read?

 

0 Kudos
Message 1 of 14
(400 Views)

I generally don't like doing this, but you could use > (62, 0x3E) as your termination character.  This will work as long as that character is never in one of the responses.

 

My preference is to constantly try to read the lines and use a queue to pass the data on to the main loop.  That reading loop also logs every single read line to a file for debugging.  This is all part of a terminal framework I put together.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 14
(388 Views)

Thank you for hints!!!

 

Why is " > (62, 0x3E)" this better termination character than others? Please drop some links, will study it!

 

For sure, I can manipulate with instrument using putty or Termite, but I've stucked also to trigger the instrument to start measurement with LabView. For example,

 

sweepu 27000000 40000000 250 khz

 

in Termite triggers the measurement according to user manual. But in my .vi it kind a blinks display for a second and measurement is not trigered. Where is the problem in my .vi why instrument do not trigger?

 

In Termite I realised that measurement on instrument is trigered just in case if Append CR is used. All other options gives the identical result as my .vi

Labview2.jpg

 

I got so much litters of coffee in my body today... will continue with beer 😄

 

 

0 Kudos
Message 3 of 14
(366 Views)

@ku_ku wrote:

Why is " > (62, 0x3E)" this better termination character than others? Please drop some links, will study it!


I stated to use '>' based on your previous image where it was obviously a terminal that used "->" for the prompt.  So '>' would indicate when the device was done sending something.  But with your update here, I would go back to my base of using the Carriage Return or Line Feed at the termination character and use a queue to send each line to the main loop for processing.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 14
(357 Views)
0 Kudos
Message 5 of 14
(355 Views)

@ku_ku wrote:

your video, rigt?

 

https://www.youtube.com/watch?v=J8zw0sS6i1c


Yep, that's me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 14
(352 Views)

Hello,

           is there a possibility that after the last symbol sent from the instrument ">" there is no termination character???

 

If I try to read all data, that is sent by instrument, while Termination character is disabled, I run in timeout... but I got the data!!! Identical to what I get with Termite.

 

NoLF CR.png

But when I enable termination character and read line by line, as you suggested, I also get all the data, but I got timeout while the last "->" is read!I guess there is no termination character after "->". How to test it?

 

 

NoLF CR2.png

If there is no Termination character, is there a workaround?

 

0 Kudos
Message 7 of 14
(315 Views)

To save time, please share the instrument's make and model or, better yet, the programming manual.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 8 of 14
(311 Views)

Hi Santo,

               I'm glad to share it 🙂

 

SpectrumCompact (J0SSAP74)

Hope you can see there something I do not see 🙂

 

 

0 Kudos
Message 9 of 14
(306 Views)
Solution
Accepted by topic author ku_ku

@ku_ku wrote:

           is there a possibility that after the last symbol sent from the instrument ">" there is no termination character???


That is normal for a terminal.  It is the command prompt.  I treat a terminal as an "Intermittent ASCII" instrument (referring to my presentation you linked to).  I use Bytes At Port to see if there is a message started.  If there is, read the line.  If not, maybe have a wait.  With this, I set the timeout to something pretty short, like 50ms.  I will then ignore the timeout error (Clear Error has an input for specific errors to clear) and just treat what I did receive as a full line.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 14
(294 Views)