Efficient optimized way to read from serial port and GPS data display using map

Hi,
I have a custom h/w which reads the data from GPS Rx and after parsing send it to PC over RS232.
Each second it sends 201 bytes to PC. I have developed a VI to read the GPS data and display it. Project file is attached.
Fulctionality of different loops are as following:
1. LOOP 1: 1.1 Reads the serial data from com port.
               1.2 Synclonize the frame using start bytes "a" and "z".
               1.3 Reads next 4 bytes containg receiving error information.
               1.4 Reads next 195 bytes. in which initial 80 byes are GPS data. rest are others.
2. LOOP 2: 2.1 Extarcts the GPS information and put them in an array.
                  2.2 Extarcts the receive error infor and counts the total error by incrimenting the variable using shift reg.
3. LOOP 3:3: 3.1 Displays the GPS data in chart and log the data in a file.
4. FLOW : Uses the GMAP .NET based API to creat a MAP and display.
Problem statement:
1. Functionality acheived.
2. However in between data set is being missed by the programm. 
Quesitions:
1. Is the developed VI is efficient in terms of using queue loacl variables etc.
2. What are the improvments I can do to solve the problem.
Any other suggestions|
Thank you
jayant
jayant
Attachments:
Telemetry_Receiver_v2.zip ‏3075 KB

One of the most common problems in serial communication is the need for an adequate timing: how much time is expected your device to spend before answering? Have you put and adequate pause in your code before reading from the serial port?
Hope this helps
Roberto
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?

Similar Messages

  • A problem about reading from serial port

    Hi,
       I just sent '0x03' from MCU to PC continuously, and then sent  '/n' as a stop character after every '0x03'. I use labview to read the data. The problem is when it get two '03' it get a '0', another two '03' and another a '0'. I don't know where is the '0' from?
      PS: Hyper terminal can display natrually.
       Thank you! 
    帖子被hengfo在08-08-2007 10:14 PM时编辑过了
    Attachments:
    serial read.vi ‏36 KB

    I think the problem may be the loop reading the serial port is running too fast.  There is no timing delay in the loop, so you are reading it as fast as you can, and probably faster than the device is sending data.  So sometimes the buffer is empty, and then the empty string gets converted to a numeric zero.  The way to know for sure is to put an indicator on the error wire coming out of the serial port read.  I bet you will see errors about the read buffer being empty.
    Put a wait timer in the loop to slow down the execution just slightly.  This is a good idea so that LV doesn't eat up all the CPU resources.  Look at the example for Basic Serial Write and Read.  You may want to have a loop ahead of the read that waits until there are a certain number of bytes at the port before it reads the serial port.  You may want to put a loop around the serial port that waits until a valid number is read in before it exits the loop and goes to the numeric conversion.
    Message Edited by Ravens Fan on 08-09-2007 08:50 AM

  • Trouble reading from serial instrument and DAq simultaneously.

    Greetings,
    I am having some trouble getting my VI to read from my DAq and a serial instrument at the same time.  If I run the subVI's simultaneously (i.e. subANG is running in one window and subVEL is running in a second window) both return the proper values and behave as I would expect.  However, if I call the subVI's into a parent VI and try to run them both in the same loop structure subANG gets stuck and will not resond with a change in signal.
    I have also tried to use a stacked or flat sequence to separate out the execution of subVEL and subANG, but I still get the no response from subANG.
    The most confusing thing is that if I run Parent.VI in one window and then create a copy of subANG (call it '....-copy' or whatever) and run it in a second window, Parent.VI behaves properly and will refresh the readings as they appear in '...-copy'.
    I have attached 3 files.
    (1) subANG.VI     -This reads an RS232 signal from an inclinometer.  The signal is refreshed every 10ms or so.
    (2) subVEL.VI      -This reads raw voltage from one channel on the DAq, calculates the mean then converts that into a pressure differential and finally a velocity based on the pressure and temperature inputs. 
    (3) ParentVI.VI     -This simply calls and displays the subVI's
    My guess is that it is a buffer issue, but I am stumped.  Does anybody out there in Labview land know why this might be happening?  All suggestions welcom.
    Solved!
    Go to Solution.

    I am noticing it is not an NI DAQ card.  How are you communicating with the DAQ? If it is using a serial port, that could be your problem.
    I also highly recommend using the VISA drivers for serial communications instead of the serial.llb VIs.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Plot more than one analog value to a waveform chart by reading from Serial Port

    I have 4 LDRs and I want to plot their values to a waveform chart by reading them from the serial port. I have looked around and found an example of a VI plotting one value to a waveform chart (attached below) but I am unsure about how to expand this for 4 different waveforms, mostly because I don't particularly understand the way is being read currently. If someone could either point me in the way of a relevant example or explain/show me a solution, or explain howthe current VI I have works, that would be greatly appreciated.
    Attachments:
    LDRread.vi ‏20 KB

    Since I assume each LDR (whatever that is) has its own serial connection, you will need to read from 4 different serial ports.  From there, just form an array of all the data and write to the chart.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • Reading ascii codes from serial port and plotting them

    Hello
    I am trying to build a VI that reads data (ascii values) from the serial port.
    I am trying to build a wireless phonocardiogram. I have a microphone that acquires heart sounds. these signals are amplified and sent to a A/D converter to digitize them. the digital signal are sent to a base unit. The digitals signals received at the base unit have to be sent to a computer (over a serial port to view them).
    I would like build a VI to plot ascii data received over the serial port.
    I would like to plot those values so that the plot just looks like a analog signal (the one I had before A/D conversion).
    Can anyone provide me some help?
    Thanks in advance.....
    Solved!
    Go to Solution.

    Hi chaitu209
    What is your transmission speed,  samplerate, and bandwidth needed in your project? The bandwidth of the serial port is somewhat limited. Let me give you an example
    Say you are using 115200 Kbit per second as transmission speed, one start bit/stop bit and parity bit, and 8 bit data. This will give you 115200/11 bytes pr second as the maximum theoretical transfer rate/sample rate. But if you are using up to 16 bit AD your  maximum samplerate will be 115200/(2x11). So my advise to you is to use a binary transfer protocol not ASCII based protocol. This is not a problem in Labview with serial transmission.
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Computer freezes while reading from serial port

    My computer freezes when i tried to read from a serial port for a longer period of time such as 10 hours. I always close the serial port after reading. please, help me solve this problem

    I too experienced a similar problem twice on my machine and I have no idea how to stop it because it is so intermittent and I cannot replicate it.
    Perhaps I can offer some clues.
    The Labview screen cannot be stopped and some parts of Windows appears frozen. Oddly enough I can switch to the block diagram but thats about all I can do. The LV stop button will indicate a mouse click on it but the VI does not stop. iT also cannot be closed.
    Even the reset button and power button on the PC does not work. I am forced to power down the PC (pull the plug) to get back control.
    I believe it is related to a visa call to my serial Balance.
    ANyway no solution but hopefully some clues.
    Dell Optiplex GX260 w/ 500MB RAM
    Win2K 500.2195 w service pak 4,
    NI
    serial Hardware and NI serial ver1.45 (16 com ports)
    Labview 6.1 and 7

  • Function for reading from serial port

    Hi experts,
    We are trying to read data from the serial port with the following function we got from internet.
    The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.
    We already copied the file MSCOMM32.OCX in c:\windows\system32 and we successfuly registered it, with regsvr32.exe.
    We tried it with Windows XP and Vista.
    Anybody has any idea?
    Thanks in advance
    FUNCTION ZSERIALCOM.
    ""Interfase local
    *"  IMPORTING
    *"     REFERENCE(MODE) TYPE  I DEFAULT 0
    *"     REFERENCE(COMMPORT) TYPE  I DEFAULT 1
    *"     REFERENCE(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'
    *"     REFERENCE(OUTPUT) TYPE  C OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(INPUT) TYPE  C
    *"  EXCEPTIONS
    *"      NO_CREATE_OBJECT
      TYPE-POOLS: sabc.
      INCLUDE ole2incl.
      PERFORM init.
      PERFORM open_port USING commport settings.
      IF mode = 0.
        PERFORM read_port
        CHANGING input.
      ENDIF.
      IF mode = 1.
        PERFORM write_port
        USING output
        CHANGING input.
      ENDIF.
      PERFORM final.
    ENDFUNCTION.
    DATA: o_obj TYPE ole2_object.
    *& Form Init
    text
    --> p1 text
    <-- p2 text
    FORM init.
    DATA:
    wa_repid LIKE sy-repid.
    wa_repid = sy-repid.
    CALL FUNCTION 'AUTHORITY_CHECK_OLE'
    EXPORTING
    program = wa_repid
    activity = sabc_act_call
    application = 'MSCOMMLib.MSComm.1'
    EXCEPTIONS
    no_authority = 1
    activity_unknown = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    IF sy-subrc <> 0.
    RAISE no_create_object.
    ENDIF.
    ENDFORM. " Init
    FORM open_port *
    --> COMMPORT *
    --> SETTINGS *
    FORM open_port USING commport settings.
    SET PROPERTY OF o_obj 'CommPort' = commport.
    SET PROPERTY OF o_obj 'Settings' = settings.
    SET PROPERTY OF o_obj 'InputLen' = 0.
    SET PROPERTY OF o_obj 'PortOpen' = 1.
    ENDFORM. "open_port
    FORM read_port *
    --> INPUT *
    FORM read_port
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM. " read_port
    FORM write_port *
    --> OUTPUT *
    FORM write_port
    USING output
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    SET PROPERTY OF o_obj 'Output' = output.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM.
    *& Form final
    text
    --> p1 text
    <-- p2 text
    FORM final.
    SET PROPERTY OF o_obj 'PortOpen' = 0.
    FREE OBJECT o_obj.
    ENDFORM. " finalbligw

    Hi ,
    I want to read value form weigh bridge through COMM port. I have developed the FM and done the setting as mentioned in the below link
    Read COMM port using ABAP w/o third party software 
    but while executing the FM independently I am able to get the value from the COMM port,but when I call the FM from a program I am not able to get the output value from the FM.I am calling the FM from the report program.please find the code below.
    report test.
    data : lv_input TYPE c.
    CALL FUNCTION 'ZFM_WEIGHINTERFACE'
      EXPORTING
        MODE                         = 0
        COMMPORT               = 1
        SETTINGS                  = '1200,N,8,1'
        OUTPUT                     = ''
      IMPORTING
        INPUT                        = lv_input
      EXCEPTIONS
        NO_CREATE_OBJECT       = 1
        OTHERS                 = 2
    IF SY-SUBRC <> 0.
    * Implement suitable error handling here
    ENDIF.
    if I execute the FM independently the output is getting perfectly.but while calling from a program i am facing the issue..
    any suggestion is appreciated.
    Thanks
    Vivek

  • Controlled reading from serial port

    I'm trying to establish a connection to an external device through the serial port. This is done in a while-loop which sends an association request tries to get a response if a response is not recieved a new rewuest is sent, etc. At the moment this procedure does not work. I am considering two explanations for this. The first is that the loop does not wait long enough for a response to come and simply keeps pumping out requests, the other is that there is something wrong with the reading algorithm, that doesn't let it properly take in information from the serial port.
    Solved!
    Go to Solution.
    Attachments:
    association_loop.GIF ‏5 KB
    read_visa.GIF ‏8 KB

    I made a new version of the read case. The old version was a while loop, the new version is a while loop which will go on until it encounters an EOF character. In this case it is
    0xC1 or 'Á'. I thought the old version would break before getting any message. This doesnt get any signal either. I have probed it, and it doesn't get a string from which to take the length.
    Attachments:
    read_visa2.GIF ‏10 KB

  • Reading from serial port

    HI,
    I need to read data from virtual serial (rfcomm - BT GPS receiver). I connect to my gps using system command:
    [root@localhost ~]# rfcomm connect /dev/rfcomm0 XX:XX:XX:XX:XX:XX
    and this creates port at /dev/rfcomm0, when I do :
    [root@localhost ~]# cat /dev/rfcomm0
    I get:
    M,0.0,0000*76
    $GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
    $GPRMC,000009.999,V,0000.0000,N,00000.0000,E,,,101102,,*17
    $GPGGA,000010.999,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*7E
    $GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
    and the only problem is what to do to read this sequences via java application. I obtained package comm2.0.3.zip , but have no idea what next. I would be grateful for any help.
    best regards
    joshua

    I did everything described here:
    http://www.geeksville.com/~kevinh/linuxcomm.html
    got an example from:
    http://java.sun.com/developer/releases/javacomm/SimpleRead.java
    (the defaultPort = "/dev/term/a"
    replaced with
    defaultPort = "/dev/rfcomm0")
    i connect to my gps with:
    [root@localhost ~]# rfcomm connect /dev/rfcomm0 XX:XX:XX:XX:XX:XX
    start the application and get an error:
    java.io.IOException: Error instantiating class gnu.io.RXTXCommDriver
    gnu.io.RXTXCommDriver cannot be cast to javax.comm.CommDriver
    at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:239)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
    at comm.SimpleRead.main(SimpleRead.java:78)
    Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
    at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
    at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
    at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
    at comm.SimpleRead.main(SimpleRead.java:78)
    Java Result: 1
    i think i did everything about rxtx as described. could anyone help?
    best regards
    joshua

  • How to configure visa to adquire dat from serial port and then converted to numeric value from a home embedded device

    I already stablish communication with my serial port using VISA, selecting COM1 as the resoure name.
    After that, I tried to read the data from the port (as we know the data was in string format )but I need to convert the data to numeric value to hadle it (no arrays).
    Another main thing is that I'm develoing a new based Embedded design and tthe info that will trhow out from the device to the PC is binary.
    How can I solved the problem, and if I want to make bidirectional communication with my system how can I do it? The VISA intructions as *IDN? and so forthetc can be recognize by the external system if the COM1 port is recognized by NI Max as ADSRL1::I
    NSTR1?

    Hello,
    For an example of bidirectional serial communication in LabVIEW, please see the shipping example LabVIEW <-> Serial.vi. This can be found from LabVIEW by going to Help >> Find Examples. From the example finder, select Hardware Input and Output >> Serial >> LabVIEW <-> Serial.vi.
    Once you are able to read the string data in, you can use the VIs in the String/Number Conversion palette to convert the data to numeric format. To access these, right-click on the block diagram >> All Functions >> String >> String/Number Conversion.
    Let me know if this does not help.
    Regards,
    Sean C.
    Applications Engineer
    National Instruments

  • Using servlets to read from text file and insert data

    Hi,
    Can I use a servlet to read from a space delimited text file on the client computer and use that data to insert into a table in my database? I want to make it easy for my users to upload their data without having to have them use SQL*Loader. If so can someone give me a hint as how to get started? I appreciate it.
    Thanks,
    Colby

    Create a page for the user to upload the file to your webserver and send a message (containing the file location) to a server app that will open the file, parse it, and insert it into your database. Make sure you secure the page.
    or
    Have the user paste the file into a simple web form that submits to a servlet that parses the data and inserts it into your db.

  • Problem with JPEG files from Leica M and GPS data

    It seems there's a serious bug in Camera Raw 8, hosted in Bridge CS6 on an MS Windows machine, with regard to GPS metadata.
    When using a Leica M (Typ 240) with a multi-function handgrip then both the DNG files (DNG is Leica's native raw format) and the JPEG files out of the camera will include GPS position data in the respective EXIF metadata sections. However, Bridge refuses to display the JPEG files' GPS data (while there's no problem with the GPS data in the DNG files). Worse yet—when loading a JPEG file in Camera Raw for some parametric adjustments and saving the file then the GPS data will be entirely gone! (Again, no problems with the DNG files' GPS data.)
    I suppose that Camera Raw 8 hosted in Bridge CC as well as Lightroom 5 are suffering from the same issue.

    Nobody? Absolutely nobody?? Zalman? Eric? Anyone?
    If you need more input from me then please talk to me.

  • How to decode a set of datas received from serial port and display image on a canvas based on CVI ?

    Hi !
    I have received a set of datas via rs232 and it contains picture messages. I have to decode the datas first and then display them on a canvas.
    I have known several functions that may be used . Such as
    int SetBitmapData (int bitmapID, int bytesPerRow, int pixelDepth, int colorTable[], unsigned char bits[], unsigned char mask[]);
    int CanvasDrawBitmap (int panelHandle, int controlID, int bitmapID, Rect sourceRectangle, Rect destinationRectangle);
     However,I don't know how to set the following parameters according to the actual pixel values and color values.
    int bytesPerRow, int pixelDepth, int colorTable[], unsigned char bits[], unsigned char mask[]
     What's more,I have no idea how to decode the datas.
    The  attachment is a incomplete project. I will be very appreciated if anyone could help me .
    Best regards.
    xiepei
    I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
    Attachments:
    Decode and display image.zip ‏212 KB

    Well, things are getting a bit clearer now.
    1. Your image is actually 240x240 pixel (not 320x240 as you told before). The size of image data is 57600 bytes which corresponds to that frmat (I was puzzled by such a data size compared with larger image dimensions!)
    2. The image is a 8-bits-per-pixel one; this means that you must provide a color palette to create the bitmap
    3. You cannot simply copy image data into bitmap fields in CVI: CreateBitmap always produce an image with pixeldepth matched with display colour depth (normally 24 or 32 bpp)
    All that means that you must:
    1. Create the appropriate color palette with 256 colors: it may be a grayscale or color palette depending on camera characteristics. Grayscale palette can be found in my sample project, while sample colour palettes can be found here (here the description of a "standard" 8-bpp color palette)
    2. Create the bits array correctly dimensioned for the color depth of your monitor
    3. Get each pixel value from the camera, lookup in the color palette for the appropriate colour and create the RGB informations into the bits array in memory
    4. Display the bitmap on the canvas
    As a first step, I would configure my system for 256-color display setting, create a bitmap and simply copy image data into it: you should be able to get the correct image back to your screen.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Read from txt file and analyse data

    hi,
    i am having a problem for reading data from a text file and checking whether it is a integer or not.
    basically if i have a txt file with the following content:
    12 45 345 500 45.67684 33
    my output should be:
    12 45 345 500 invalid 33
    that means if there is a integer number in the file, the integer number will be printed on the screen BUT if there is anything else like a string or a double number, then "invalid" will be printed.
    how can i check what kind of datatype it is??
    i have the following code to start with:
    try
                BufferedReader in = new BufferedReader(new FileReader(FileName));
                String l = in.readLine();
                in.close();
            catch(IOException e)
                System.out.println("IO error");
                System.exit(0);
            }

    ok i have tried the following code:
            int index = 0;
            String[] arr = null;
            int nb = 0;
            try
                BufferedReader in = new BufferedReader(new FileReader(nameFile));
                String line = in.readLine();
                arr = line.split(" ");
                for(int i=0; i<arr.length; i++)
                    index = i;
                    nb = Integer.parseInt(arr);
    System.out.print(nb+" ");
    in.close();
    catch(IOException e)
    System.out.println("IO error");
    System.exit(0);
    catch(NumberFormatException e)
    System.out.print("invalid ");
    for(int j=index+1; j<arr.length; j++)
    nb = Integer.parseInt(arr[j]);
    System.out.print(nb+" ");
    which works perfectly fine for the following scenario:
    txt-file:
    12 45 345 500 45.67684 33
    output:
    12 45 345 500 invalid 33
    but what, if I have the following data in my txt file:
    12 45 345 500 45.67684 33 23.234 21
    then the output should be:
    12 45 345 500 invalid 33 invalid 21
    how can i solve this???

  • Reading a char array from Serial port

    Need help!
    Hi, I've got the following problem - I wanna read a input stream from serial port and I use at the moment the following method (reading bytewise):
    public String receiveText (){
          byte ch;
          fStrBuf.delete(0,fStrBuf.length()); //clearing the buffer
    try{
              do {
              ch = (byte) fPortInStream.read();
              fStrBuf.append( (char) ch);
            while ( (byte) ch != 0x03); //The end of frame byte
             }catch(IOException ioe) {};
          return fStrBuf.toString();It works pretty well, but disadvantage is that it's too slow to use it in the thread (at least I think so)
    How can I change it to read all available data from the port (or simply faste). I don't need event listeners, because it's a request-responde communication.
    I tried smth. like this
    byte[] readBuffer = new byte[20];
                try {
                    while (fPortInStream.available() > 0) {
                        int numBytes = inputStream.read(readBuffer);
                        fStrBuf.append(readBuffer);
                } catch (IOException e) {}
          return fStrBuf.toString();But it doesn't seem to work :-(

    May I suggest that you use StringBuilder rather than StringBuffer. It has less overhead because it is not threadsafe. I do synchronous serial port stuff with Opto 22, and i have no listeners enabled.
    Appending to the String(Builder/Buffer) directly from the byte buffer mangles it. So I use a string (ugh). With the Opto22 brain boards, i am looking for a carriage return as a term char. It either finds it or times out.
    This is the best i have come up with so far:
    StringBuilder response = new StringBuilder();
    String data = new String();
    long msTimeOut = 2000;
    public void getResponse () throws IOException {
            byte[] readBuff = {0};
            int charAvail;
            response.delete(0,response.length());
            long ts = Calendar.getInstance().getTimeInMillis();
            try {
                while ( readBuff[readBuff.length-1] != '\r' ) {
                    charAvail = inputStream.available();
                    if ( charAvail > 0 ) {
                        readBuff = new byte[charAvail];
                        inputStream.read(readBuff);
                        response.append(new String(readBuff));
                    if ( Calendar.getInstance().getTimeInMillis() > (ts + msTimeOut) ) {
                        response.delete(0,response.length());
                        response.append("TIMEOUT");
                        break;
            } catch (IOException e) { e.printStackTrace(); throw e; }        
            data = response.substring(0);
        } I just starting writing Java about 4 days ago, so caveat emptor.

Maybe you are looking for