LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Serial Misery....

Solved!
Go to solution

Good job, it looks great, glad to see you're using a "wait until done" loop. Keep in mind, that "27" in the loop simply makes the loop wait 28*0.02 = 560mS. So you have a safety timeout of ~560mS. The "27" has nothing to do with your original "27" you had wired to the read. Not that it hurts, but it just seems coincidental that you used the same number.

 

The sequence structures are completely unnecessary in cases 1 and 2. You have a wire that connects the "frames" together, so the frames are not needed. Get it?

Message Edited by Broken Arrow on 03-22-2010 08:14 AM

Richard






0 Kudos
Message 21 of 36
(1,305 Views)

I used 27 as i'm expecting 27 characters to be clocked through my loop.  (27 is the loop iterations i want to get to)

 

I have made some changes, but i notice that my recieve frequently gets out of sync which messes up my data as i index the recieved string to get my numbers.

 

The microcontroller is running a 200ms loop but will only send data when it recieves "WE" which i want labview to send every 500ms or so.

 

I have attached the new code. Any ideas on my sync issues ?

 

 

0 Kudos
Message 22 of 36
(1,270 Views)

You are stopping your loop if the Bytes at port is greater than 0.  Suppose only some of your 27 of your bytes have come in during that interval.  The loop will stop, it will read those x number of bytes, and you data will look corrupted because because you are missing bytes.

 

It is generally never necessary to consistently flush the serial buffer.  If you happen to flush it in the instant before the remaining of the 27 bytes have been received, then you will wind up with with the last couple bytes remaining in the buffer for the next time the whole loop iterates.

 

You also have a potential race condition in your writing to file.  You have two Write to Spreadsheet files.  One before the inner True case and one inside the inner true case.  Which one do you want to execute first?  As it is, either one could execute first because neither one is dependent on waiting for the other to start or finish executing before it runs.  If instead of splitting the file path wire, you wired it out of the first Write to Spreadsheet file before sending it into the inner true case, then you can guarantee the one outside must finish executing before th inner true case executes.

0 Kudos
Message 23 of 36
(1,260 Views)

Thanks for the info,

                              so if i get rid of the >0 stop in the loop, so it will only stop if the data >27  or = 0 that should sort out my sync problems ?

 

 

Also regarding the write to file case structures, i want to exicute the inner case just once (this creates colum titles) then exicute the outer one everytime the timeout occures (to write data to the file)

 

Thanks, Zac

0 Kudos
Message 24 of 36
(1,257 Views)
I just tried getting rid of the >0 stop and it is still getting out of sync ?
0 Kudos
Message 25 of 36
(1,250 Views)
The problem with your loop is you're doing an OR with the >0, it needs to be an AND. With the OR, it stops at >0. With AND, it makes sure it's > 0 AND all the bytes have been received. See pic.
having a hard time editing to get the pic to link-in, just click it 😉
Message Edited by Broken Arrow on 03-23-2010 11:54 AM
Richard






0 Kudos
Message 26 of 36
(1,250 Views)

Wow, it works perfectly now !    thanks for that, i've been chasing this problem for hours !

 

 

Thanks, Zac

0 Kudos
Message 27 of 36
(1,230 Views)

Having said that.....

                              i have compiled it to en exe and it wont find the comport, are ther any extras i need to include in the install ?

0 Kudos
Message 28 of 36
(1,187 Views)

Zac:  Just a couple quick thoughts on the transition to an application. 

1.  In your original vi, do you have the COM port value saved as a default value in the "VISA resource" name control?

2.  If you are moving the executable to a new PC, is VISA installed on that PC?  Does the COM port show up in MAX?

GCentral
0 Kudos
Message 29 of 36
(1,179 Views)
Bill made some good points. Also, in the Build Specification, you have to Include VISA support, or Include serial port support, something like that. Look for it, you'll find it. Then build again and it should work.
Richard






0 Kudos
Message 30 of 36
(1,176 Views)