LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DB Tools Insert Data results in broken DB record

Solved!
Go to solution

Hello, I'm a new LabView user trying to create a VI that will receive a csv string from a scale add a date time stamp and post the data to an access database. I'm using a 32 bit ODBC connection to the database. There are 3 potential string lengths calibration is only one column, pass and fail are 6 columns. I've seen the problem on the pass and fail but not the calibration. It works most of the time but occasionally the database record will be split in the middle and half of the data is in one record and the other half is in the next record. I've tried adding delays thinking that there was a timing issue with the data coming from the com port of the scale but even with the delays the issue occurs. I've also tried increasing the bytes at the com port to wait until the complete string comes to the com port but it still happens. I can also see the break on my front panel too so I don't think the problem is between the VI and the DB. I tried adding the column names to the DB insert but it didn't work so I took it back out. I'm at a loss why this is happening, any advise would be much appreciated.

Download All
0 Kudos
Message 1 of 5
(1,280 Views)

Hello,

 

your problem is that you do not check if the string you get from "Read VISA" is a complete record set. Just reading a bunch of characters that are currently available in the buffer does not ensure that this buffer has all the data you would like to have.

 

Possible solutions:

  • Perhaps your scale does use a termination char to distinguish between different record set. If that is the case then I strongly recommend to use that to your advantage. Enable the term char, forget about bytes at port and always read e.g. 1000 bytes.
  • Programm a parser that checks for a complete record, e.g. read bytes and concatenate this so long until you find an OK in your answer string.

Regards, Jens

Kudos are welcome...
Message 2 of 5
(1,225 Views)

Thanks Jens! That makes perfect sense. I'll give it a try.

0 Kudos
Message 3 of 5
(1,207 Views)

I've added the termination character and increased the bytes read to 1000 and the broken records is fixed but now I'm getting a VISA timeout error. This error occurs after about 10 seconds with no data. After acknowledging the error I'm able to continue sending data. I changed the port setting in NI-VISA for the termination character and I've tried replacing the simple error handler with a general error handler and clear error to prevent the error from stopping execution but the port still times out even if there is no pop up error. When this happens it records a date time stamp with no data and will continue to do this every 10 seconds until I stop execution or data is actually on the port and it will record.

Download All
0 Kudos
Message 4 of 5
(1,166 Views)
Solution
Accepted by topic author CJ67

I've found a solution that works. I created a case for calibration, pass and fail string lengths. The default does not do any concatenation or database entry. For anyone with a similar project I've attached examples of each case.

0 Kudos
Message 5 of 5
(1,156 Views)