02-04-2011 04:54 AM
Hello guys !
I have a special problem communicatin through RS232 with a PIC microcontroller.
The problem :
On push of a button i want to read a value from the microcontroller.
On another push of a button, i want to write a value to the microcontroller.
However, i get an error : "VISA: (Hex 0xBFFF0015) Timeout expired before operation completed."
I've tried to search the forum for similar problem, but i haven't found a suitable answer.
I also post my current code for reference. I'm using LabView 8.5.1.
The RS232 communication is working fine (i can read and write from the PIC).
I tested the connection extensively so i think that te problem is not there.
Can u help me ?
Thank you !
02-04-2011 05:24 AM
02-04-2011 05:39 AM
Thank you 4 your answer !
I tried the proposed sollution in the form of the attached vi but the error remains.
Is there a way to use event structures to accomplish this task ?
Thank you!
02-04-2011 05:56 AM
02-04-2011 06:08 AM
Hello !
Thank you 4 your answer !
The proposed sollution also doesn't work.
I don't really know what else to try
02-04-2011 11:06 AM - edited 02-04-2011 11:15 AM
Are you waiting for a response from the device after you send it a command? Are you getting any data back? A simple delay is not a very good solution since your program may work for one given situation but the hard delay may not in others. You can use a VISA event to wait for data at the serial port. How much data are you expecting? If it is a larg eamount of data you may want to calculate the timeout for the read based on the amount of data and your given BAUD rate. If you expect a large amount of data you may not have your timeout set long enough for all the data to arrive, especially if you are using slower BAUD rates.
I noticed in your code that you have enabled the read to look for a termination character. Does your device send one? If not, you may be getting the error because you have not received the 1000 bytes you indicating you want to receive. If you will not be getting a termination character and you don't know how much data you will be receiving you need to create some type of algorithm to read data and decide when to stop. Th eapproach I use is to read a single byte. This read will contain the maximum timeout to wait for the data to arrive. Once a single byte has been read I continue reading chunks of data using a small timeout value. This value should be long enough to allow any small delay that occurs in the data as it is being sent from the device but short enough to indicate the data is complete once a timeout does occur. This timeout error is discarded since it is not a true communication error.
NOTE: You should avoid using controls as variables. You have your Byte to Read controls set as default values and hidden. Therefore they are nothing more then a constant. Hiding controls simple to hide "variables" is not a good coding practice. Either expose the controls to teh user or use a constant.
02-04-2011 12:12 PM
Mark has already discussed lot many things
I suspect that you are getting time out error just beacase data sent by PIC is not 1000 bytes.
For testing you can use "VISA bytes at serial port" vi to actually check how may bytes have already arrived at port and then read those many bytes on port
We can help you better if you can discuss bit more about the packet format
Tushar Jambhekar
tushar@jambhekar.com
Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog