LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help with array manipulation

Solved!
Go to solution

Hi

 

I am a graduate student, lol and a novice programer. My school doesn't offer LabView so I have had to teach myself. I am taking several legacy HP analog instruments, to create a network analyzer, and using LabView to get a more user friendly "digital" version. I ran into a problem whlie retriving data from an HP 8750a storage normalizer with a DAQ.  What I need to do is pull a X & Y value while monitoring a PEN value to see if I should write, that is if Pen is greater than some value keep the data if not disregard it.  I am able to monitor the PEN, in VI it is Voltage 0, and over write the other data, Voltage 1 & 2, with 0's.  lol but this is not what i would ideally like to do.  I would like an end array of only elements when Voltage 0 is greater.  Can someone please point me in the right direction, lol i know this is kind of a stupid question.

0 Kudos
Message 1 of 10
(3,147 Views)

Why are you scattering LOL thoughout your message?  It makes it seem like you don't take yourself or your question seriously and makes your message kind of annoying to read.   Save the "LOL's" for when you are text messaging your BFFs. 

What does the term "PEN" mean?  When composing a message, please don't use obscure abbreviations without defining them.

 

I'm trying to decode what you are saying through all that chuckling to yourself.  It seems that your VI is building a lot of data into an array, but sometimes you get data that is zero, and you don't want that placed into the array, just ignored.  Is that correct?

 

What you need to do is use a shift register to store your 2-D array rather than auto-indexing it at the loop output tunnel.  Initialize it with an empty array.  If you get data you want to put into the array, then in the true case, build that new data onto the data in the shift register and pass it back into the shift register.  If you get the zero and that is the data you don't want to store, then pass the 2-D array wire through the False case so the array remains unchanged.

 

By the way, in your VI, you don't need to branch your 1-D array into 3 Index Array functions to get the elements.  You can feed the array into a single Index Array function, stretch the bottom of the function down until you get 3 elements.  With a single function, you will automatically get elements 0, 1, and 2 and you won't even have to wire constants to them.

 

Also, there is a greater than zero function already on the comparison palette.  That way you don't need to use a greater than and a separate 0.

Don't need to branch your i wire inside the loop and have it go through two different tunnels, you are just duplicating data.  Use 1 tunnel and branch the wire outside.

Don't clear your DAQ task on every iteration of the loop.  Just clear it when the VI ends.

Wire a control to your Stop terminal.   Having a False constant there means you are forced to Abort the VI to get it to end.

I don't know what your Not Sure VI is supposed to be.  I'm not sure why you are associating your HP instrument with a DAQ task.  They are two completely different entities.

 

Here is the VI with all these things changed.

 

 

Message 2 of 10
(3,139 Views)
Solution
Accepted by topic author jaswri

Here's a quick draft using simulated data. Modify as needed.

Message 3 of 10
(3,129 Views)

I was not aware that this forum was so serious.  That is fine though if it bothers people that I put "lol" I will stop.  First a "PEN" is not uncommon if you are fimliar with older legacy HP products.  The fact of greater than 0 was just to simplify it for the people reading. The PEN is actually triggered by a current greater than 150 mV, but to say that pulling greater than 0 for the VI gives the same effect. Like i stated in the VI I pull element values like that for my own personal error checking, I am aware you don't need to do that. Your suggestion is very accurate though, I was just trying to learn to other ways to manipulate arrays better.  The shift register is the easiest way to do it but I thought it should be able to be accomplished through other ways too. Thank you very much for you help though.

0 Kudos
Message 4 of 10
(3,117 Views)

The reason for the Daq on the HP instrument is so old that it has no digital communication, only BNC connections.  So the only way to read those is with a DAQ.  Remember please that this is one small subVI from a large Program.  Also because of reasons with the other subVI's I need to clear the DAQ after ever iteration, because of a timming issue, but I will look into changing that if you say it is not a good way to go.  You gave good answers but you seem to be kind of condisending to someone who is just trying to learn.

0 Kudos
Message 5 of 10
(3,116 Views)

Thank you very much to both Ravens Fan and Altenbach for their help and their personal time. 

 

Side note -- What I was hoping some one suggest is a way to do this not using shift registers.  I took the clad and am taking the cld soon and just wanted to expand some of my knowledge. 

0 Kudos
Message 6 of 10
(3,112 Views)

The forums aren't necessarily serious all the time, but they should be kept professional.  I just felt that the LOL's you were adding really distracted from trying to read and understand what you wanted to do.  Unclear messages really don't help you, or help us trying to help you.  I often read messages as if I was hearing the person talk to me right in front of me.  And if someone was trying to ask me an important question but kept laughing during the whole thing, it would be so distracting I'd want to smack them and walk away.Smiley Wink

 

I would consider shift registers to be the better way to go with most LabVIEW code constructions.  I don't think you should try to avoid them.  But I think the way to do what you are looking for is to go ahead and build the array with all the unwanted data in it.  Then when you are done, you could use functions like delete from array as you iterate through the searching each row and deleting it as necessary.  But even then you will need to use a shift register to maintain that array since you will be working on the array in a loop.  So no, I can't think of a way of doing this without shift registers.

Message 7 of 10
(3,106 Views)

@jaswri wrote:

Hi

 

I am a graduate student, lol and a novice programer. My school doesn't offer LabView so I have had to teach myself. I am taking several legacy HP analog instruments, to create a network analyzer, and using LabView to get a more user friendly "digital" version. I ran into a problem whlie retriving data from an HP 8750a storage normalizer with a DAQ.  What I need to do is pull a X & Y value while monitoring a PEN value to see if I should write, that is if Pen is greater than some value keep the data if not disregard it.  I am able to monitor the PEN, in VI it is Voltage 0, and over write the other data, Voltage 1 & 2, with 0's.  lol but this is not what i would ideally like to do.  I would like an end array of only elements when Voltage 0 is greater.  Can someone please point me in the right direction, lol i know this is kind of a stupid question.


I know you don't want to hear this but,....Perhaps you might want a second opinion of your methods and methodology.  I'm not aware of the abstract or goals for your experiment so try not to be too offended but if I read a paper presented with this " Several legacy HP analog instruments were hodge-podged together creating an effective network analyzer," I would stop right there!  So much of the data then becomes questionable for quantitative measure that the term "measurement" can't really be applied and at best you have some "observations" of limited interest scientifically. 

 

I urge you to have a frank discussion with your advisor about the methods and methodologies and how to improve tracability of data in this experiment.


"Should be" isn't "Is" -Jay
Message 8 of 10
(3,055 Views)

jaswri wrote:

Side note -- What I was hoping some one suggest is a way to do this not using shift registers.  I took the clad and am taking the cld soon and just wanted to expand some of my knowledge. 


The use of shift registers is correct here. Shift registers are one of the most efficient data structures in LabVIEW and mastering them is a key skill you will need.

 

The code could be made more efficient if you know from the start of the program exactly how big the final arrays will get, but I don't think this is possible in this case.

 

 

Message 9 of 10
(3,052 Views)

Ok thanks guys. I was just seeing if there were alternatives, to be explored. I agree that shift register is the best way to go.

Ravens-- that was the method I was going with, the delete element, I must have messed-up either the index or length control.

 

No this is not my master's project. They just wanted an additional Network analyzer but didn't want to pay $60k.  I am in nano studies, I just happen to be able to program in LabView.

 

0 Kudos
Message 10 of 10
(3,045 Views)