LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic string array



@Radiance_Jon wrote:
PS - where in the heck are error in and error out?!?!  I can't find them in the functions palette



They're on the controls palette, which is on the front panel.  Specifically in Modern>>Array, Matrix & Cluster.  When placed on the front panel, there will be a corresponding error in and out placed on the block diagram.

Trey B
Applications Engineering
National Instruments
Message 11 of 20
(3,655 Views)
For some strange reason I did not see reply#7, but I saw reply#8, to which I responsed. Very strange. I did not intend to ignore this question.

To respond to the question: Yes, you would need separate format strings, but you're sending different strings based on which channel it is anyway, and I didn't see your code (what I could see of it) handling the other commands. My only point regarding the Format Into String is that it's just a little cleaner than doing a number to string conversion and then a string replacement. The Format Into String accomplishes this in one step.

For example, by looking at the strings you're trying to send I see that the following strings are common for each channel:
: PULSEn: STATE 1
: PULSEn: SYNC T0
: PULSEn: CMODE mode
: PULSEn: WIDTH width
: PULSEn: DELAY delay

You can accomplish this with a Format Into String by using the method I show in the attached VI. A similar method can be used for the WCOUNTER, PCOUNTER, and BCOUNTER commands. I'm not telling you that you have to do it this way. I'm only suggesting it as an alternative. Choose whichever method is more comfortable for you and that you believe will allow you the flexibility you think you will need in the future.

Message 12 of 20
(3,644 Views)
Okay, here it is, the solution I'm going with is below.  The first set of strings initializes the device, while the case structure holds all the strings to initialize the channels.

Now, onto the dynamic channel parameters!!!


0 Kudos
Message 13 of 20
(3,629 Views)
You need to correct your loop tunnels:
  • You do not want to autoindex the VISA Resource Names at the output of the first loop and at the inputs of the other loop. Disable auto-indexing for that wire.
  • You need to replace the auto-indexing for the error cluster with a shift register for both the left and the right loops. Right-click on the tunnel and select "Replace with Shift Register".
  • You need to replace the tunnel for the error in the loop inside the case structure with a shift register.
Also, there's an "Increment" primitive.

Message Edited by smercurio_fc on 07-19-2007 12:10 PM

Message 14 of 20
(3,607 Views)
I'm not totally sure what you meant by the primitive incrementer.  I found the error with the VISA resource name by chance.  I used a similar loop later on and could not figure out for the life of me why it was only running 7 times instead of eight.  Near as I can figure the VISA resource name was always auto-indexing, and I guess at an earlier stage there were only 6 elements, so future loops based their auto-indexing off of this instead of the arrays I was trying to index them off of.  I removed auto-indexing on the errors too... why do they need "shift-registerized?"  How exactly does NI handle that?  Each time it shifts how does it store the data differently than if I had left it auto-indexing.  I thought auto-indexing was essentially creating an array of any and all errors - what does the shift register do?

Thanks so much for all your help!  The project is coming along extremely well!
0 Kudos
Message 15 of 20
(3,599 Views)

Primitive basically means the smallest form of a VI, (i.e. a simple function).  Addition is a primitive as you can't open it up and look into.  Right below addition on the Numeric pallete (at least on my screen) on the block diagram is a "+1".   It does in a single node, what adding a constant 1 with an addition node does.

There are basically 3 types of ways to pass data into and out of loops.

Normal tunnel (a colored block),  uses the same value at the beginning of each iteration even if that wire gets the data changed on it.  The value at the end of the last iteration gets passed out.

Shift register (an downwards and upwards triangle which are paired up one each side.)  This feeds the the value at the end of the last iteration to the beginning of the next iteration.  (Similar to feedback nodes, but many people, including me, feel the shift register is easier to read)

Auto indexing tunnel. (square brackets [ ]  ) Feed into an array, each iteration of the loop uses the next element of the array.  The number of elements determines how many times the loop runs.  When you autoindex going out of the loop, an array is built based on the number of times the loop is run.

The reason you don't want to autoindex the I/O reference or the error clusters is that you don't want to build arrays of them, but just pass the value back into the next iteration of the loop.

Message Edited by Ravens Fan on 07-19-2007 11:29 PM

Message 16 of 20
(3,607 Views)


@Radiance_Jon wrote:
I'm not totally sure what you meant by the primitive incrementer.  I found the error with the VISA resource name by chance.  I used a similar loop later on and could not figure out for the life of me why it was only running 7 times instead of eight.  Near as I can figure the VISA resource name was always auto-indexing, and I guess at an earlier stage there were only 6 elements, so future loops based their auto-indexing off of this instead of the arrays I was trying to index them off of. 


When auto indexing multiple arrays, or having a value fed into the N node of a for loop, the loop only runs the number times based on the smallest value of N and the number of elements in the smallest array.  If you had a 3 element array, but a value of N=4, the 4th element of the array is undefined, thus what would it use?  It only ran 6 times because there was an array of 6 elements of VISA references built up in the first loop.
Message 17 of 20
(3,589 Views)
Thanks to smercurio_fc and Ravens Fan for all the help and very useful information on LabVIEW.  I've been away a while and just got a chance to read some of your replies.  The project is coming along smoothly and I am actually about to wrap it up.  This post has evolved into a multiple question topic... I don't know if I should post the next two here or elsewhere.  Since one is along the lines of the current discussion I will post here.  The other I will start a new topic for. 

smercurio_fc said:

You need to replace the auto-indexing for the error cluster with a shift register for both the left and the right loops.


Why do it this way?  Why do it differently from the VISA Resource Name?  Why not do both as a shift register?  And lastly, if I use a shift register, can I simply connect the "output" side of the shift register to the next link in the chain (e.g. the next loop using VISA Write/Read)?  Currently I have simply disabled the auto-indexing, so I guess any errors that would come up would get over-written each time.

Message Edited by Radiance_Jon on 07-26-2007 09:09 AM

0 Kudos
Message 18 of 20
(3,545 Views)

You can setup both the VISA resource and and the error wire with a shift register.  The key thing for the VISA resource is that it is NOT an autoindexing tunnel that generates an array.  For the VISA resource name, it won't matter whether it is a normal tunnel or a shift register and should behave the same.  That's because the VISA resource name wouldn't be getting changed from one iteration to the next that would require it to be fed back in at the beginning of the loop.

Yes you can wire the "output" side of the shift register to the next VI in line.

With a normal tunnel and no autoindexing on the error register, the error would get overwritten on each loop.  With a shift register, the error would get carried back to the beginning of the next loop iteration.

Message 19 of 20
(3,530 Views)
Thanks!  I think I fully understand tunnels, shift reg.s, and auto-indexing.
0 Kudos
Message 20 of 20
(3,520 Views)