LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial visa read losing the first part of the string

Hello all, I am reading a Hp437b power meter through a prologix gpib to usb converter and losing the start of the string. So if the string is "abcdef" sometimes it will give "bcdef", and others it will give " def" and so on; the characters that get cut of are in the front of the string and vary as to the numbers of characters that get cut off. Does this have to do with the termination character that I have been hearing alot about?
Mark R Rivet
BSIT/SE
0 Kudos
Message 1 of 10
(4,098 Views)

Here is the VI that I am using, it was an example vi that came with the converter and I modified it with a while loop; timer; and file i/o. I have also attached the log file so you can see what I mean about losing characters.

Mark R Rivet
BSIT/SE
Download All
0 Kudos
Message 2 of 10
(4,092 Views)
Set your serial port settings once before the loop starts.  Don't close the port until after the loop ends.  I don't know why you are doing these things on every iteration of the loop.  What is probably happening is that some of the data is coming during the period of time between when you close the port and reopen.
0 Kudos
Message 3 of 10
(4,073 Views)

I am quite new to all of this and I am sure that my vi has some unorthodox things going on. I appreciate any comments that you can give to me the design of this VI; I have 1 week on lab view so far, I am as green as they come. So, I will move the set serial stuff outside the loop, and also I will move the visa close outside loop and see what happens. I will report back today. Thanks for the reply, I was really at a loss for answers.

Mark R Rivet
BSIT/SE
0 Kudos
Message 4 of 10
(4,064 Views)

Also be aware, while 256 bytes may be perfect for the *idn command, it's not going to work for some other commands. You can wire the Bytes at Port directly to the Read function. Put a wait after the Write, such as 10 to 50mS.

 

 

Richard






0 Kudos
Message 5 of 10
(4,056 Views)

Well, it turns out to be the *idn? command that is messing things up. If I only use the Prologix commands, I get the measurement everytime, nice and stable.

 

                                                       This string does not work:

                                                                    *idn?

                                                                    ++auto 0

                                                                    ++addr 17

                                                                    ++read eoi

                                                 

                                                       This string works good:

 

                                                                    ++auto 0

                                                                    ++addr 17

                                                                    ++read eoi

 

 

So also I think that I only need to issue these commands outside the while loop; does that sound right. Now they are inside the loop and get written everytime. Can I just issue these once, and then continue to read inside the loop?

 

 

Mark R Rivet
BSIT/SE
0 Kudos
Message 6 of 10
(3,979 Views)

Genesis712009 wrote:

...

So also I think that I only need to issue these commands outside the while loop; does that sound right. Now they are inside the loop and get written everytime. Can I just issue these once, and then continue to read inside the loop?

 

 


How is the Write initiated? When the user starts the program? If it happens once per running the VI, and that's the end of it, then yes, put the Write outside the loop.   There are several architectures which will work, but it depends on the purpose of the VI:  To have the write sent upon pressing a button, put the Write inside the loop, but within a case statement which is triggered with a latch-type boolean button (so that it fires once per button click). Ultimately, you'll be better served with a State Machine, or Event Structure. To do write/reads properly, you need to get comfortable with these architectures.

 

Message Edited by Broken Arrow on 08-06-2009 09:46 AM
Richard






0 Kudos
Message 7 of 10
(3,975 Views)
I have a string buffer that you can enter the strings and it gets wired to the visa write function. So once you enter the command strings, you hit the go button and it starts and keeps going untill someone hits the stop button. Would you like to see my vi? I can send it along next time if you wish; its very simple. But keep in mind, I've only been at this for about three weeks off and on. 🙂
Mark R Rivet
BSIT/SE
0 Kudos
Message 8 of 10
(3,969 Views)

You'll generally get better help if you post a VI; otherwise, you'll get very general broad answers like my last one! Smiley Happy

 

Richard






0 Kudos
Message 9 of 10
(3,955 Views)
Ok, so here is my vi, this one works well. However, I would like to modify it to send the instrument setup commands only once; then start reading the output power until someone clicks the stop button. Oh, also, a recent request is to only log a particular value once and only make another write to the data file when the value changes. Because I take readings every second and quite often the reading does not change for some time. It might read 4.5 for two minutes then drop to 4.4. In the mean time, I have taken 120 readings and stored them. So that's got me struggling about how to do it labview. I can think about how I would do it in c or java but the labview part is evading me for now.
Mark R Rivet
BSIT/SE
0 Kudos
Message 10 of 10
(3,913 Views)