From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-11-2007 08:36 AM - edited 01-11-2007 08:36 AM
Message Edited by Steve.Briggs on 01-11-2007 09:37 AM
01-11-2007 08:47 AM
01-11-2007 09:45 AM
Is there a terminator after each line of data? If there is, then you could do something like the attached. After each line is read, the string is searched to see whether the text 'END' is included. If it is, then the while loop stops. If it doesn't, then the ack is written. If there is no termination character after each line then it will be a just a little more complicated. You would check the number of bytes and read that number and keep reading until the number of bytes available is 0. Check the returned string for 'End' as in the example.
I rewrote the code for writing all of the command strings too. mainly to get rid of the sequence structure. Because you have not data flow between the VISA Writes and the delays, you don't know whether the delay will happen before or after the VISA Write. You could actually have something like VISA Write, VISA Write, Delay, Delay and I think you want to have a delay between each write.
01-11-2007 10:05 AM
01-11-2007 10:12 AM - edited 01-11-2007 10:12 AM
Well I see that i am too late. Well see if this attached vi helps any. I did a similar thing by getting rid of the sequence structure and using more of an Interrupt read thread. let me know if you can open it i saved it as 7.1 from 8.0 so you might need to replace the time delay vi and the serial config vi
-James
Message Edited by James R on 01-11-2007 10:18 AM
01-30-2007 09:37 AM - edited 01-30-2007 09:37 AM
Message Edited by Steve.Briggs on 01-30-2007 10:37 AM
01-30-2007 09:56 AM
01-30-2007 11:56 AM - edited 01-30-2007 11:56 AM
your read vi is reading as fast as the loop is going so if nothing is at the port then there will be 0 bytecount. if you only want to read data when it arrives at the port look at the code that i posted earlier to use an interrupt method of retrieving data from the serial port. if you wish to continue to read like you are try to put a small delay in the loop and you will get much better performance.
you can also use the bytes at port property node and when it is greater than 0 then read the bytes at the port
Message Edited by James R on 01-30-2007 12:00 PM
02-02-2007 09:56 AM - edited 02-02-2007 09:56 AM
At this point, every attempt is resulting in error 1073807339 for timeout.
I took a look at the vi you created James and the string read resulted in infinite a never ending feed of "\r\n", and then the same timeout error.
I then took a look at the bytes at port property node, and have it read the bytes when they are greater than 0. This worked for one line, when the byte count was 17, but then resulted in byte counts of 0 there after, so nothing ever progressed.
I then put a small delay in my loop where I read and write the ack command (hex "06"), but it gave me an instant error 1073807339 for timeout rather than occurring after I read one line of data, which usually happens.
When I talked to one of the creators of the spectrophotometer I am using he said..."Note that data comes up a line at a time and each line has to be ACK'd in a few seconds or it times out, approximately less than 8 seconds." I told him of my failure and errors, to which I received a reply of "I do not understand why you are having these troubles" and nothing more after that.
With that being said, I decided to take an opposite approach and removed every Time Delay during a write/read procedure and it would work...partially . Out of the 5 scans I need, it would successfully get through 2 or 3 scans, and then timeout at the 4th scan. I assume this has something to deal with how fast I am reading, the byte count, or not being able to respond with the ack command at the end of each line quick enough.
I know full well that begging won't get me anywhere, but I am in dire need of a solution to this problem. I'm sure many of you can relate to my frustration...having something work so well, being very close to finishing the project, then having these errors pop up and having no way of fixing them.
The VISA write/read vi is attached.
Many thanks for any input to this problem.
Message Edited by Steve.Briggs on 02-02-2007 10:57 AM
02-05-2007 12:45 PM