Problem writing to serial port

Hi All,
I am very new to LabVIEW (just a couple of months). I need to communicate with a serial port of an Advanced Energy RF generator (Ovation) serial port (AE Bus)
The manual talks about little endian conversion, CSR and checksum that I just can't make it work. does anybody know how to write and read to this serial port?
I have used the write and read to serial port from examples with no luck and no response from the generator. I have attached the generator's manual here, the serial commands section starts at page 65 (4-25)
Has anybody written a program to talk to Ovation RF generator? can anybody help me out and get me started? I am stuck!!!. ... appreciate your help. thanks.
~Johnny
~ Johnny
Attachments:
Ovation - AE RF generator.pdf ‏1444 KB

Thanks... so I started with the basic serial write and read, enetered hex text strings into the serial write, including the checksum and what I read back is not always correct because for example I need to calculate the XOR in the program and not just eneter it as a hex value. I should also put the write and read into a loop because I will be writing and reading to serial port 2 dozen times.
I am working with two devices, one is the generator, the other is a controller board that has a very similar serial bus structure as the generator's AE serial bus. the controller board has stepper motor drivers that move two variable capacitors. for the generator, I need to turn the power on and off and set to different power levels. for the control/stepper motor driver board: I need to read the values from a text file(attached). the text file has 3 table, table1, column1 is the number of steps that the stepper motor will move and column2 is the nominal capacitor values for C1. same thing table2; values are number of steps versus nominal cap values for C2. I need to creat a matrix such that to move the C1 to steps listed in the table, and for every step increment in C1, I need to move the C2 motor to 20 different position (listed in the table3 that has the desired percent value of total capacitance ) position and make a measurement of the impedance of the capacitors with agilant E5061 network analyzer and write the data back into the same text file at the end where it says "IMPEDANCE_REAL     in Ohm    one line per C1 position"  and into a excel sheet too while taking a measurement... and do the same thing all over again for C2 versus C1. I think  I need to use the producer consumer design pattern eventually when I get the details worked out first.
any suggestion? .... much thanks.
~ Johnny
~ Johnny
Attachments:
Basic Serial Write and Read1.vi ‏24 KB
cap-table.txt ‏7 KB

Similar Messages

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

  • Writing to serial port 1 from a PDA

    ok this program is driving me NUTS! i have this microchip which uses a certain protocol... now this protocol requires that you send it some characters in hexadecimal so it'll reset... afterwhich it'll send you a data packet containing the version of the microchip etc etc (it's an aduc812... which you can find on www.analog.com)... anyway, that's not important... i am having trouble actually WRITING to serial port 1... i noticed that doing it through an actual PC requires some sort of "open serial port.vi" which is not available in the pda version... all i have is init.vi which is apparently not enough from what i am told... i thas to be opened first... initialized next... then written to then read from... does anyone know how i can acc
    omplish this open procedure with the pda module? is that some sort of software i'm missing? why isn't it included with the pda module add on... etc etc... thank you in advance... i really need help with this so as much information as possible would be appreciated... let me know if you need further info...
    christina

    Hey Christina,
    Here is a link to a knowledge base one simply writing to the serial port from a PDA.
    http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=E011F478861443EFE034080020E74861&p_node=%20DZ52363&p_source=External
    Hope this helps.
    Brett

  • After writing into serial port, the same message gets bounced back into the Inqueue also. If anyone know how to avoid this, please rpely.

    Hi,
    After writing into serial port, the same message gets bounced back into the Inqueue also. If anyone know how to avoid this, please reply.
    Thanks,
    Ganesh

    If you disconnect the cable going to the serial device, do you still get the echo? If so you have something going on in the port setup. If disconnecting the cable stops the echo then the device you're talking to is doing it - which would be my bet. One thing to check is whether this might not be normal operation. I have seen devices that if a command was successful, it simply echo'd back the command string you had sent. Also many serial devices have setting for specifying whether they are to echo commands.
    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

  • Reading/writing to serial port w/ VISA in Labview

    I'm writing a Labview program to control and to read data from a Varian vacuum pump controller. It is connected to the serial port in my computer, and I have been trying to open a VISA session to communicate with the instrument. So far, however, the computer cannot see the instrument--I get the same error messages reading and writing to the instrument as I do to an empty serial port. Does anyone have any suggestions on what the problem might be? Thank you.

    There are a lot of possiblities. Is the cable correct? You probably need a crossover cable (TX and RX) swapped. You also need to check and make sure the serial ports on both ends are set the same (i.e. baud rate, handshaking, stop bits, etc.). Make sure that the port is enabled. I've seen people try to use a comm port only to find that a modem card installation caused the port to be disabled. You could also try using hyperterminal to talk to the instrument. If you can communicate there, you can eliminate any hardware problem.

  • 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

  • Problem in Accessing serial port using java comm Api

    I have installed java comm Api in my pc.
    i have gone through the instalation instruction which comes on this package.
    I have done the instalation like this
    Copy win32com.dll to my <JDK>\bin directory.
    Copy comm.jar to my <JDK>\lib directory.
    Copy javax.comm.properties to my <JDK>\lib directory.
    and restart the system.
    But when i run the BlackBox , it is giving me message
    "serial port not found".
    Can any one tell me , what is the exact problem ?

    I'm not sure what you mean by BlackBox, but I have used the COMM api extensively.
    The majority of problems is that the api cannot see the serial port (which is what you are describing) and this is caused by incorrect placing of the javax.comm.properties file.
    As well as <JDK>\lib, try putting it into <JRE>\lib as well. That has often solved problems on my setup.

  • Problems reading the serial port with labview 5.1.

    I open the example serial.vi , I select write to serial port, run the programm, I don`t have any problem. But when I select read serial port, I get the error code 16392and hex code error x4008. I need to know what can I do? Thanks a lot

    Any time you get an error in LV you can right click on the error cluster indicator and do a "Explain Error".
    If you do this for the error code you reported, the explanation says that it was a framing error.
    In serial communications, a framing error indicates that the hardware was not able to detect a start bit, data then the stop bits that comprise a frame.
    This prompts me to suggest that you check you port setting on the serial port. You want to make sure you are setting the port for the correct;
    Number of start/stop bits,
    Baud rate
    data bits
    parity (just for good measure)
    and hardware handshaking.
    I hope this helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Problem communicating via serial port in Linux

    Hello,
    I am trying to transfer data via serial port, in Linux.
    But it is impossible till now!
    I get Runtime exception.
    Here is my code:
    public class Main {
        public Main() {
        int num=5;
        int[] array = new int[5];
        public static void main(String args[])  {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    array[0]=1;
                    array[1]=2;
                    array[2]=3;
                    array[3]=4;
                    array[4]=5;
                    new ParallelCommunication(num,array);
    import java.io.*;
    import java.util.*;
    import javax.comm.*; // for SUN's serial/parallel port libraries
    //import gnu.io.*; // for rxtxSerial library
    public class ParallelCommunication implements Runnable, SerialPortEventListener {
       static CommPortIdentifier portId;
       static CommPortIdentifier saveportId;
       static Enumeration portList;
       InputStream inputStream;
       SerialPort serialPort;
       Thread readThread;
       static OutputStream outputStream;
       static boolean outputBufferEmptyFlag = false;
       int num;
       int[] array;
       public ParallelCommunication(int this_num,int[] this_array) {
          boolean portFound = false;
          String defaultPort;
          num = this_num;
         array=new int[this_array.length];     
          array = this_array;     
          // determine the name of the serial port on several operating systems
          String osname = System.getProperty("os.name","").toLowerCase();
          if ( osname.startsWith("windows") ) {
             // windows
             defaultPort = "COM1";
          } else if (osname.startsWith("linux")) {
             // linux
            defaultPort = "/dev/ttyS0";
          } else {
             System.out.println("Sorry, your operating system is not supported");
             return;
    //      if (args.length > 0) {
    //         defaultPort = args[0];
          System.out.println("Set default port to "+defaultPort);
          // parse ports and if the default port is found, initialized the reader
          portList = CommPortIdentifier.getPortIdentifiers();
          while (portList.hasMoreElements()) {
             portId = (CommPortIdentifier) portList.nextElement();
             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (portId.getName().equals(defaultPort)) {
                   System.out.println("Found port: "+defaultPort);
                   portFound = true;
                   // init reader thread              
                   initialize();
                   break;
          if (!portFound) {
             System.out.println("port " + defaultPort + " not found.");
       public void initwritetoport() {
          // initwritetoport() assumes that the port has already been opened and
          //    initialized by "public void initialize()"
          try {
             // get the outputstream
             outputStream = serialPort.getOutputStream();
          } catch (IOException e) {}
          try {
             // activate the OUTPUT_BUFFER_EMPTY notifier
             serialPort.notifyOnOutputEmpty(true);
          } catch (Exception e) {
             System.out.println("Error setting event notification");
             System.out.println(e.toString());
             System.exit(-1);
       public void writetoport(int counter) {
          try {
             // write string to serial port
             outputStream.write(String.valueOf(array[counter]).getBytes());
          } catch (IOException e) {}
       public void initialize() {
          // initalize serial port
          try {
             serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
          } catch (PortInUseException e) {System.out.println("Port In Use.");}  //******Here is the Exception******
          try {
             inputStream = serialPort.getInputStream();
          } catch (IOException e) {}
          try {
             serialPort.addEventListener(this);
          } catch (TooManyListenersException e) {}
          // activate the DATA_AVAILABLE notifier
          serialPort.notifyOnDataAvailable(true);
          try {
             // set port parameters
             serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                         SerialPort.STOPBITS_1,
                         SerialPort.PARITY_NONE);
          } catch (UnsupportedCommOperationException e) {}
          // start the read thread
          readThread = new Thread(this);
          readThread.start();
       public void run() {
          // first thing in the thread, we initialize the write operation
         initwritetoport();     
         for(int i=0; i<=num_of_inputs; i++) {
            // write string to port, the serialEvent will read it
            writetoport(i);
         serialPort.close();     
       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:
             // we get here if data has been received
             byte[] readBuffer = new byte[20];
             try {
                // read data
                while (inputStream.available() > 0) {
                   int numBytes = inputStream.read(readBuffer);
                // print data
                String result  = new String(readBuffer);
                System.out.println("Read: "+result);
             } catch (IOException e) {}
             break;
    }...and the outcome is :
    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
    Error opening "/dev/ttyS0"
    tcgetattr(): Input/output error
    at com.sun.comm.LinuxDriver.getCommPort(LinuxDriver.java:66)
    at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:369)
    at ParallelCommunication.initialize(ParallelCommunication.java:128)
    I have searched a lot and I couldn't find a solution.
    Thank you.

    I'm having the same problem this helped somewhat debug the problem
    http://bloggerdigest.blogspot.com/2006/11/linux-serial-com-port-diagnostic-test.html
    I'm running Suse 10.3 and apparently it does not recognize my serial ports. So before
    you can test your Java code you have to figure out how to make linux see the ports.
    If I find a solution I'll let you know but if you find one first let me know. Thanks.

  • Error while reading/writing to serial port

    Hello,
    I am trying to read/write to my serial port but
    this message shows every time i launch the
    program. Does anyone know some help ?
    Thanks
    FdB
    Attachments:
    error2.ppt ‏172 KB

    Frederico
    This VI (LV8)
    1. Open the serial port at 2400 baud
    2. Powers down the PT104 and wait 0.5 secs for this to settle
    3. Flushes the serial power buffer to remove any power down acknowledgements in the serial buffer
    4. Powers up the PT104 waits 1 sec for things to settle
    5. Reads any bytes in serial rx buffer.
    6. Power down the PT104
    7. Close the COM Port.
    This is a bit of a guess but this is how I would approach it. Can you try this and let us know how you get on?
    thanks
    David
    Message Edited by David Crawford on 07-20-2006 10:31 AM
    Attachments:
    PT104 - Get Version at Power Up.vi ‏56 KB
    PT104 - Get Version at Power Up.jpg ‏50 KB

  • Big Problems with the Serial Port

    I'm Spanish and my English is not very good, I'm sorry but I need your help.
    I want to connect two computers (my desktop and my handbook) with the serial port (COM2 in both sides).
    I have the cable.
    I have installed JBuilder 7 in both computers.
    I have installed "commapi"
    I'm running SimpleWrite.java (the example from Sun) in one of them and SimpleRead.java in the other.
    I don't get in any moment receive any data.
    I execute first SimpleRead and I can see what this process is waiting something. After, I execute SimpleWrite (many times), this process star and stop correctly but never the first aplication receives nothing.
    I am trying for four days, I am desespereted.
    I need your help is very important to me. I don't understand what is happening!!!!. This is my e-mail: [email protected]
    Thank you very much.
    NOTE: my handbook has just one serial port, before had a winmodem but it was eliminated.

    hi,
    when your notebook has only one port, how do u know that this port is COM2? I think u gave a wrong parameter for the SimpleReader or SimpleWriter so one send data to a port (say COM1) but the other receives data from another port (say COM2).
    regards,
    eedych

  • Reading and Writing For Serial Port (RS232)

    Hi there;
    I want to send data from my comport to a device and take data from there. I use Windows operating system. I looked at a bit javax.comm and RxTx.
    Firstly do i have to use RxTx for my project because of i am using Windows operating system?And;
    Where should i began to start simply send and receive data via RS232?
    Edited by: furkankamaci on Feb 14, 2009 8:05 AM

    Use RxTx and follow its examples.

  • 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

  • Problems with VISA and the serial port

    Hello,
    i have a little problem with the serial port and VISA. I have changed an existing LabView- Software in that way that I have replaced the serial- module by the VISA- module. The function of the program is to communicate with different devices by RS232. After changing the modules to VISA the software doesn't work probably. The problem is, that when I try to communicate with one of the devices first I get no answer. When I try it a second time after some seconds the communication works perfect. After about a minute I send another message to my device but there is no answer again. I have to send the message again.
    I hope someone in this forum can help me with my problem
    cu Marco

    Marco,
    this sounds very much like a problem with the termination of your messages. You may have to tell VISA to add a termination character. Please follow the instructions in this document.
    Best regards,
    Jochen
    National Instruments Germany

  • How to unbundling binary structure coming through the serial port

    Hi to all
    I have a board that is transmitting a binary stream. This stream is a structure repeated constantly ... the payload of this structure looks like this
    I have no problem reading the serial port and disaplying ASCII data but this is not my application.
    ANALOG_COUNT is (2)
    typedef struct
    uint16_t light;
    float TempAmbient;
    float TempTarget;
    uint16_t ADC[ANALOG_COUNT];
    int16_t AccX;
    int16_t AccY;
    int16_t AccZ;
    }StreamContext_t
    The idea is for me to, once I get the 20 bytes that comprise the strcture I want to brake it into its elements to feed it to graphs or what ever.
    Thanks
    Alejandro
    Solved!
    Go to Solution.

    You are still making life to difficult.  Try this.  It is much simpler to understand and it will work correctly.  Ok, there may be some debugging.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Start.vi ‏18 KB

Maybe you are looking for

  • Error in updating database

    hi, i am getting an error "String or Binary data is truncated" by using the querry.. QryStr = "update OSRI set U_NetUOM='" & uom & "', U_Length='" & length & "', U_Height='" & height & "',U_sqf = '" & sqft & "',U_sqm = '" & sqmt & "' where ItemCode =

  • Use data type enhancement in XSLT mapping in XI

    Hi Experts, I'm working on SNC and I need to add an element to a data type.  I have created a data type enhancemnet with the element in it.  Now I need to get this into my XSLT mapping.  I have tried creating a message type but the data type enhancem

  • Parse XML file, read a tag with whitespaces value.

    Hi all, I've got a problem with reading a spaced value record from xml file using sys.xmltype. My xml file contains the following: <?xml version = '1.0'?>; <ROWSET> <ROW num="1"> <FIRSTNAME>Nik</FIRSTNAME> <LASTNAME> </LASTNAME> <AGE>30</AGE> </ROW>

  • Reg: JDBC -- RFC Sync call

    Hi All, I have created a scenario between JDBC and SAP, which is a synchronous communication. In SXMB_MONI and in communication channel monitoring it is successful. JDBC synchronous communication channel is able to fetch the data, However it is not a

  • NetBeans 6.1----Woodstock component : Bubble Help

    Hi All, I recently came across the new Woodstock component : Bubble help. I have used it in the Onclick event of an image hyperlink which is in a table Column. Now if i select the image hyperlink in first row of the table, the bubble appears half and