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.
Similar Messages
-
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 KBFrederico
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 -
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...
christinaHey 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 -
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 KBThanks... 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 -
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,
NehaMy 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();
-
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,
GaneshIf 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 -
0 bytes at serial port after Visa Write
Hi,
I'm having problems communicating with a Pollux box controlling a stepper motor (both from Micos). The Pollux box has an RS232/485 connection to the computer.
I have tried adaptations of LV's Basic Serial Read and Write example. Even for the basic example there has never been any bytes at the serial port after the write.
I have attached some sample code for LV 10.0.1(64bit) and the OS is Windows Server Enterprise 2008.
The Visa drivers have just been installed.
After some research I have added a 'Set I/O buffer size' as advised by http://digital.ni.com/public.nsf/allkb/60DDFED7EFEFE7188625705700750821?OpenDocument
The time-out is set to 10s, I have a wait of 1s before read and 0.5s between each write (the characters are written individually incase that was the problem).
The write command getaxisno_ should reply with the default axis no which is 1. However, there is never any reply.
The termination character for Venus2 is a space for transmitting commands and ASCII CR LF at the end of received data.
I'm not sure what else could be wrong. According to MAX the device is working properly. Although, when I try to open a Visa test panel in MAX the program crashes. I'm not sure if this is a related problem.
I'd be really grateful for any advice, have been trying to fix this for a few days now.
Thanks in advance!
Ciara
Attachments:
Getaxisno test.vi 18 KBThanks, I'll search those now.
When I click the test panel button, the Max window disappears and the program is closed. Next time I open it an Unexpected Error box opens with a message saying there was an unexpected error and I should search Info Code MAXKnownException.
'The exception occurred in the NIMax process in the function (Unknown).'
I have searched this and the info advised me to send a report with log files etc to NI which I have done. Just waiting on the reply.
I copied the Visa resource name from MAX and the termination character is the same as what a previous owner of the equipment used in Visual Basic. -
Control Camera Attibutes through serial port using VISA commands
Hi there,
I'm using a Basler acA2000-340kc camera through an PCIe-1473R FPGA as frame grabber.
I would like to be able to configure the camera through the serial port just in LabView, not using a third-party as Pylon (which I can do now).
According to this forum post
http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/My-Basler-acA2040-180km-NIR-is-not-visible-in...
this is possible just taking the VI posted here
https://decibel.ni.com/content/docs/DOC-5049
and converting from IMAQ to VISA, as RIO frame grabbers cannot use IMAQ. I have been trying to do this by changing the IMAQ vi to their VISA equivalents, but I have no good results.
Does anyone know which are the steps to go from that piece of code to one that can be used to control the camera in my case?
Thanks a lot,Hi i.popa,
Basler makes the Basler Binary Protocol Library for serial communication with their cameras. If you make sure you're running the serial server section of your FPGA code to keep the serial port open, you should be able to use calls from this library to communicate with your camera. We have a community example with more information on using the Call Library Function Node to call a DLL. This DLL will take care of all the processes needed to write from and read to the registry, so this implementation will probably be similar to the example program you listed above, using calls to this library instead of the IMAQ Serial functions.
Good luck with your application!
Emily C
Applications Engineer
National Instruments -
Problem in reading data from serial port continuously- application hangs after sometimes
I need to read data from two COM port and order of data appearance from COM port is not fixed.
I have used small timeout and reading data in while loop continously . If my application is steady for sometime it gets hangs and afterwards it doesnt receive any data again.
Then I need to restart my application again to make it work.
I am attaching VI. Let me know any issue.
Kudos are always welcome if you got solution to some extent.
I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Attachments:
Scanning.vi 39 KBbillko wrote:
Ranjeet_Singh wrote:
I need to read data from two COM port and order of data appearance from COM port is not fixed.
I have used small timeout and reading data in while loop continously . If my application is steady for sometime it gets hangs and afterwards it doesnt receive any data again.
Then I need to restart my application again to make it work.
I am attaching VI. Let me know any issue.
What do you mean, "not fixed?" If there is no termination character, no start/stop character(s) or even a consistent data length, then how can you really be sure when the data starts and stops?
I probably misunderstood you though. Assuming the last case is not ture - there is a certain length to the data - then you should use the bytes at port, like in the otherwise disastrous serial port read example. In this case, it's NOT disastrous. You have to make sure that you read all the data that came through. Right now you have no idea how much data you just read. Also, if this is streaming data, you might want to break it out into a producer/consumer design pattern.
Not fixed means order is not fixed, data from any com port can come anytime. lenght is fixed, one com port have 14 byte and other 8 byte fixed..
Reading data is not an issue for me as it works nice but I have a query that why my application hangs after sometime and stops reading data from COM PORT.
Kudos are always welcome if you got solution to some extent.
I need my difficulties because they are necessary to enjoy my success.
--Ranjeet -
Read data from serial port or TCP port of frontend PC
Hello Friends,
I have requirement to read data from device connected to frontend PC which will provide meter reading data.
Vendor has given me two option.
1. Device can be connected to seiral port and data transfer will be done through MODBUS RTU protocol.In that case data need to capture from serial port.
2. Device can be connected to TCP port and Socket program can be provided for data transfer. In that case SAP will act as client and communicate with TCP port.
There will be multiple workstation with individual meters connected to them.
I am aware of text file interfacing through front end tools using custom code using VB,JAVA or others.
Is there any solution availble to achieve above things using ABAP other than text file , like direct communication?
I am using ECC 6.0.Hello,
Socket programming in not available on ABAP, but you may use RFC for the same.
Use the below links for more details
[Link 1|http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf]
[Link 2|http://forums.sdn.sap.com/thread.jspa?threadID=1820233]
Regards,
Abhishek -
How to read from 4 serial ports
Hi
Does anyone know how to read from 4 COM ports with only 2 interupts? I can
manage it by using Close serial driver.vi, however this makes the amount of
allocated memory by Labview increase throughout my experiment and thereby
slows down the computer. I use Labview 4.0.1 on Win95.
Regards
Frede LeiHi,
Thanks for the reply however I could able to write the PCR to read one variable without wagetype. My question is, I have 6 variables in VAR table and now I want to read all the variable and based on the variable I need to create the 6 wagetype each for each variable.
I know to create the wagetype with one variable.
ZSSB CCE : restore 7SSB wage types paid separately in RT
AMT=& VSSB Set
AMT?0 Comparison
ADDWTI7SSB IT Input table
=
However, how I could create the only 1 PCR for 6 variable?
regards,
Saurabh Garg -
Reading datas from serial port (palm)
Hi,
Because read methods (DataInputStream, stream on palm serial port) are blocking, how do I know if there is at least one available byte that can be read ?
ThanksHi,
I thought the method available() resolve the problem but this method gives the number of byte available without blocking.
I use :
public DataInputStream dis = null;
public int readDataBuf(byte[] buf) {
int status = -1;
try {
if (dis.read(buf, 0, 1) > 0) {
status = (buf[0] & 0xFF);
catch(IOException e) {
System.out.println(e.toString());
return status;
but with the read method if there is not byte the program stop wainting a byte.
Thanks -
Reading data from serial port needs optimisation
Hi,
We have got a class which reads input from some hardware connected to the serial port.
The data coming from the device can cross over 1mb at a time.
We would like to optimize the speed of the program such that no data is lost during the readings.
Hence, we would like to store the entire reading into memory such that it can be stored into a file or database once the readings have been completed.
The serialport class returns a byte[] of the current data in the buffer. There could be over 8000 such readings.
Would it be better to convert the byte[] into a char[] and append into a StringBuffer
or append the byte[] as is into an ArrayList and perform the conversions and operations on it later?
Reg,
ChetanThe ArrayList will not only be much faster but it will preserve the original data. Unless the incoming data really is a String there is no point in converting it.
-
Dev question - is it possible to read the iPhone serial port?
Hi,
apologies if this is not the right place to ask this question. If so, please let me know the correct place.
I am new to iPhone sw development and would like to know if its possible for a non-jailbroken 3G iphone to read/write data to the serial port (dock connector). Am trying to find out before I invest in a special device I'd like to connect.
thanks much,
'markhttp://developer.apple.com/iphone/program/accessories/
For additional information, refer to the documentation for the iPhone 3.0 SDK or ask in the iPhone developer forums.
Maybe you are looking for
-
Came up with message "disk could not be read or written to"
brand new ipod, jsut got it yesterday and this shows up, what is wrong with my 4th ipod in two years now! anyone know how to fix this or is it jsut a faulty ipod? other complication ive had with it today are itunes freezing which ive reinstalled, and
-
I always have trouble with my mailbox. It is always asking for my passwords but everything has been verified. How can I get it to stop doing it and start working????
-
** CONTACT MANAGER and CONTACT CATEGORIES **
I am a 9930 owner. Is there any discussion about fixing the Contact Manager in the new OS to include more of vCard fields as in BB OS version 7x and prior? We need Contact Categories field in the Contact Manager and the tight integration with MS Outl
-
Firefox, XPpro, CS5: For four days, a particular website I visit has become corrupted; it's Wordpress Right column is in disarray. All other websites remain normal in appearance. The right column contains various categorized lists and book covers (f
-
Load external images and video in edge
Hi. I am looking into edge instead of flash. My question is how do you load external images and videos from an external server? To clarify, I need to insert a link from where the images can load into the stage, so they don´t take up any of the final