04-16-2021 10:56 AM
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
04-16-2021 11:11 AM
@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.
04-16-2021 12:35 PM
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.
04-21-2021 02:25 AM
Hi crossrulz
Are you able to help me with a triggering solution?
Regards
04-21-2021 06:27 AM
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…
04-21-2021 10:45 AM
Hi GerdW
Thank you. That looks straightforward. Not sure how to insert within my loop VI?
Can you show example, please.
Regards
Trevor
04-21-2021 11:10 AM
You should attach your VI!
04-21-2021 01:47 PM
Hi
Sorry not able to show VI at this time. Will be back in office next Wednesday.
Regards
Trevor
04-28-2021 08:03 AM
Hi Ravensfan
VI Attached
Thank you in anticipation
regards
Trevor
04-28-2021
08:26 AM
- last edited on
05-13-2025
03:34 PM
by
Content Cleaner
A few questions:
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).