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. 

ExcelTest.txt

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.

post-7534-0-65626900-1437407393.jpg

  • 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.

 

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
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

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

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.

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.

  • Similar Content

    • 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
    • By mhsjx
      Hi,
      I'm a beginner in labview, and now test cRIO about two weeks. I still can not solve the problem. I attach my test project for explanation.
      I want to realize that , for example, with time sequence t1, t2, t3, t4,  DO outputs T, F, T, F, AO1 outputs A1, A2, A3, A4, AO2 outputs B1, B2, B3, B4, and the delay of AO1 and AO2 should as small as possible(AO1 and AO2 may comes from difference modules).
      I search in Google, NI forum, and decide to use for loop and loop timer in FPGA.
      The reason as follow:
      1. To realize the specific time interval, I can use Wait and Loop timer. But in "FPGA 0--Test DO.vi", it can't not realize specific time interval by several us's error(maybe large). And to complete once of while loop, it needs 134us. I can't explain that it can realize time interval below 134us, even I acturally realize a delay of 10us, but the input is not acturally 10us, so it's not accurate. 
      And by NI example, I use the Loop timer.
      2. In "FPGA 1--Test DO and AO.vi", I find that the loop timer helps me to realize accurate time interval, however, it ignore the first time interval. Such as, t1, t2, t3, t4, with disired output A1, A2, A3, A4. It goes A1(t2), A2(t3), A3(t4), A4(t1). And in "FPGA 2--Test DO and AO.vi", it has same problem. DO0 and AO1 goes A1(t2), A2(t3), A3(t4), A4(t1). And AO0 is always ahead of DO of t1. 
       
      The people of NI forum advice that I should put AO0 and AO1 into one FPGA/IO node and use SCTL. But up to now, I don't find any example about it(Google or NI forum, maybe it's primary).  Mainly that AO0 and AO1 must go with different timeline, the dimension of input array is different.  Can anyone offer advice for me?
      Thanks
      Test.7z
    • By kpaladiya
      I would like to build a model using image data and NI-cRIO-9063 and NI 9264 for voltage control.
      for image, I made a script in python using OpenCV libraries that detecting some points . For voltage control, I use cRIO-9063 with NI 9264 voltage controller.
      My question is, I am new in LabVIEW and I don't have any idea how can I make a loop for voltage control in python. Is there any library available in python that directly connect cRIO and NI 9264 devices? if not then how can I combine my image data(which is in python) with cRIO device? I need argent help.
    • By Makrem Amara
      Hi there,
      I am working on a machine vision project with LabVIEW.
      The camera will locate some parts and send their coordinates via TCP/IP 
      and I created a client also with LabVIEW to display these coordinates here is how the communication going.
      First, if the camera detects something then msg will be sent to the client to inform him.
      then if msg was received correctly client responds with another msg to request the coordinates. 
      at last, the server sends the coordinates to the client. 
      here I faced some problems
      1- the msg sent are with variable length ("x=0,y=0,Rz=0"==> "x=225,y=255,Rz=5" ==> "x=225,y=255,Rz=90"  length vary between 16 and 22 ) with the constant "byte to read " it will not display the full msg.
      2-the client works fine but at a certain time, it shows errors like ("LabVIEW: (Hex 0x80) Open connection limit exceeded";;;;;; "LabVIEW: (Hex 0x42) The network connection was closed by the peer. If you are using the Open VI Reference function on a remote VI Server connection, verify that the machine is allowed access by selecting Tools>>Options>>VI Server on the server side"
       
       





    • By drjdpowell
      I am just starting on trying to be able to use Python code from a LabVIEW application (mostly for some image analysis stuff).  This is for a large project where some programmers are more comfortable developing in Python than LabVIEW.  I have not done any Python before, and their seem to be a bewildering array of options; many IDE's, Libraries, and Python-LabVIEW connectors.  
      So I was wondering if people who have been using Python with LabVIEW can give their experiences and describe what set of technologies they use.
×
×
  • Create New...

Important Information

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