LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa data read on >0

Hi

 

I have a simple write/ read data to a text file using visa and GPIB “GET” command. The data reads fine but I need to only read in data when the value is >0 to trigger a set number of data points. I’m using visa open, write, read, close and write to text with loops. Unfortunately unable to show VI at this time. 
Any examples would be helpful

 

0 Kudos
Message 1 of 22
(2,010 Views)

@Compolitus wrote:

The data reads fine but I need to only read in data when the value is >0 to trigger a set number of data points.


And where is this "value" coming from?  We need A LOT more context.


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 22
(1,997 Views)

Hi crossrulz

 

Thank you for reply. You are the person that helped me originally. 

The data is from a GPIB frequency counter Visa write sends GET command and visa read is set to input 12 byte ASCII strings. This is then fed to a notepad text document and looped for a total of 256 cycles. 

When run is initiated the cycle starts to read reads all 256 data bytes immediately, even zeros.   I need it to wait until the first proper value byte is received before reading in 256 steps. Greater than zero seems sensible to me as the first value from the frequency generating device is around 9 Ghz. 

I presume that there needs to be some sort of visa “wait until >0” before starting the read cycle. 

0 Kudos
Message 3 of 22
(1,968 Views)

Hi crossrulz

 

Are you able to help me with a triggering solution?

 

Regards

 

 

0 Kudos
Message 4 of 22
(1,878 Views)

Hi Compolitus,

 


@Compolitus wrote:

I need it to wait until the first proper value byte is received before reading in 256 steps. Greater than zero seems sensible to me as the first value from the frequency generating device is around 9 Ghz. 

I presume that there needs to be some sort of visa “wait until >0” before starting the read cycle. 


You don't need a "wait"…

You need to implement this pseudocode:

REPEAT
  data := VISARead(device)
UNTIL data > 0
save(data to file)
FOR i=0 to 255
  data := VISARead(device)
  save(data to file)
NEXT

The first loop reads the data UNTIL it is greater than zero. The 2nd loop reads the data and saves to file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 22
(1,871 Views)

Hi GerdW

 

Thank you. That looks straightforward. Not sure how to insert within my loop VI?  
Can you show example, please. 

Regards

Trevor 

0 Kudos
Message 6 of 22
(1,850 Views)

You should attach your VI!

0 Kudos
Message 7 of 22
(1,845 Views)

Hi

 

Sorry not able to show VI at this time. Will be back in office next Wednesday.

Regards

 

Trevor 

0 Kudos
Message 8 of 22
(1,838 Views)

Hi Ravensfan

 

VI Attached

 

Thank you in anticipation

 

regards

 

Trevor

 

0 Kudos
Message 9 of 22
(1,801 Views)

A few questions:

  • Why the first loop? If you set N=1 for a For loop, it almost always does nothing. You can just remove it and have the same effect.
    • Here there's a slight behaviour with the wait, but that isn't the most typical way to write it. Use either Stall Data Flow.vim, or a Flat Sequence Structure, or Synchronise Data Flow.vim to add delays in that way
  • You're currently reading the string, but presumably you want to convert it to a number. Do you know how to do that? Do you know the format of the string and the type of the output number?

You might consider reading about State Machines - there's a good chance it could be useful for this triggering behaviour. However, it isn't strictly necessary, especially if you only want to trigger once (not repeatedly).

 

Don't unconditionally write your data if you only sometimes want the values to be stored. Consider also how you want your text file to be formatted (and perhaps if a text file is appropriate, depending on the rate of data acquisition, but I think it should be fine).


GCentral
0 Kudos
Message 10 of 22
(1,792 Views)