Send to the request by serial port

HELP !!!
Bonjour... et merci de bien vouloir me dépanner ...
J'ai une application où un automate programmable (TSX57 de Schneider El.) doit communiquer avec un PC par une liaison série RS-232 pour échanger des informations.
Du côté du PC, j'ai Labview 6.1 comme outil de développement avec IMAQ Vision Builder.
Je désire que l'automate donne un signal au PC (par le port série), pour que ce dernier exécute un Vi, préalablement généré par IMAQ Vision Builder, qui émettra des informations via l'automate.
Avez-vous un exemple en Labview ou des explications claires qui me permette d'émettre des caractères "à la demande" du récepteur ???

Vous devez m'excuser parce-que je ne peux pas essayer une reponse en Francais, mais...
You will need a loop running in which you read one or more characters from the serial port (using a suitable timeout) and maybe accumulate them in a shift register until you determine that a valid message has been received (or your program has to exit). Then you either carry out your processing or discard the message if it is invalid. I'm sure that looking at the VISA examples will help you work out how to do this. The VISA termination character property can be very useful if your messages are always terminated with a known character such as a CR.

Similar Messages

  • Send command to modem using serial port and capture the response in the labview

    hello.
    I am doing my shool project.
    I want to send command to modem using serial port and get the response in the labview.
    When i run my program and enter"AT", only messy code will be displayed.
    can anyone help me? thanks 

    Dora0512 wrote:
    Thanks for you all. My partner got it already.
    I am doing send sms part.
    Can anyone tell me why my program is not so steadily?
    It means this program can run. But somtimes I cannot receive sms. sometimes can
    Basically, it is not well-written from both a LabVIEW and a communications point of view.  Unfortunately, I can't elaborate because today is an exrtremely busy day at work.  I'm hoping this bump will prompt someone to help you with your problem.  If you could also provide us with the programmer's guide or the manual for your equipment, that would be extremely helpful.
    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.

  • 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

  • The "VISA Configure Serial Port" VI will only run at 9600 Baud

    I have written a Serial Port monitor "RS232 RW.vi"  that works for the most part. The problem is that it will not respond to alternate port configuration settings.... For instance: the default RS232 Serial port configuration is:
    (COM1,9600 baud,8 data bits,1 Stop bit, None no parity)
    As a test, I am using a Null Modem Cable to connect From my LabView Com1 port to another PC running RealTerm Serial Port Monitor.. Using my newly designed "RS232 RW.vi"  With port settings of (COM1,9600 baud,8 data bits,1 Stop bit, None no parity),  I can send and receive data back and forth all day long no problems....
    However, if I configure the "RS232 RW.vi"  port to any other configuration, such as (COM1,2400 baud ,7 data bits,1 stop bit, Odd parity).. It will not take the expected chances and continues to operate @ 9600 baud etc.
    I then changed the "RS232 RW.vi"  default settings to (2400,7,1,Odd)
    it still refuses to deviate from (COM1, 9600,8,1,None...)
    I also went into the Win XP  Device Manager on the LabView system and manually configured Com1 to 2400,7,1,Odd  
    and still,.... the "RS232 RW.vi"  will only operate @ 9600,8,1,None
    Can anyone else test drive my VI and see if they have the same problem of not being able to see new changes in the Port configuration settings ..other than (COM1, 9600,8,1,None...).... ?
    FYI.. Unfortunately my LabView is running on Version 6.0 so you may need to up-convert the attached vi
    Solved!
    Go to Solution.
    Attachments:
    RS232 RW.vi ‏102 KB

    Instead of just appreciating the comments, you need to implement them.
    Having the VISA close inside the loop is definitely the problem.  And Crossrulz is 100% correct about the problem being that the serial port gets reset to the default baud rate after closing the port.  Here is the proof.
    Note that while you may have set the port settings manually in device manager, those settings are revised by the VISA driver.  If you look in Measurement and Automation Explorer under Devices and Interfaces >> Serial and Parallel, you'll see the default settings that the VISA driver uses.  If you change the setting there, your program will work the way you want.  But that is not the correct fix.  The correct fix is to get the VISA close out of the while loop.
    The port settings are established in this order.
    1.  By the Windows device drivers.
    2.  By the VISA driver as established in MAX.  Since you are useing VISA, these settings will automatically override #1.
    3.  By the port settings you set programmatically in your LabVIEW program.
    Attachments:
    Example_VI.png ‏18 KB

  • To send multiple operation commands to serial port

    My AC power source is able to communicate to PC via serial port using LABView and I can perform any operation by giving commands in Hex individually, But when it comes to the parallel operation of all the commands or to put them in a particular sequence. I am failing to do so.

    You can only send 1 command at a time.  That is just bus communications 101.  But you can string together many VISA Writes to send the individual commands, one after the other.
    But since if sounds like you are doing this on a GUI based instance, what you want to do is configure the port before your loop and close the port after the loop.  Then inside your loop you just have an Event Structure to key off of the different controls changing values.  You just send the command you need to inside of each event case.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • How do I change the DAC service serial port assignment in a distributed applications

    I am in the process of writing an application for end of line testing of large commercial HVAC units. It is our intention that this will be a distributed application on several workstations.
    I am successful setting up a modbus serial connection to the hardware we are using when in the development system but once the application is built and installed onto another PC, no data is passed from the NI variable Engine to the shared Variables in the VI. The comm port is identical and the port settings should get handled through the executable application I would assume.
    Does anybody have any clues? 
    Stebo222

    Hi, do you see the variables at the Distributed System Manager? If not, I believe you need to check this article. Something to keep in mind is the path for the library, it changes once it's built into an executable so make sure you are pointing to the right direction (a regular fix is striping the path, it may not work on the VI but it will on the .exe).
    Alejandro | Academic Program Engineer | National Instruments

  • Defining both the sender both the receiver IP and ports

    Hello guys, i need help.
    My aim is to develop an app that can send UDP packets over the network to the specified IP address and port number, and just now no problems.
    Using DatagramSockets and DatagramPackets i'm able to achieve this part.
    The real problem is that i need to display in the UDP sent the IP address of my machine and the port number i want and not a random port number.
    Is it possible?
    if so, how?
    thanks in advance for the help
    Gio-Kun

    DatagramSocket allows you to set a port (and optionally: an InetAddress), which specify the port and IP to use on the sender.
    DatagramPacket allows you to set the same for the receiver.
    What am I missing?

  • Could Someone send me a 'VISA Configure Serial Port.vi'???

    I need that VI from LabVIEW version 6.1! My mail is [email protected]
    Thank You.

    I made a vi that does the same and can serve for you as an example. look in the help how to use it.
    part of it is 6.0 and part 6.1 but that is no problem.
    The 6.0 vi's will be converted when loaded
    greetings from the Netherlands
    Attachments:
    visaoptions.zip ‏69 KB

  • Problem while reading data from Serial Port

    Hi All,
    I am facing some problem while reading data from Serial Port.
    As per the requirement I am writing the data on Serial Port and waiting for response of that data.
    Notification for data availabilty is checked with method public void serialEvent(SerialPortEvent event) of javax.comm.SerialPortEventListener.
    When we are writing data on the port one thread i.e. "main" thread is generated and when data availability event occures another thread "Win32SerialPort Notification thread" is generated. This creates problem for me as we can't control thread processing.
    So can anybody pls explain me how to overcome this problem?
    Regards,
    Neha

    My Problem is:-
    I am simoultaneouly wrting data on port & reading data from port.
    First I write data on port using outputStream.write() method. Now when target side sends me response back for the request on serial port DATA_AVAILABLE of SerialPortEventListner event occured,we are reading data from serial port.Now till the time we didn't get the response from target next command can't be written on the serial port. When we are writing data on port main thread is executed.Now my problem starts when DATA_AVAILABLE event occured.At this point another thread is created.Due to this my program writes data of next command without reading response of previous command.To solve this prob. I have used wait() & notify() methods as follows.But again due to this my pc hangs after execution of 2 commands. (PC hang in while loop in a code provided below.)
    From SOPs I could figure it out that after 2 commands we are not able to write data on serial port so DATA_AVAILABLE event doesn't occure n pro. goes in wait state.
    Can anybody help me to solve this issue.
    Neha.
    Code:
    public void serialEvent(SerialPortEvent event)
              switch (event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                                 break;
                   case SerialPortEvent.DATA_AVAILABLE:
                        try
                             dataThread = Thread.currentThread();
                             dataThread.setPriority(10);
                             dataAvailable = true;
                                                                                    byte[] tempArray=new byte[availableBytes];
                                        inputStream.read(tempArray);
                                                                       catch (IOException io)
                             SOP(io, "Error in serialEvent callback call for event DATA_AVAILABLE");
    public void  writetoPort(byte[] data) throws IOException
                             outputStream.write(data);
                              while(finalTimeOut >= actualTime)
                            if( ! dataAvailable)
                                    actualTime = System.currentTimeMillis();
                           else
              synchronized (mainThread)
                   mainThread = Thread.currentThread();
                   mainThread.wait();
    public  void sendDatatoUser(byte[] b) throws Exception, HWCCSystemFailure
              obj.returnData(b);
              synchronized(mainThread)
                   mainThread.notify();
                                                           

  • MEASURING FORCE ON BALANCE USING AN ELECTRONIC BALANCE FROM THE SERIAL PORT

    Hi,
    I am trying to measure FORCE using an electronic BALANCE from the serial port. My measurements are strange! The BALANCE sometimes give ZERO reading! Is it because of the sample rate, baud rate etc? I have attached the readings concerned.
    Attachments:
    databalance.doc ‏144 KB

    I think your problem is due to the way you read the weight :
    1/ask the balance to send the data
    2/oversee the byte number on the serial port until it is constant
    3/read the bytes received
    4/convert to number
    During step 2, you compare the bytes at serial port with the previous value. So far, you have been very lucky to be able to read something : the answer here is always ZERO since the readings occur BEFORE the balance has been able to send anything! means that your loop stops immediately (if you are not convinced, jujst add an indicator to display the loop index. However, since you added a wait (0.8 s), when going to step 3, the balance has had some time to send something. Here, you should not have read again the number of bytes at serial port, but that unwillingly corrects the previous error and you can read most of the received data...
    You should modify completely your algorithm. Usually, a balance send the weight as a string with some terminator (RC or LF). Accordingly, the algorithm should be :
    1/ask the balance to send the data
    2/read the serial port, concatenating the received chars until a terminator char is received or a timeout has occured
    3/convert to number
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Accessing the fielpoint web server using serial port

    hello everyone!
    I would like to use the fieldpoint serial port, instead of the utp port, to
    access the fielpoint internal web server. This means to have the tcp on
    serial port. Is it possible? And how can I do it?
    Thanks,
    Andrea

    There may be some hidden trick method of doing that, but usually, RS232 does not support web access. In order to use a COM port to access the web, you'd normally have to use something like PPP. I don't think there's a PPP client for FieldPoint.
    - Dan

  • Setting additional features of the serial port

    I have to set some features of the serial port which are not settable with the
    ordinary LabView examples or Vi's. What I am trying to set are:
    XonLimit, XoffLimit and Mask RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BRK ERR RING
    How can I set these features?

    Open the VISA configure serial port vi and look how the basic settings are implemented. There is a visa property node that can be accessed : right click on it and select "properties" to access other parameters. You can either modify this vi, or create your own.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • 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

  • Writing to serial port

    I currently send ASCII characters to a serial port. I have not errors reported back. Everything appears to be error free, except that the device that I am trying to control does nothing. The device being controlled does not send anything back to the pc. The connection is strictly a one way connection. Do you have to send a carriage return or something to get the ASCII characters to "push" out of the buffer? - Sorry I don't have access to my code at the moment.

    A portion of my code is below. What does the 'flush'
    do? I thought it just emptied out the buffer.
    while (portList.hasMoreElements()) {
    portId = (CommPortIdentifier)
    tIdentifier) portList.nextElement();
    if (portId.getPortType() ==
    ortType() == CommPortIdentifier.PORT_SERIAL) {
    if (portId.getName().equals("COM1"))
    .equals("COM1")) {
    try {
    serialPort = (SerialPort)
    portId.open("SimpleWriteApp",
    d.open("SimpleWriteApp", 2000);
    } catch (PortInUseException e)
    ortInUseException e) {}People get life for this crime!
    try {
    outputStream =
    outputStream =
    tStream = serialPort.getOutputStream();
    } catch (IOException e) {}So you now have two life sentences to serve.
    try {
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch
    } catch
    } catch (UnsupportedCommOperationException e) {}Sorry, three life sentences to serve.
    try {
    outputStream.write(rightString.getBytes());
    } catch (IOException e) {}You get the prize! Four life sentences from a short bit of code.
    }P.S. You should really use the COMM api for writing to serial ports.

  • Problems with access to serial port using reentrant code

    Hi,
    I have a VI that send commands and receive answers from an instrument using
    de serial port.
    This VI runs perfectly when used alone.
    However I'm trying run two instances of that VI simultaneously using
    reentrant code and I'm facing some problems.
    Sometimes everything is OK but sometimes, in the process of writing to
    serial port the following error happen:
    Error code 36.
    Invalid refnum device.
    What is this?
    Does someone know how to prevent this?
    Thanks in advance for any help.

    "Paro, Paula [CMPS:2721:EXCH]" wrote:
    >
    > Hi,
    >
    > I have a VI that send commands and receive answers from an instrument using
    > de serial port.
    > This VI runs perfectly when used alone.
    > However I'm trying run two instances of that VI simultaneously using
    > reentrant code and I'm facing some problems.
    > Sometimes everything is OK but sometimes, in the process of writing to
    > serial port the following error happen:
    > Error code 36.
    > Invalid refnum device.
    >
    > What is this?
    > Does someone know how to prevent this?
    >
    > Thanks in advance for any help.
    You can't use reentrant vi's vith serial vi calls without supervising of
    driver.
    Use VISA instead and you have to control the VISA session opening and
    closing. Another word is that the only one serial port sess
    ion should be
    opened at a time.
    Reentrant vi's for serial port without checking serial port session is a
    mistake of program algorithm. Change it in any convenient way.
    Sergey Krasnishov
    Automated Control Systems
    National Instruments Alliance Member
    Moscow, Russia
    [email protected]
    http://acs.levsha.ru

Maybe you are looking for

  • Can we display only sub totals on the alv grid output

    hi, can we display only the subtotals calculated on the grid display.it should display all the data it shpuld display only the subtotals of it. if yes can any one please give me the code for will be awarded with points.

  • Printing all possible combinations of a given word.

    Well I'm supposed to print all possible combinations of a given word(I'm writing this for the benefit of those who might not have guessed this from the subject). I've got some code but its horribly wrong. Could anyone point out any mistakes. public c

  • Third level Drill Down report

    Hi, I have a requirement to create the report using Crystal Reports 2008 up to 3 levels of drill-down. I tried to create it but I can create up to only 2nd level of drill-down. Is it possible to create 3rd level of drill-down. If yes, please let me k

  • Two different network managing icons in KDE!

    Hi, i installed knetworkmanager and two icons appeared after reboot, but i just want one. One is the normal icon that also appears in kubuntu, the other one is somethin like a blue circle with a blue bar at its right side indicating signal strenght,

  • How can I connect my iPad to an HP Photosmart c309n printer?

    How can I connect my iPad to an HP Photosmart c309n printer?