Visa read function question

Hi, all:
I use Visa to write/read data from hardware through COM port,  the protocol is interactive communication, labview send commnd frame first, then hardware send back required data frame.if labview don't send command frame, then hardware send 0x00 continuously.  frame length is 10 bytes.
My idea is:  use Visa Write to send one frame down, then inside a While loop a Visa Read to get the data frame, when get the right data frame, stop while loop.
But I found the while loop can't stop, with probe, I found the data frame sliped once, it seems that Visa Read get the data then very soon it get 0x00 so that the comparison function can't finish to handle the data, then 0x00 arrives to the probe which sticked the input terminal of comparison funciton.
I solved this problem use a buffer string to store Visa Read's output read buffer, and make Visa Write and Visa Read a pair inside the while loop.
I wonder why the comparison function can't catch the data frame from Visa Read exactly.
Please refer to the attchment jpg file, it is not the real vi, just illustration
Attachments:
visaRead.jpg ‏23 KB

Is it possible that your device is already sending 0x00 when you start running your VI?  If so, you may get that in the serial port buffer.  Then, when you do the VISA Read, you will read 0x00 as the first byte, then the first 9 bytes of your frame (cutting off the last byte) so the comparison won't work.
EDIT: by the way, it's common to read the "Bytes at Port" VISA property, then feed that into VISA Read as the number of bytes to read, so that you read the entire buffer contents.  You can then scan that string for the expected data.

Similar Messages

  • Read in Binary form in VISA read function

    Dear All,
    I have connected my Device to the serial Port. and data read from the buffer is stored in text format. I want to view the data in binary format .
    Actually, i have performed the same function in Visual Basic. there also if i view the data in text format, it shows some junk values. but if i view the data in binary, it shows the actual data coming from the instrument .
    I dont know how to modify the VISA read function. can any one pls tell me how can i read the data in binary format?
    Thanks
    Ritesh

    Oops!  No it didn't.
    Lab VIEW 2012 (if that makes a dif)
    I'm using the VISA Read function to take ADC readings in from a microcontroller.  The VISA Read function outputs the data as a string.  Easy to convert the string to U8, either with the conversion function or type cast function, and works great except for a tiny corner case when the ADC reading is zero.  The VISA Read function treats the 8-bit zero reading as a null character and strips it out.
    Apparently, since this is done by the VISA Read function as it's building the string, type casting and or converting the output string from the VISA Read function doesn't "bring the zeros back".
    I've tried setting the VISA property "Discard NUL Characters" to false, and that didn't seem to help.
    My current work around is just to never have the micro send a zero ADC reading. 
    Anyway, I'm a Lab VIEW noob, so while this isn't essential to my project, I remain curious about how to send Lab VIEW serial data that isn't automatically considered characters, thrown into a string with all the zeros stripped out.
    Regards,
    Who

  • VISA Read function Read buffer problem in serial communication

    Hi,  I use VISA write and read function in serial communication app, the device continuously sends 0x00 if it is not receive a request from Labview program running on PC.
    And the request sent by labview is programmable. I met a weird problem, each time the request changes, the VISA read buffer output port still shows the last request firstly, from second time, shows the right request.
    It works like: Req code: ... 50, 51,51,51,50....;  VISA Read buffer: ...50, 50, 51, 51, 51, 51, 50....
    Please refer to the program.
    Attachments:
    readOne_test.vi ‏21 KB

    How are you running this?  You don't have a while loop around it.  Is it part of a larger VI?  Please don't tell me you are using the run continuously button.
    You don't have any wait statement between you VISA Write and your bytes at port.  So it is very likely the receive buffer is still empty since you didn't give your VI time to wait for the device to turn around and give a reply.  If you read 0 bytes, your VISA read string will be empty.  How does your decoder subVI (which you didn't include) handle an empty string?

  • VISA Read and Bytes at Port Timing Question

    Hi,
    I have a question that doesn't seem to be documented in the VISA Read function help. My application normally queries a serial instrument, waits, and then reads the port (with Bytes at Port property node wired to the byte count input of the VISA Read). However, I also need to be able to handle strings received from the instrument asynchronously without my vi requesting any data. So in the False Case in my vi (the True Case is where I write a command to the instrument) I have a Bytes at Port property wired to the VISA Read function's byte count input without using a VISA Write. This works fine if the \r\n terminated string is sent in one packet. However, sometimes there is a slight delay (only a few milliseconds) between characters. When that happens, the VISA Read returns, but I don't get the entire intended string. (Of course I know I have to keep reading in a loop until I get the \n and then assemble the received characters (sub strings) into my complete string for processing.)
    This is my question: What is the time delay between characters at which the VISA Read terminates? This is not specified. I assume it could be as little as just slightly more than 1 stop bit at the baud rate being used. Does anyone know? NI employees?
    When a string of more than one character (byte) is sent, as soon as the stop bit time has expired, the next start bit is normally sent immediately. Is it possible that if the next start bit doesn't come by, say, the mid-bit position time at the baud rate being used, the VISA Read returns immediately? Or does it wait at least 1 character time (at the baud rate)? This should be documented. Furthermore, for future versions it might be useful to add an input to the VISA Read to specify in milliseconds how long to wait AFTER the 'byte count' number of bytes have been received before returning the string (or character).
    Thanks for your help.
    Ed

    I looked up the PC16550D data sheet (http://www.national.com/ds/PC/PC16550D.pdf). On p. 19 it says:
    When RCVR FIFO and receiver interrupts are enabled, RCVR FIFO timeout interrupts will occur as follows:
    A. A FIFO timeout interrupt will occur, if the following conditions exist:
        - at least one character is in the FIFO
        - the most recent serial character received was longer than 4 continuous character times ago (if 2 stop bits are  programmed the second one is included in this time delay).
        - the most recent CPU read of the FIFO was longer than 4 continuous character times ago.
    The maximum time between a received character and a timeout interrupt will be 160 ms at 300 baud with a 12-bit receive character (i.e., 1 Start, 8 Data, 1 Parity and 2 Stop Bits).
    B. Character times are calculated by using the RCLK input for a clock signal (this makes the delay proportional to the baudrate).
    C. When a timeout interrupt has occurred it is cleared and the timer reset when the CPU reads one character from the RCVR FIFO.
    D. When a timeout interrupt has not occurred the timeout timer is reset after a new character is received or after the CPU reads the RCVR FIFO.
    So, this UART uses 4 character times to determine that no more characters are coming in. And the delay is baud-rate dependent. This makes sense because I see that at, say, 115200 baud I receive more "partial strings" than I do at 9600 baud (where the sending device has more time to send the next character)!
    Kudos for making me investigate this further! Thanks for listening. Hope this may help others in the future.

  • VISA Find function to VISA Resource Name

    Hi,
    Can anyone help me with this VISA question. I'm kind of new to
    instrument control, but have been using LV for quite a long time. I'm
    using version 6.02. I discovered the VISA Find Resource function, and
    thought it would be really neat to find the instruments that are sitting
    on my GPIB bus, and then make sure they are the ones I need for my
    testing. The Find resource works great, and returns an array of strings
    that are the resource names of the instruments. i.e. GPIB0::5::INSTR.
    However, the VISA Open (and all the other VISA functions) require a VISA
    resource name control (One of those pruple doohickies with I/O in it).
    I haven't been able to figure out how to get that string from the find
    function into the VISA resou
    rce name control (It looks like a pulldown
    on the front panel) so that I can do a *IDN? query to find out what
    instrument is actually at this address. I've tried property nodes, even
    looked at the invoke node, but to no avail. By the way, the property
    node DID have the VISA resource name, but it was read only.
    Thanks in advance for any help you folks might be able to provide.
    David Dupont
    Airvana Inc. http://www.airvananet.com

    Hello, David!
    I'll do my best to answer your question.
    In LabVIEW 6, you have to assign VISA aliases in Measurement and Automation Explorer. You can assign meaningful VISA Aliases to your instruments that you control using VISA in the Devices and Interfaces section in Measurement & Automation Explorer. The aliases can be used in your LabVIEW application development to refer to your instrument.
    Once you have assigned aliases in MAX, you simply place a VISA Resource Name Constant in your block diagram. Type the alias name into the resource name constant and wire the name constant to the VISA Resuorce Name input of the VISA Write and VISA Read functions to control your instrument.
    I hope this helps.
    Mark Ridgley

  • VISA read in exe file is not working

    Hi all,
    I am having problems with VISA read in an exe file created.
    I am trying to write to and read from a programmable power supply via RS232. The VI writes a command to the instrument to set the voltage level. It then writes another command, requesting the resulting current value. This value is then read by VISA read
    The VI is working fine on the development PC, which has LabVIEW installed. The exe file is also working fine on this PC. However, when I try to run the exe file on another PC (I've tried several) everything seem to work except for the VISA read functions. The voltage level command is sent, as well as the On and OFF commands, but the current is not read back.
    I guess there must be something I have missed in the installation. I am working in LabVIEW 8.5. I have created an installer and included
    Runtime Engine 8.5.1
    VISA runtime 4.5
    Is there something else I should do? I am really running out of ideas here...
    I hope someone has a clue about this!
    Clara 

    Clara-
    1. Have you verified that the COM port settings in Windows (check under device manager) are matching how you initialize them (Baud, bits, parity, and flow control) and that these match the power supply's settings?
    2. Also, are you trapping an error message after the attempted Read command (this will make it a lot easier to diagnose).
    3. Do you programmatically close the VISA session at the end of the program?
    4. You can always post the code to see if the forum members will catch the porblem.
    ~js
    2006 Ultimate LabVIEW G-eek.

  • NI VISA read stops at zero character, returning an 0xBFFF003E error

    Hi
    I’m trying to read some serial data from a UUT using the NI-VISA read function. The data is mostly text but does include some control codes. The first of these appears after the ‘OK’ in the Serial Bytes window on the front panel. More text should follow but for some reason, the read function stops at the first zero character (index 144 in the Byte Array), and returns an 0xBFFF003E (-1073807298) error. I found another thread where someone had a similar problem and I’ve tried the fix for this plus a few other things, but nothing’s worked. If I use Hyperterminal, the entire data block is returned as it should be.
    I wondered if this was anything to do with the 7.1 version of Labview I’m using (upgrade is on the cards). The version of NI VISA I’m running is 4.2.
    Very much appreciate any thoughts.
    Thanks
    Bruce

    The error code itself is a generic VISA error which often happens with USB to RS-232 interfaces. Does your device connect to the PC through USB as a virtual COMM port? If so what chip and Windows driver is it using?
    Also your function somehow looks wrong. The only criteria for the read loop to terminate is if there is an error on the VISA read or the Teststand termination status gets true. Generally if you use VISA Bytes at Serial Port you are almost always doing something wrong! That function does absolutely not synchronize with anything in your data. You will read whatever is there at that moment and that could be a partial message, no bytes at all (LabVIEW is typically many times faster than any serial device even if it is super high speed), or multiple messages.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • VISA Read gets incorrect data from serial connection

    I am having difficulty using the VISA functions in LabVIEW to read data from a virtual COM port. Data is being sent from a serial to USB chip via a USB connection using OpenSDA drivers. I have a python program written to read from this chip as well, and it never has an issue. However, when trying to achieve the same read in LabVIEW I am running into the problem of getting incorrect data in the read buffer using the VISA Read function.
    I have a VISA Configure Serial Port function set up with a control to select the COM port that the device is plugged into. Baud rate is default at 9600. Termination char of my data is a newline, which is also default. Enable termination char is set to true. A VISA Open function follows this configuration, and then feeds the VISA Resource Name Out into a while loop where a VISA Read function displays the data in read buffer. Byte count for the VISA Read is set to 20 so I can read more of the erroneous datat, however actual data will only be 6-12 bytes. The while loop has a wait function, and no matter how much I slow down the readings I still get incorrect data (I have tried 20ms thru 1000ms). 
    The data I expect to receive in the read buffer from VISA Read is in the form of "0-255,0-255,0-255\n", like the following:
    51,93,31\n
    or
    51,193,128\n
    And occasionally I receive this data correctly, however I intermittently (sometimes every couple reads, sometimes a couple times in a row) get incorrect readings like this:
    51,1\n
    51,193739\n
    \n
    51,1933,191\n
    51,,193,196\n
    51,1933,252 
    51,203,116203,186\n
    Where it seems like the read data is truncated, missing characters, or has additional characters. Looking at these values, however, it seems like the read was done incorrectly because the bytes seem partially correct (51 is the first number even in incorrect reads).
    I have search but haven't found a similar issue and I am not sure what to try from here on. Any help is appreciated. Thanks!
    Attachments:
    Serial_Read_debugging.vi ‏13 KB

    The first thing is that none of the error clusters are connected so you could be getting errors that you are not seeing. Are you sure about the comm parameters? Finally, I have never had a lot of luck looking for termination characters. You might want to just capture data and append each read into one long string just to see if you are still seeing this strangeness.
    What sort of device is returning the data? How often does it spit out the data? How much distance is there between it and your computer? Can you configure it append something like a checksum or crc to the data?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • VISA Read Timeout and VISA Write not working

    I'm writing a program that sets a triangle wave pattern voltage (using Triangle Wave VI) to a DC power source (GWInstek PST-3202) through a RS-232 connection.  I know my instrument parameters are set up correctly because I've been able to control this power source using a different VI with the same parameters.  I also know I am connected to the power source because I can talk to it using MAX.  I have a string indicator before my VISA Write statement that shows me the command being sent to VISA Write.  It shows the correct syntax for setting a voltage on this instrument.  However, when I run the VI, the voltage is not changed on my instrument, even though the correct command is sent to the instrument.  After the VISA Write operation I have inserted a VISA Read function in order to read the newly set voltage from both a numeric and a waveform indicator.  Using the Error Out cluster I am able to see that there is a timeout error from VISA Read.  I thought perhaps I needed to clear or flush the buffer after each Read statement, but that didn't work either.  I'm stumped as to why VISA Write isn't writing to the device.  I have included my VI below, as well as the initialization subVI for the power supply.  
    Attachments:
    Triangle Volt Mod.vi ‏27 KB
    GW Instek initialization.vi ‏18 KB

    Yep, you need to append the End of Line character to the end of your command.  And for your read to work properly, you need to request the data.  That requires a querry command to be sent.  Look closely at the differences in command and communication structures between your working VI and your mod.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to run vi continuous​ly when VISA read timeout happens

    Hello,
    I am using LabView 2010 to read an Agilent 6000 series Oscilloscope. The Oscilloscope reads data from another experimental machine which fails occasionally due to sample failure. When the machine fails, it stops sending signal to the oscilloscope and leads to the VISA read timeout error and the whole vi is terminated.  Is there a way that I can continuously run the vi when the error happens? For example, when the error happens, it stores the error in the error wire. When the vi read the error code from the wire, it sends a command to stop my experimental machine then stop the vi. 
    So far, it just simply stops during executing the visa read function. In this case, why do we have error in and out? The vi simply stops when the error happens. 
    Thanks
    Lawrence
    Solved!
    Go to Solution.

    I'll start of with automatic error handling. By default, LabVIEW enables the automatic error handling. So consider the case like the one below,
    If let's say the VISA Read returns an error, but you did you pass the error information to VISA Close, what will happen is that LabVIEW will highlight the VISA Read (since the error comes from that function), pause the execution at the VISA Read and an error dialog box will appear. From the dialog box, it will prompt to either continue (Move on to the VISA Close) or stop (LabVIEW will stop the VI at VISA Read)
    Now, consider another scenario like this,
    By passing the error information from one function to another, let's say if VISA Read returns an error, that error will pass to VISA Close and finally to Simple Error Handler.vi. So Simple Error Handler will generate error dialog box after all the VISA operation is completed. This is called manual error handling (It can be enabled by just wiring the error information from one function to another and terminates at Simple Error Handler).
    http://www.ni.com/gettingstarted/labviewbasics/han​dlingerrors.htm
    As for VISA Close, here is the information about VISA Close.
    http://zone.ni.com/reference/en-XX/help/371361K-01​/lvinstio/visa_close/
    See that button on the left side of this post...
    If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~

  • VISA read timeout error

    Good day to all,
    I have this problem with my LabView program. It is being used to interface with a Energy Meter to retrieve the data. I am able to execute "Open" and "Write" VISA, but am unable to execute "Read" VISA. Attached below is the screenshot of the error.
    EKI1521 is being used to interface serial connection from the meter to ethernet, connecting to the computer with
    labview program. Attached are the settings for the EKI1521.
    This is extracted from the main program after narrowing the problem down to the VISA Read function. The subVIs in this program are proprietary protocols of the meter and does not contribute to this Reading error.
    It might be interesting to note that I am able to run another program to interface with another meter using Modbus protocol. It also used the same EKI1521 with the correct VCOM settings. (This should free the EKI1521 from any faults). 
    Thanks & Regards,
    Andrew
    Attachments:
    1.png ‏169 KB
    2.png ‏210 KB

    Hi,
    Stop me if I make a mistake, but you don't set Visa properties in your Labview code (type, baudrate... etc).
    Best regards,
    V-F

  • VISA read timeout

    I dont know why im getting a timeout error at the VISA read function(error says "timeout expired before operation completed"). I made sure the Labview serial port and my devices serial port are configured exactly the same. I even tested hyperterminal with the same port settings as in labview and it works perfectly but my labview program gives me an error. My device terminates each command it sends with a carriage return so i set up VISA READ to stop reading data when it  encounters the CR character. I also made sure the carriage return was infact being sent by my device. Any thoughts?
    Solved!
    Go to Solution.

    I think it's not seeing your termination character on the read and/or write.  When I send a string to the serial bus, I always use "Concatenate Strings" to add the appropriate termination character(s) to the end.  Assuming your read termination is CR/LF, I've always had better luck stopping on the LF and stripping the CR with "Trim Whitespace."
    Also, don't be afraid of making the timeout a second or two.  If everything is going right, it will (normally) give the serial port plenty of time to complete its operation, but if things are going wrong, it will give you time to "notice" something is wrong.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Visa Read Overrun Problem

    Dear all,
    I am using VISA Read Function to read data coming from my Hardware.
    The data is coming really fast. The H/W is sending 1600 bytes after every 10ms.
    I am using Event Structure(timeout event) to check whether 1600 bytes are at port or not. Timeout is set to 1ms. i even tried with 0ms.
    Baud Rate = 3000000.
    but the program is giving Buffer Overrun problem when i am trying to read data using VISA Read.
    I have set the buffer size to 64000 but with no success. The problem still seems to persist.
    i have played around with Receive buffer of COM Port in device manager. i tried all the values from 64 to 1600, again with no success.
    every time i run the program i get an error stating,"A character was not read from the H/W before the next char arrived" at VISA Read Function.
    and i am not doing anyother processing other than Reading data from the Port in the timeout event. 
    What could be the problem?
     Thanks,
    Ritesh 

    Ritesh,
    The over-run is still caused by the driver of the hardware.  What you are observing is that the driver is able to keep up with bursts of data coming into the port.  So for the first few thousand bytes coming in, there is no error.  However, after a while, the driver falls behind and cannot keep up (hence the over-run error).
    How does FTDI recommend that you use their ports in LV?  VISA may interact with the driver in a different way or set properties to different values.  All of this can have an impact on how the driver performs.  Also, this DLL that they provided may not return overrun errors the same way that VISA does.  The malformed string may just be missing data that was missed because of an over-run error.
    You have not mentioned anything about the types of flow control that are available to you.  The only real way to prevent over-run errors in data intensive communication is to have ways to hold-off the data (flow control).  Since the data will be interrupted for a fraction of a second, the driver will have a chance to get the data out of the hardware in time.  Communication will automatically resume once the data is read out of the hardware.
    Thanks,
    Steven T.

  • VISA Read Losing Characters off the end of the output string

    Hi,
    So I am writing a VI to take an output string of data from an ardunio Uno and parsing it. I am using the Read Visa vi to grab the string from output of the device. In the end I will be connecting a device that actually gives value in this type of string  format : (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*).
    So after a large number of loops, the program starts to drop the last few characters of the string that it outputs. So the string output from Visa Read will read something like (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,). The only way to fix this problem after it has occured is to completely close labview (all the way). Once I open it again and start running the program, all is fine in the world.
    Anyone ever have this issue? I have been trying to debug this in different ways and the only weird symptom that I have other than the Visa Read function losing a few characters of the string is the fact that looking at the Bytes at Port after I Visa Read, is that it starts showing five bytes instead of zero. 
    attached is my most recent attempt at solving this issue. 
    Note:  The Ardunio outputs a string of this format every 2 seconds with the values being incrimental over a specified range.(#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*) 
    Solved!
    Go to Solution.
    Attachments:
    Ardunio(StringOutput).vi ‏36 KB

    So i did a long data collect and It looks like ever 43minutes and 24 seconds the system goes from cutting off the last 5 characters to not cutting off the last 4 characters.
    As I cant see how Labview would be causing that, I am going to try and dig into the Ardunio and solve that issue... hopefully when thats done I can simplfy my code like you guys pointed out.
    Thanks!
    Attachments:
    overnight_11_18.csv ‏3001 KB
    Overnight.png ‏146 KB

  • LabVIEW VISA Read Byte Count Limitation​s

    I have written a program that acquires and analyzes data from the Tektronix TDS3032B oscilloscope. The scope can transfer either 500 or 10,000 points. However, it seems the VISA Read function (I am using LabView 6.0.2) is unable of reading enough bytes to receive the entire data string. I am almost certain that this is not a timeout issue because I can set the timeout extremely high and still get the same behavior. What would be the best way to fix this problem?

    I assume that you receive a timeout error when trying to read a big string (many points). Did you try one reading with a low byte count, less than the length of the expected string? ... or fast consecutive readings ?
    If you are able to receive parts from the expected string, the problem looks to be buffer related. Thus, you can try to use "VISA Advanced > Interface Specific > Set I/O Buffer Size" to set enough room for a large string.
    Hope this helps

Maybe you are looking for

  • Error Message Downloading iOD 5.1 to  4th Gen iPod Touch?

    I have tried to install iOS 5.1 on my iPod a bunch of times now, and each time I get the same thing: There was a problem dowloading the doftware for the iPod. The network connection timed out. Make sure your network settings are correct and your netw

  • Start/End Date parameters that check day of week and using to set default values.

    Hi, I've got a report that presents data between a start and an end date. I want it to check if it's a monday and present data from the previous week, otherwise present data from this week. For the "Default" value of parameter @startdate, I've got th

  • Chimes, Chimes, and more Chimes

    Sometimes when I start her up, the chimes sounds many times. I hit the start button to shut it down and then I re-start. Everythings fine. What's wrong? Boy, I never had ONE PROBLEM with my old Mac Mini... SP

  • Dynamic SELECT with FOR ALL ENTRIES IN

    Hello Xperts, we are having a bit of trouble with the following SELECT FIELD-SYMBOLS:         <itab1>      TYPE standard table.   ASSIGN ATTR_T_I->* TO <itab1>.     select       FIELD1       FIELD2     from DBTAB1     into CORRESPONDING FIELDS OF tab

  • OSD Request User State Storage fails after SCCM 2012 upgrade to R2

    After SCCM upgrade from SP1 to R2 OSD fails on Request User State Storage. Error: Task sequence: XXXXX has failed with the error code (0x00004005). For more information, contact your system administrator or helpdesk operator. In smsts.log: ==========