Jump to content
pkeny

Boolean array Variable

Recommended Posts

Hey all,

 

I am trying to create a fairly large program.

 

What I want to do is for someone to upload a text file, customized so I can create statements for it, and then labVIEW will read the the text file and perform actions.

 

Specifically, the text will contain pin numbers, on/off status, wait delay, and another on/off status. The pin numbers correspond to a Boolean indicator array. The on/off status tell the Boolean indicator array to turn on/off. The wait delay tells the program to wait how long before changing the indicator array value again, and the second on/off status turns the Boolean array on/off after the wait delay.

 

I cannot get the part where I want the Boolean array to change status after the wait delay. I am thinking the method of doing this would be a local variable, or a property value node. But, when I tried it, it would not even let the original status to turn on/off the indicator Boolean array, let alone changing the status after the wait delay.

 

I have attached my code and text file (tab delimited) for another method of explanation.

Altenbach wrote a big portion of the code for educational purposes

 

If you delete the local variable, you will notice that the boolean array changes based on the first text column, versus it being constantly Gray if you have the local variable. 

ExcelTest.txt

Text Boolean.vi

Edited by pkeny

Share this post


Link to post
Share on other sites

Why are you initializing an array in your For loop?  You want to replace elements; here's a very quick way to accomplish that:

 

Also, you don't need to use (ever) the Stop command; just put all of your logic in the other case.

post-7534-0-65626900-1437407393.jpg

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for that,

 

Also, I am just using the stop command for now as a placebo to remind me to fill in that section later.

 

Now, I have another question, how can I accomplish my task programmably versus me hardcoding it in. For an example, currently on the text document one can have a maximum of one delay, so labVIEW will go through pins status once, then delay, then go through the pins status again. However, can someone help me with the logic to create a way to do that programmably so instead I can go through the pins status 100 times with a delay in between?

Share this post


Link to post
Share on other sites

I'm not clear on your intent.  I think you'd be better off setting all of the pins and a delay in each row.  If you don't want a delay, just set it to zero.

 

 

post-7534-0-56381700-1437481270.png

ExcelTest2.txt

Share this post


Link to post
Share on other sites

If you want something complex, you need to write a complex program which parses each line of your spreadsheet file, and and controls all the possible execution options accordingly, there is no escape from that. For example do you want to write pin-status-wait-status-wait-status-wait... or pin-status-wait-iterations... Maybe you should start there, defining what is to be expected on a line, and what is intended to happen; then you can think at possible implementations which satisfy your constraints.

I don't even understand, should the lines of your file be executed sequentially or simultaneously? The examples above assume sequentiality; I previously deleted a reply of mine in which I was answering you understanding simultaneous start of all pin cycles, then thought that perhaps it was not the case.

Share this post


Link to post
Share on other sites

It looks like you can operate sequentially from your examples so another method s to use a simple scripting language.

This assumes also that the file format is negotiable or can be translated but results in much more flexible and easier to maintain and understand  code..

SR ExcelTest.zip

Edited by ShaunR

Share this post


Link to post
Share on other sites

I apologize if I have not been clear.

 

I do not want something complex, but I understand that I might need to have something complex.

 

Anyways, it really does not matter whether I have it sequentially, or simultaneously, but since I already have it so the delay happens sequentially it is okay for such.

 

So, what I want is:

 

1. Pin > 2. Status > 3, Wait > 4. Iterate through step 2 and step 3 until no more columns left in text file.

 

So, for step 4, the iteration should look like: Status>Wait>Status>Wait>status>wait>status>wait>status>end.

 

The method I think to make something like that is a for loop with shift registers, however, I cannot wrap my head around for loops and shift registers in labVIEW for some reason. I will try something later in the afternoon and post it here. Maybe from there I can get some more help.  Actually, just explaining it so I have a clear vision in my head helps out.

 

Hopefully I have been clear.

 

I really appreciate all the help.

Thank you

Edited by pkeny

Share this post


Link to post
Share on other sites

Would this do, then? The assumption is that the first column of the line is the pin number, then further columns can only be ON, OFF, a waiting time in ms or empty to end the sequence.

 

post-28229-0-46155400-1437490223.png

post-28229-0-36519000-1437490230.png

post-28229-0-28020200-1437490238.png

  • Like 1

Share this post


Link to post
Share on other sites

Would this do, then? The assumption is that the first column of the line is the pin number, then further columns can only be ON, OFF, a waiting time in ms or empty to end the sequence.

 

attachicon.gifpin1.png

attachicon.gifpin2.png

attachicon.gifpin3.png

Very good and efficient code. Close to what I want. Your code reads it row by row. I want to read it column by column.

 

So, using my attached text file as an example, your code will go row by row. So, it will first turn on pin 0, then wait 1ms then turn it off then wait 1ms and then turn it on, and then turn pin 1 on...and so on...

 

What I want is for it to read column by column. So what I want is that it will first perform:  pin 0 on, pin 1 on, pin 2 off, pin 3 on....to pin 10....

 

and then it will wait 1 ms and turn pin 0 off, wait 1 ms turn pin 1 off, wait 1 ms turn pin 2 on....all the way to pin 10,

 

Then wait 1 ms turn pin 0 on, wait 1 ms turn pin 1 on, wait 1 ms turn pin 2 on....all the way to pin 10 and then stop.

 

So, in general, I want it to read the whole second column (status) first, and then read the next two columns, row by row: wait, status, (next line), wait, status, (next line)...until pin 10, and then go on to the next set two columns: wait, status, (next line), wait, status....etc.

 

I know this is quite confusing and obscure haha.

 

So, I have uploaded an excel file with an example, with the order of operation. I think that will really clarify everything and explains everything.

text test.txt

Book1.xls

Edited by pkeny

Share this post


Link to post
Share on other sites

Your code reads it row by row. I want to read it column by column.

 

ensegre has given you a good starting point. Would you like to try modifying his code to match what you want?

Edited by JKSH

Share this post


Link to post
Share on other sites

Hello,

 

I have made an attempt to get this.

 

Based on my text file, column 0 is pin number, column 4 is status.

 

I have it so column 1 (status) is working.

 

The next parts are not, which is an iteration. I tried to do this in the while loop, but I cannot seem to figure it out. Anyways, what I want in the while loop is, based on my text file is:

 

(Start at column 2)

1)Wait 2 seconds, turn boolean array index 0 off

2)wait 3 seconds, turn boolean array index 1 off.

3)wait 2 seconds, turn boolean array index 2 on.

4) wait 4 seconds, turn boolean array index 3 on.

 

 

5)wait 4 seconds, turn boolean array index 0 on.

6) wait 3 seconds, turn boolean array index 1 on.

7)Wait 2 seconds, turn boolean array index 2 off.

8) Wait 2 seconds, turn boolean array index 3 off.

9) repeat steps 1-8 if there are more columns...in this case there aren't.

 

 

post-53751-0-35829900-1437786948.png

text test.txt

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.