Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

visa works with highlight execution

I'm trying to modify the example provided by Omega to read from a PX409 pressure transducer.  The code used to verify that the sensor is present only works when I run the vi in highlight execution mode so I know that means I need to initiate a wait of some sort somewhere along the visa communication trail.  I've tried all sorts of things with no luck.  I've attached the example vi from Omega.  Can anyone point me in the right direction?

 

Thanks.

LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 1 of 6
(3,208 Views)

A few things concern me here.

1. There should not be a reason to use the VISA Clear after every write.

2. Why is the termination character turned off?  From what I can tell, the protocol uses an ASCII messaging which ends with a Carriage Return (CR, 0xD).  That tells me you should set up the VISA Configure Serial Port to enable the Termination Character and set it to 13 (0xD).  You can then get rid of the Bytes At Port and just tell the VISA Read to read more bytes than you ever expect back in a message.

 

Do you have any manual or documentation that states the commands protocol?


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 6
(3,150 Views)

I tried to get rid of the Visa Clear functions after every write but it didn't solve the problem.  Putting a 400ms wait at the end of every write seems to have solved the problem but I feel its more of a hack than a solution.  Example is attached as well as command protocol documentation.

LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 3 of 6
(3,140 Views)

That does help.  I would actually set the Termination Character to be ">" (0x3E, 62) since it looks like all responses end with that except for when you request a Binary reading or are streaming data.  But you can use a VISA Property Node to turn on/off the termination character as needed.  When streaming, it becomes a little more complicated as you have to find your sync byte, read 5 more bytes, and then unflatten the data part of the message into a SGL using Little Endian.  But that is a little farther down the line.

 

But as far as your waits, it is quite possible the unit is really slow.  In that case, you kind of have to wait either a set amount of time or for the response.  You still shouldn't need to use the VISA Clear though.

 

And I am not seeing the CLR command listed in the manual.  You could try removing that to see if it helps at all.  Here is a quick cleanup that I just did.


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
Download All
0 Kudos
Message 4 of 6
(3,135 Views)

Yeah, I didn't see the CLR command and tried to remove it with no luck.  I will try your suggestions and see if it how far I get.

 

Thank you very much!

LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 5 of 6
(3,132 Views)

It is obvious that you are running into a timing issue.  What I see is that your first 'Tick Count' can start whenever it wants as it has no constraints as to when to begin.  Try adding a second sequence to your delay after the ENQ command.  Place your 'Tick Count' in there and keep the rest of your wiring as is for now.  There are a number of improvements to make, but let's stick with the issue at hand.  The reason why it would work while in highlight mode is that even though you would still get the timeout in your 'While Loop', is that it is also able to read the complete instrument response within the extended time.  This makes your True cases work.

 

By moving the initial 'Tick Count' after the delay sets exactly when to begin the counter; otherwise, it could begin before configuring the Serial Port which means that it would already be past the 5,000 ticks before entering the loop.  Not sure that your timeout will ever read 5,000 ticks, but who knows.

 

As a note, the Tick count will roll over about once every 49 days in a 32-bit unsigned number.  After that time, it may cause havoc with your comparisons.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 6 of 6
(2,824 Views)