Reading a whole frame from the serial port

I have posted before about my attempts to use the serial port (http://forums.ni.com/ni/board/message?board.id=170&thread.id=387410).
Anyway, I want to connect an external device through using VISA. It uses a protocol that exchanges frames. My main program is a series of while loops going through the different echanges, it sends one frame, waits for the proper response, sends the frame again etc.
My problem lies in reading the frames. I'd like to read from the serial port until I get an EOF character, then parse the frame, etc. for every cycle of send/check. This doesn't work. I've managed to get one character from the port, thereby confirming that my reading function does actually read. Then I tried to put it into a loop which resulted in it not returning any characters at all.
Attachments:
AssReq.GIF ‏5 KB
GetFrame.vi ‏14 KB
readVISA.vi ‏13 KB

Attachments:
SerialPortControl_2.vi ‏24 KB

Similar Messages

  • I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadshee​t. Any ideas?

    I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadsheet. Any ideas? Right now my data will collect one reading instead of continuously reading my IMU which displays data in a continuous stream.
    Thanks
    Attachments:
    Read_IMU_Drew.vi ‏21 KB

    Hi
    Your vi is in 2009 version, which i am unable to open in 8.6
    However, if you want your data to be saved in excel sheet, here is the VI
    Somil Gautam
    Think Weird
    Attachments:
    save to excel.vi ‏12 KB

  • 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...        

  • How to retrieve data from the serial port and decode it each 2 bytes is a long variable and 1 frame is about 6 bytes

    I send the frame by a microcontroller ( 8bits) the fram contains 6 bytes, 2bytes conform a long variable, I want to decode the frame and make operations with these long variables and then plot them

    Hey jpvans,
    I would first suggest using NI-VISA to talk to the serial port. Then, you can use the LabVIEW Type Cast or the Flatten to String and UnFlatten From String VIs to convert the data.
    You can setup the read so that it reads just two characters at a time to form an individual long or you can set the read up to read it all and then use the string functions like String Subset to cut the information into chunks.
    I hope this helps out.
    JoshuaP

  • How to read and write from the serial port using java

    can anyone tel me how to capture data from a serial port and display on the screen and also store it in a database.

    Java Comm API, JDBC

  • How can an image be displayed by using raw data read from the serial port?

    Hi there,
    I am using an embedded camera to take photos. To operate it i send commands to it via the serial interface. I have received all of the image data back through the serial port and can view it as hex data in a string. The image data is 16bit colour RAW data at 160x120 resolution meaning i have 38400 bytes of data (160x120 = 19200. 19200*16 = 307200. 307200/8 = 38400). I want to be able to display this data as a picture, but cannot figure out how to do it. Can someone please point me in the right direction? i have been fiddling about with lots of the pixmap functions but no luck. Do i need to put this data in to a 2D array first?

    Yes, first convert it into a 2D array of pixel values. From there you can convert it into an image to display it in a picture control.
    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

  • How to get a signal from the serial port to start a labview program?

    I need to synchronize the data obtained from a program (which is not in Labview)with the data collected with Labview on a different computer. I can send some data strings to the serial port of the computer running the Labview program when the other program starts. However, I need to be able to read the trigger in my Labview program. Do you know what I should do? Thanks.

    If you don't have any other programs listening on the COM port, you need to let a LV program run BEFORE the signal comes, otherwise you won't be able to read it. You can have the program wait in a slow timed loop so that it doesn't use up too much CPU time, and when the required "trigger" comes, to move into the main part of the program.
    You basically need a while loop waiting for a certain string in the serial buffer. Once the string is found the while loop is exited, and the data acqquisition or whatever else you require from the progam can be performed.
    In the example attached the program wait for ANY text to be sent to the COM port. Please note that you need to configure the VISA resource before using it. Once there is something at the COM port, the loop will exit and the rest of the program will be executed.
    Hope this helps
    Shane
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Wait for serisl message.vi ‏17 KB

  • Project select data from the serial port

    Hi everyone,
    The project is about use labview to receive data from a serial
    port wirelessly. The serial port will receive two values (X1 and X2) every 10
    minutes. I want to use those two values as two inputs for my formula. How to
    make selection? Many thanks.
    Baicy
    Solved!
    Go to Solution.
    Attachments:
    port read.png ‏23 KB

    Scan From String.
    Using the first option, and putting some numbers in for the zeroes so it shows some kind of meaningful result.
    Attachments:
    Example_VI.png ‏12 KB

  • Hello!!!I need to read some data from the serial port and processing these, at the same time I want to see the process that I am doing.

    I read the data without problems, and I see them using Waveform graph, the problem is that I want to see the real time stamps, but in the graph appears 2:00:00,000 and 01/01/04, so the date and the time is wrong !!
    Can I change this?
    I am thinking that the problem is that I have to adquire the data and the time stamps ( using Get date/time) and after, I have to represent both!!!
    Thanks!!!

    Hello,
    As you probably know a waveform is made of a beginning time (t0), a time difference between each value (dt) and an array of values (Y). Your problem is probably that you don't initialize t0. Use the Vi 'Waveform->Build a waveform' to initialize the time of the waveform.
    Hope this helps !
    Julien

  • 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.

  • How to detect if my external device is connected to the Serial port

    Hi,
    If I remove the cable from the serial port in my pc or either remove the serial cable from my external device, then when I send a request to open the serial port from my program, it basically does nothing, it just sits there.
    I want to be able to show some sort of message or any other way of indicating to the user that they should check the cable.
    below is the bit of code to open and set serial port params:
         public void openPort() {
              // Initialise the drivers
              System.setSecurityManager(null);
              String driverName = "com.sun.comm.Win32Driver";
              try {
                   CommDriver commdriver = (CommDriver) Class.forName(driverName)
                             .newInstance();
                   commdriver.initialize();
              } catch (Exception e2) {
                   e2.printStackTrace();
              // port will be set in Store Operations.
              String wantedPortName = Configuration
                        .getParameter(ConfigSetting.EFT_COM_PORT);
              //System.out.println("wantedPortname : " + wantedPortName);
              Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();
              CommPortIdentifier portId = null; // will be set if port found
              while (portIdentifiers.hasMoreElements()) {
                   System.out.println("counter");
                   CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers
                             .nextElement();
                   System.out.println(pid.getName());
                   if (pid.getPortType() == CommPortIdentifier.PORT_SERIAL
                             && pid.getName().equals(wantedPortName)) {
                        portId = pid;
                        System.out.println("found a macth");
                        break;
              } // end of while
              if (portId == null) {
                   System.err.println("Could not find serial port " + wantedPortName);
                   //System.exit(1);
              try {
                   port = (SerialPort) portId.open("EFTDriver", // Name of the
                                                                               // application
                                                                               // asking for the
                                                                               // port
                             10000 // Wait max. 10 sec. to acquire port
              } catch (PortInUseException e) {
                   e.printStackTrace();
                   System.err.println("Port already in use: " + e);
                   //System.exit(1);
              // Now we are granted exclusive access to the particular serial
              // port. We can configure it and obtain input and output streams.
              try {
                        port.setSerialPortParams(9600, SerialPort.DATABITS_8,
                             SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
              } catch (UnsupportedCommOperationException usc) {
                   System.err.println("Unsupported operation" + usc);
              }Please advise what method can I use for this purpose.
    Thanks
    Abhi

    You mean it hangs in the open() method despite the timeout?

  • I want to write and read a hex file from the flash buffer of the microcontroller through the USB serial port

    hello sir,
    I am developing a GUI screen from that i want to write and read a hex file from the flash buffer of the microcontroller through the USB serial port. the driver i am using is FTDID2XX driver.if anyone having examples of loading file through serial port.Please reply me .
    Thanks

    Looks like you should post your request in the LabVIEW forum, this one here preferentially is for LabWindows/CVI...

  • How can I read the voltage from a serial port

    I am fairly new to LabView and I am having trouble figuring out how to read the DC voltage coming out of an RF Power Supply through a serial port so that I can monitor the voltage every few seconds. In order to do this do I need to purchase a DAQ card or anything like that?

    You would not need a DAQ card to read data over the serial port. You would, however, need a serial port. That may sound sarcastic, but it's not, since many manufacturers are ditching serial ports on computers. If you don't have a serial port then you would need to get something like a USB<->serial adapter or a serial port card that you plug into an expansion slot in your computer.
    Assuming you've got that then you need to find the command set for the RF Power Supply, and write drivers for it so you can send the command to read the voltage, and then read the resposen. I would suggest looking in the Instrument Driver Network to see if a driver for your supply has already been written. 

  • "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

  • Why does a standalone program created in Labview 8.5 try connecting to the internet when the program only reads data through the serial port? Firewalls object to progams that contact the internet without permission.

    why does a standalone program created in Labview 8.5 try connecting to the internet when the program only reads data through the serial port? Firewalls object to progams that contact the internet without permission.
    The created program is not performing a command I have written when it tries to connect to the internet, it must be Labview that is doing it. How do I stop this from happening? 
    Any help would be very appreciated.

    It looks that way..
    "When LabVIEW starts it contacts the service
    locator to removes all services for itself. This request is triggering
    the firewall.This is done in case there were services that were not
    unregistered the last time LabVIEW executed- for example from VIs that
    didn't clean up after themselves"
    This is not yet fixed in LV2009.
    Message Edited by Ray.R on 11-04-2009 12:25 PM

Maybe you are looking for

  • Unable to Loda the data into PSA.

    Hi Xpert, i am uanble to load the data into PSA. my source system is not R/3,it is BI. (ctually we are xtracting the data (from a cube) with the help of programm to a table and then i am creating a generic data ource on that table and loading the dat

  • Ibook g4 video capabilities

    my video is an ATI Mobility Radeon 9550 , and i would like to know if it could be improved from 32mb to 128mb. But i got one thing in my mind, i think the video is not shared, its dedicated. Could it be possible to make it shared video memory, becaus

  • Report related to ranking !!!!

    Hi All, We have a requirement here for an HR report . Suppose for example we have 40 candidates CAN1, CAN2 etc , & each candidate has to go thru 4 sections of training. he will get some point n each section between 1 to 10 .For example CAN 1 got 5 in

  • Parallel Ledgers - different posting variants - document posting

    Hi Experts, In our scenario, we have one Leading & one Non-leading ledger and both the ledgers have same Fiscal year varaint but different posting period varaint. 1. If we close the Posting period variant for the non-leading ledger and keep the PPV o

  • What is the best way to sync media onto the iPhone using iTunes?

    I know of two ways- one is be simply dragging items onto the iphone folder. The other is by clicking the iphone folder and selecting which playlists,artists, ect I want to sync. Is there any difference between the two?