Serial Port Event Labview Student

Serial Port Event Labview Student Average ratng: 3,7/5 2416 votes

Hi, I do not know Visual Basic very well. I am trying to communicate with an Extech 421509 Thermometer via the serial port.

The LabVIEW Student Edition delivers all the capabilities of the full version of LabVIEW, widely considered the industry standard for design, test, measurement,.

Since I do not know VB very well I first wrote the program in LabVIEW to make sure I knew how to write the program, once I was successful with that I tried to write the code in VB. I am mostly successful with that except that in VB my buffer will be read 4 or 5 times and then there is nothing on my buffer. In LabVIEW I do not have this problem as I write to the buffer I can immediately read from the buffer. Here is a picture of my LabVIEW Block Diagram Here is a copy of my VB Code. ReadExisting will read as many characters as are available. If there aren't 14 characters available, the code in the timer tick routine won't execute, although the characters wills till be removed from the buffer.

Given the typical response time of a remote serial device such as this, and the fact that you are comunicating at 2400bd, it is unlikely that the whle transmission would be completed between the end of the WriteLine instruction and the start of the ReadExisting instruction. Ex yu midi. The simplest change would be to put a Do loop around the ReadExisting so that you continue reading until you get 14 characters. Autopano giga keygen mac torrent. Buff = ' Do buff = thermo.ReadExisting() Loop until buff.count => 14 but the problem there is that it might get hung up waiting for characters that aren't going to arrive. A better solution is to read the data in the serial port data received event and assemble the sentence of 14 characters there, before passig it back to the routine that extracts the data you are after. There's an example of this alternative here: You will need to change that slightly, to clear the queue and issue a new command every second. Is there any reason for declaring buff and thermo as Shared?

That doesn't look right to me. I did try both of those with no luck. I understand that if there is less than 14 characters available that the rest of the code will not execute. The part that confuses me is why does it read data the first 4 times (the full 14 bytes) but after that the buffer reads nothing (returns an empty string). Even if the transmission wasn't completed, after the time delay wouldn't those bytes appear the next time that I read the buffer since those bytes have not been read or cleared yet? I do not believe that it is a timing issue since it doesn't matter whether the timer is set for 1 second, 10 seconds or longer, it will still read something in the buffer the first four times and nothing after that. Also throughout debugging I have put time delays between the read and write commands with still the same result.

Ha ha, thermo and buff were declared as shared because I wanted to make them global variables (so they could be used in several sub routines at that time). I wouldn't doubt that I messed that up, as I had said I am very new to VB in fact my entire knowledge about I this language I have picked up from this project which I started about a week ago. With serial ports.ReadExisting() may not be all the data and you may need to Read Existing several times.