Serial port interrupt

I am a new user of LabView. I have been working a project for a month. I can explain shortly:
I used serial visa in my application. I configure all necessary thing for using serial port (port number, baud rate, etc.)
I configured the time out also, but I do not want to use it. Because when the time out finish serial visa read the port. If there is nothing
at the port read a empty string (""). It is a problem in my application.
I want to read the port when anything written. (when a interrupt occur) 
May be it is just an easy problem but I could not find.
Thanks for your help.

Horseman,
I am trying to understand exactly what you are trying to do. If I understand you correctly, your code is wait for event is timing out and then it goes ahead and tries to make a read anyways. The read then returns nothing, so you would like your code not to read at all if it times out. Is this correct? In this situation, you would want to make a case statement that would have a case for when there was characters to read, and separate case for the time out to do nothing.  Was that what you were looking to do?
Cheers,
-Marshall R
National Instruments
Applications Engineer
One stop for all your NI-VISA Support
GPIB Support has a new homepage

Similar Messages

  • Send DAQ measurement results through serial ports

    Hi, All
    I use PCI-6034E for measurement. After DAQ gets data, I send them to another computer through serial port (com1). I write a Virtual C++ program, which calls NI-DAQ library functions to implement DAQ data sampling (multiple channel scan) and sends measurement data to another computer through serial port under request. DAQ data sampling and serial communication are implemented in two threads. They are running concurrently. They share a global memory for measurement data. The serial communication thread will do infinite wait and send data only when another computer sends a request through serial port.
    I met two problems. First, when I reduce the size of DAQ measurement buffers (piBuffer and halfpiBuffer, I us
    edouble buffer model), DAQ measurement is often interrupted by the message "[DAQ_DB_HalfReady] returned NI-DAQ warning 10846. Your application was unable to retrive data from the background acquisition buffer fast enough so the unretrieved data was overwritten with new data. ...". I want to get run time data so I need to reduce the buffers as small as possible. How can I solve it ? The second problem is that the serial port gets error data (nothing) from measurement computer sometimes, especially when DAQ initializes itself and finishes work. It looks like that there is a conflict between DAQ and serial port. Does anyone have similar experience about this? Any suggestion?
    Thank you in advance.
    Le Cai

    Le Cai,
    You are correct that the number of scans to read is equal to half of the buffer in double buffer mode. I was mistaken and referring to a standard (non double buffered) operation. However, you can increase the size of your buffer without affecting the period of your acquisition. A buffer of 60 is quite small and, as such, will be more prone to overflow errors. The rate is actually set through the DAQ_Rate() and DAQ_Start() functions. For more information on these functions and how to configure the scan rate, please see the NI-DAQ Function Reference Manual.
    NI-DAQ Function Reference Manual for PC Compatibles
    http://digital.ni.com/manuals.nsf/websearch/1630A0B68738B269862567C1007A2912?OpenDocument&node=132100_US
    A good place to start would be the example titled, "DAQdoubleBuf.c" which ships with the NI-DAQ driver. If you installed the examples for Visual C++ when you installed the NI-DAQ driver you should be able to find this example in the \Program Files\National Instruments\NI-DAQ\Examples\VisualC\AI folder on your computer. This example would be a good template as it is very close to what you are trying to do.
    If you observe that you only receive the overflow error when you are operating the two threads, thus ruling out the buffer size as being a potential problem, you may want to examine whether or not your second thread is placing a lengthy exclusion on your data buffer during the period when your first thread is trying to move the data. If your first thread has to wait during the half-buffer transfer this could easily cause the overflow, as the acquisition would be running but the transfer would be paused. Instead of placing a mutual exclusion around one piece of global memory you could try using a queue instead. A queue approach will allow you to pass the data from the first thread into a queue to be read, when convenient, by the second thread. In this method the first thread would never have to wait as the transfer would just be a handoff.
    Regards,
    Justin Britten
    Applications Engineer
    National Instruments

  • Serial Port of Microsoft

    Hello,
    I have a program in LabVIEW which read from the serial Port.
    I would like to know the name of the memory where is saved the information from the serial port in the Operating System of Microsoft and where LabVIEW reads the information.
    I would be very glad if somebody could help me in this topic.
    Ramon

    Ramon,
    you are on the wrong track here. This is completely hidden to the end user and/or application programs. This is necessary, because in multitasking OS it would take much too long for application programs to react to direct HW interrupts as they are used in serial communication. Long words meaning is: Let LabVIEW handle all this stuff. Just open the serial port, configure it, send some text to it and/or read strings from it. Close the port when you are done. Its that simple in first hand!
    It might become more complicated when communication protocols and protocol error handling comes into play, but this is beyond you actual Q.
    Hope this helps!
    Greetings from Germany!
    Uwe

  • Serial port CTS monitoring

    I would like to know how to read the status of the Clear To Send (CTS) line.
    I need this in order to implement a write with timeout vi, required when
    using the RTS/CTS handshaking protocol.
    Thanks
    Gilles

    Hallo, Gilles,
    Du meintest am 21.09.99 zum Thema serial port CTS monitoring:
    > I would like to know how to read the status of the Clear To Send
    > (CTS) line.
    advanced/memory/in port
    If you run LabView under Windows NT, you need "hwaccess" from the NI ftp-
    server for direct port access.
    CTS is line 4 (2^4) at (port base + 6), the MSR (modem status register).
    Ralf Browns interrupt list (especially the "ports.lst") shows many
    details.
    Viele Gruesse!
    Helmut

  • Unable to capture data from Serial port using LVRT2010 in single core pentium 4 machine

    I am using application written in Labview using windows Labview
    Runtime environment 2010. Application creates a tunnel to intercept data from
    Serial port.
    My problem is, Currently, I am using single core Pentium
    processor. When I am trying to intercept the data between COM1 and COM7 (COM 7
    is a virtual port) it is not able to capture data.
    When I am running Labview RT environment using dual core
    processor machine it is running normally. I wonder whether it could be the compatibility issues with
    single core Pentium processor.

    Hi Magnetica
    Are both of the machines running the same runtime engine,
    drivers ect?
    Have you had RT applications running on this
    machine before?
    Is the development computer a 64bit machine?
    The processor is a supported model (See link below).
    http://zone.ni.com/devzone/cda/tut/p/id/8239
    Regards
    Robert
    National Instruments UK & Ireland

  • Problem on WinXP / Labview 6.1 with VISA (serial port)

    There is a problem on WinXP / Labview 6.1 with VISA which i use to poll the state lines of the serial port. The only functions that i use are "VISA Open", "Find Resource", line state properties and "VISA close".
    On my own machine (WinME) it works fine as a standalone application (with runtime engine in the same direction), even if i rename the Labview directory so that Labview is not found.
    From my VXIpnp directory i deleted all but these files:
    directory "Win95",
    subdirectory "Bin" containing "NiViAsrl.dll",
    subdirectory "NIvisa" containing "visaconf.dll".
    When shipping this to WinXP (and copying "VXIpnp" to the root directory), the serial port was not found, so i renamed the direction "Win95" to "
    WinNT", but this did not work also.
    I installed the VISA server, although it seems not to be required -- no result.
    Final question:
    What must i do for distributing the program as a standalone application for all windows platforms?

    Hey Joachim,
    In order to create an installer that includes the VISA Run-time engine for serial IO you will have to purchase LabVIEW 7.x. See screen shot. This packages a small compact version of the run-time that can only be used for serial, but it takes up much less space. The installer that I created has my application, the LV Run-time, and the VISA run-time and it is about 26 MB.
    That is much smaller than if I had to include the 32 MB LV 7.1 run-time and the 14 MB VISA run-time separately. It would have been even smaller if I would have uncheck some of the items that I wasn't using.
    -Josh
    Attachments:
    advanced.JPG ‏31 KB

  • Using a PS/2 keyboard on a Sparc workstation through the serial port

    We have recently migrated an application that used to run on a PC, to now run on a Sparc Workstation. This is a SunBlade 1500, running Solaris 8. The application is running in a dedicated console which has a fitted keyboard and trackerball that have PS/2 connectors and cannot be changed.
    We need a way of connecting the PS/2 keyboards to the serial ports of the Sparc workstation. We already have a piece of software that will read ascii values from the serial port so we definately want to go through the serial ports.
    Can someone please suggest what converters will be required to get the output of the keyboard and trackerball as ascii input to the serial port.

    Actually, that's not a bit perverse, at all.
    Jonathan's suggestion is a standard method of connecting to a server.
    (null cable between the computer serial ports)
    ... see the Solaris man pages.
    man tip
    TeraTerm and Hyperterminal are customarily used on a PC running some dialect of Windows.
    The 'tip' command is all that's necessary between Solaris systems.
    PS/2 is not a serial connection, but is a keyboard/mouse interface 'invented' by IBM when they offered their XT-class PS/2 line of desktop systems, back in the 1980's.
    I found this next link by using Google:
    http://members.chello.at/theodor.lauppert/computer/ps2/
    The smaller DIN ports were more compact than the AT-class keyboard ports and the mouse moved from a serial port to a dedicated mouse port.
    Serial communication devices are not keyboards, per se,
    and keyboards are not serial communication devices.
    You need other hardware in between to translate what the human being sends, and another computer is a common method to accomplish that translation.
    Having said all that ...
    Since you cannot change the dedicated console hardware,
    I suggest you go to the manufacturer of that console equipment
    and have them suggest some sort of serial-to-serial interface lash-up.

  • Using a serial port under j9.. How?

    I am trying out j9 on an ipaq. I am trying to get javax.comm to work.
    When I call CommPortIdentifier.getIdentifiers ();
    I get java.lang.string.NoSuchMethodError: java/lang/String.<init>([BIII)V
    It would appear that the javax.comm package was implemented using a now deprecated String method, and that IBM has chosen not to implement deprecated methods in it's j9 vm (I get the same issue trying to run swing.)
    One would think that what is needed is an updated javax.comm package. However, there doesn't appear to be a javax.comm package on Sun's site, let alone an updated one. Whats going on here? Can someone give me an idea of how Sun and/or the JCP thinks about developers who want to use serial ports?
    Is there a workaround? A different way of talking to a serial port? Or should I abandon j9? I should add that I got my software running just fine on nsi.com's creme vm (javax.comm and swing too) and it worked without any hassles. It even understands jar files (is there a reason why IBM insists on having a link file?). However, the reason I persevered was that a) j9 is cheaper and more importantly b) nsi.com don't seem terribly keen on actually selling their product. I have lots of references to them selling their vm in bundles of 40 ($1000) which is a bit ouchy but hey I'm not paying for it. But, you'd think the nsi.com people would actually confirm this on their site?
    So.. can it be done? And why, in the world of embedded systems (my field) and now lots of phones and pdas, is so little attention given to the humble serial port? It doesn't matter how fancy the protocol is, underneath it all is a UART. grumble
    -Russel

    Hi Russel,
    I will probably soon be in the position you are in trying to get this to work. I found the following page which offers some promise.
    http://www.intrinsyc.com/support/I-Linux/405-cube/misc/smf_serial_port_access_example.htm
    Mike

  • I have problem with delay in serial port

    I have problem with serial port. I have connected two computers by serial port and I need to create program in Labview for transfer strings using start bits and stop bits. My problem is that my program is working quite well ...when I press start bit it starts to concatenate strings and if i press stop bits it stops...this is the purpose of this program...but problem is that it working only with delay...and need that this program dont need delay, because it can only concatenating data depends on delay from start bit....I wana solved problem with delay...I dont want using delay process in my program, but allways when I try to delete this delay it stop works correct
    here is my program

    Ok this should be simple - if I understand you correctly.
    You have the VISA session initialized with read termination character enabled.  So reading the number of bytes at port is NOT the correct way to read from the port.  Set the read number of bytes to something large (say 4096) and the read will return as soon as a termination character is received (or timeout).
    You'll need to make sure the sending device is configured to send termination character on writes (you can set that with a VISA property node)  and that you are sending the correct termination character.  The default is 0x0A (newline).
    Jeff

  • Open and configure serial port

    Hi,
    when i use the function configured serial port, i can work with it.
    for which case i need the function open port. do i need both an in which order?
    thanks florian 

    Hi florian
    check the help examples
    Attached png file shows  the example.
    chow
    xseadog
    Attachments:
    serial.PNG ‏39 KB

  • How do I process serial port strings as bits

    In response to my commands, my instrument is sending bytes to my serial
    port. In one instance, 2 bytes are received. I want to treat these 2 bytes
    as a group of 16 bits.
    The VISA and Compatibility Serial functions return these bytes from the
    serial port to Labview clearly labelled a "string".
    Everything I can find in the way of Labview functions and .vis don't want to
    do bit twiddling, bit swapping, and bit dropping, with "string" data.
    I thought "hex string to number" could be used here, but I can't find a way.
    The 2 Bytes in question can be represented as hex, but the data are not the
    ASCII codes for the hex representation of a binary number, they are the
    binary number. This "hex string to number" seems to want ASCII c
    odes.
    You can feed a hex number typed into a "control" box wired into "hex string
    to number" and you get a meaningful number. You can feed the 2 bytes from
    the serial port into an "indicator" set to read in hex and you get a hex
    number that is a correct representation. But that is Labview handing them
    around to itself. I need to get my "hands" on them.
    I can't feed those same bytes that show up as a correct hex representation
    in an indicator into the "hex string to number" or anything else, so far,
    and get a number that is useful for further processing.
    I thought "variant to data", but I can't find enough reference material to
    understand how to use it. A boolean array seems like a bit of a weird
    approach, so I thought I'd ask before I looked into that.
    I'm used to dealing directly with binary numbers on the processor stack, I
    call them whatever I want, and turn them into anything I feel like.
    I'm sure I'm staring the solution in the face, but I can't find any way to
    persuade
    Labview to treat this "string" data as 16 bits.
    I've got the 16 bits, which is better than not having them, but I don't have
    much hair left.

    duh, well I finally discovered the "Unflatten from String" function. A guy
    just feeds in the bytes he's collected from his serial port that Labview
    thinks are a "string", and out come lovely little unsigned 16 bit numbers,
    or whatever other type of number he wants to turn the bytes into. And there
    are great little bit twiddlers available after that, like "swap bytes", and
    you can mask out bits with the logic operators, why this is fun. There's
    nothing like being a moron...... fly me to the moon...................
    "David Lewis" wrote in message
    news:[email protected]..
    > The two bytes would come from a serial port read.vi in Labview, classed as
    a
    > string. For instance, D3 and 02. The output wou
    ld swap the two bytes,
    i.e.
    > to 02 and D3, consider the two swapped bytes as 16 bits, drop the six most
    > significant bits, and output the ten bits that are left as an integer
    > classed by Labview as some kind of number, not a string.
    >
    > Your example StringToBits_Converter.vi I found on the ni.com site
    > unfortunately gives an error message and refuses to open on my system
    saying
    > it comes from a newer version of Labview 6 than I am running. Mine says
    > 6.0.1b3. Thank you very much anyway.
    >
    > "FightOnSCTrojan" wrote in message
    > news:[email protected]..
    > > In another words, you want to create a VI in which the input is 2
    > > strings (i.e. AB) and the output is the converted array bits (e.g.
    > > 1010101010101010)?
    >
    >

  • KM2M serial port not working in Linux

    I noticed a few Linux postings so I thought I'd give this a shot. I'm running Fedora Core and for some strange reason I can't seem to send any communications out to the ttyS0 (COM 1) or ttyS1 (COM 2) ports.
    Does anyone have any suggestions on making it work?
    Thank you.

    No, your code had no termination characters at all - automatic or not. The enable termination character for the VISA Configure Serial Port is only for reads. Just like the help explains.
    And while you should check the download page for updates, LabVIEW comes with the 34401 driver.
    Message Edited by Dennis Knutson on 12-19-2009 05:49 PM

  • Problem in using serial port.

    I am using serial port to get data from a fusion splicer. The number of bytes at the port is 4096 but the read buffer of VISA read is empty. I am reading the same number of bytes. Can any one tell me what is the maximum size of VISA Read buffer? I am trying to put the contents of the buffer in a file. I am using labVIEW 6.1 on linux.I am also attaching the VI.
    I also noticed this problem...If I read the number of bytes in the serial buffer many times, sometimes it reads it as 0 and I have to keep trying until it reads this 4096 bytes.
    Thanx for any help.
    S.Vijayalakshmi
    Attachments:
    serail_comm.vi ‏52 KB

    Hey Viji,
    In your application it looks like you are just checking to see how many bytes are at the serial port. Is it possible that your application is check for the serial data at the port before the data actually gets there. If you are looping this code as a subVI or just running it over and over it is possible that one of the iterations could occur faster than your device can write the information to the bus. In this instance you are checking the number of bytes at the port and there might not be any there yet. In this case the port reads 0 as you have designed it.
    If you want the read function to wait and always read 4096 then don't wire the bytes at port to the read function. Just wire a constant/control equal to 4096 to the read function instead o
    f the bytes at port. In this case, if there are not any bytes at the port the read function will wait for the bytes to show up or until the timeout period is reached.
    I would also, suggest lowering your time to something more reasonable, because if your instrument quits transmitting your application is going to wait for 33 minutes. That is a long time for a program to hang.
    I hope this helps out.
    JoshuaP
    National Instruments

  • "Example on reading combined signals from a serial port and separating them for display purposes". I am a beginner in Labview and would appreciate if anyone help with that

    I am working on a wireless vital sign monitor. I have 3 signals; heart rate and temperature. I filter and amplify the signals before converting them into digital form. I then pass them via MAX232 before passing them to RS232 serial cable.
    I am therefore working on a program to receive the combined signal and separate them.
    I have come across serial read and write examples on ni.com but am looking for one where I can actually separate combined signals and display them separately.

    Reading the serial port will give you a string. How you divide the channels depends on how the data was formatted before it was sent over the serial channel.
    If you are designing the instrument, as it seems from your query, then you can set up any form you wish. If your data is always floating point numeric, you could use space or tab characters to separate data words. You could use and XML format. If the instrument is provided by a vendor, contact them for the protocol.
    If tabs are used between words and returns between sets of readings, the resutlant string can be interpretted by the Spreadsheet String to Array function in LV.
    Things to avoid are characters often used by serial communications systems as control characters. Carraige returns are
    often used as command terminators by serial protocols, but may also be used by the port.
    Lynn

  • Help with reading information coming from a software into LabVIEW through Serial port

    Hi,
    I am new to LabVIEW and also an amateur in using RS232 for communication. I have this software that has these icons like speed increase/decrease, elevation up/down, start/stop. Now, when I click these buttons on the software, they perform the appropriate functions. For example, if I press start button, the signal must go through a serial COM port into LabVIEW to start the machine. How do I do that? How do I find what format the code word is when I press a button on the software? And how to decode the information to read whether the button pushed is start etc...? Any help would be appreciated.

    I may not be perfect, but I'm all I got!

    That information would be in the programming manual for the device you're controlling. Unless you have a device that has no documentation or you cannot get the documentation that's the first place you should look. If you cannot get the documentation at all then you've got some reverse-engineering to do. To do this you will either need a serial port sniffer (a hardware device), or you can try to use a software-based port capturing program. On Windows PortMon is the most prevalent. This will show you how the port was configured (baud rate, stop bits, etc). Warning: the information is technical.
    As far as how to get it running in LabVIEW, you should take a look at the serial port communication examples that ship with LabVIEW. The most problems occur in figuring out how to (a) terminate a write command, and (b) determining when to stop reading. For (a) this is typically done by appending a carriage return or linefeed to the command. This is device dependent. For (b) this is usually done by the byte stream ending with a character like a linefeed. Again, this is device-dependent. 
    You may also want to peruse this KB article: Serial Instrument Control Tutorial. There are also lots of tutorial on the internet for basic tutorials on serial port communication.

Maybe you are looking for