Jump to content

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. 


Text Boolean.vi

Edited by pkeny
Link to comment

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.


  • Like 2
Link to comment

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?

Link to comment

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.

Link to comment

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
Link to comment

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
Link to comment

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.





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


Edited by pkeny
Link to comment

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
Link to comment



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.




text test.txt

Link to comment

Join the conversation

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

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.

  • Similar Content

    • By Guru Prasath
      Hello Everyone;
      How I plot the timestamp in the graph of the x-axis and numerical slider the timestamp given in 2d array.

      The array in 2d array of string...

      I will try this but it not plotting full timestamp can you help me to short of this problem.

      It will be a plot, but a few timestamps will plotting 
      How I plot full timestamp and date...
      I have attached my problems like the jpg file and .vi file for your reference.

      Does anyone have solution comments below...
      Thanks and Best regards...

    • By torekp
      I was trying a python http communication tutorial - https://aiohttp-demos.readthedocs.io/en/latest/tutorial.html#views - when I had to disable the NI Application Web Server to proceed.  And then I thought, what the **** am I doing?  Maybe I should take the free (well, prepaid) gift of a working web server.
      Here's my task.  A central HQ computer will have a GUI that monitors five machine stations, each of which has its own computer.  Every approx 10 ms (negotiable), each station gives a report consisting of two arrays, the larger being 2048 data points, the other much smaller.  Whenever HQ feels like it, HQ can tell a station to start or stop (its computer stays on).  A local IP connection is used, with a router at each end.  There is also a Raspberry Pi with its own IP address at each station's router, that can send camera frames to HQ.  The station-computers use Python and C++ to do their work, not counting whatever needs to be added to communicate with HQ.
      Your advice please?  Should I use Labview?  On both ends or just the HQ?  And which if any of these helpful add-ons suggested by Hooovahh should I use?
    • By AndyS
      I have to convert a dynamically generated array into a JSON string and back. Unfortunately I found that the un-flatten method loses the variant data. See the screenshot of FP and BD and the comments inside.

      Is this a bug in JSON Text or is my data-construction not supported as expected? In case of the letter I have modify huge parts of my code. So I hope that it is a bug 😉
      The 2nd thing I recognized is that the name "Value" of the cluster is not used during flatten. Instead the name of the connected constant / control / line is used. I found the green VI ("Set Data Name__ogtk.vi") at OpenG Toolkit that allows me to programmatically set the variant data name. As you can imagine I would prefer not to need the OpenG VI.
      Thanks in advance for your kind help 🙂
    • By kartik.azista
      HAs anyone tried creating a sub vi programmatically by selecting the set of blocks through scripting?????
    • By TDF
      TDF team is proud to propose for free download the scikit-learn library adapted for LabVIEW in open source.
      LabVIEW developer can now use our library for free as simple and efficient tools for predictive data analysis, accessible to everybody, and reusable in various contexts.
      It features various classification, regression and clustering algorithms including support vector machines, random forests, gradient boosting, k-means and DBSCAN, and is designed to interoperate with the Python numerical and scientific libraries NumPy and SciPy from the famous scikit-learn Python library. 
      Coming soon, our team is working on the « HAIBAL Project », deep learning library written in native LabVIEW, full compatible CUDA and NI FPGA.
      But why deprive ourselves of the power of ALL the FPGA boards ? No reason, that's why we are working on our own compilator to make HAIBAL full compatible with all Xilinx and Intel Altera FPGA boards.
      HAIBAL will propose more than 100 different layers, 22 initialisators, 15 activation type, 7 optimizors, 17 looses.
      As we like AI Facebook and Google products, we will of course make HAIBAL natively full compatible with PyTorch and Keras.
      Sources are available now on our GitHub for free : https://www.technologies-france.com/?page_id=487
  • Create New...

Important Information

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