LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Specific 2d array method of iterating

Hey everyone,

 

I am stuck on getting an iteration that I want. So I upload the test text file onto labVIEW. And it will turn the pins on or off based on the text file (Status boolean array). Next, I get rid of that column. 

 

After this, I am lost on how to accomplish the iteration I want.

The iteration I want, specific to the text test file, starts at column 2, row 1.

 

I want to add code to the program, meaning I want this to occur after what my current code does. So the new code addition will:

1) wait 2 ms then turn status (index 0) off.

2) wait 3 ms then turn status (index 1) off.

3) wait 2 ms then turn status (index 2) on.

4) wait 4 ms then turn status (index 3) on.

Next, move on to column 4 (The next set of status - wait in the text file)

5) wait 4ms then turn status (index 0 on).

6) wait 3ms then turn status (index 1 on).

7) wait 2ms then turn status (index 3 off).

😎 wait 2ms then turn status (index 2 off).

And repeat if there are more sets of status-wait columns in the text file (In this case their aren't).

 

 

 

 

I am at lost on how to accomplish this, hopefully I have been clear

Download All
0 Kudos
Message 1 of 11
(4,703 Views)

This could be done nicely with a state machine in LabVIEW. You read the text file in, and insert the required steps into a queue. So I imagine you could use here a Queued state machine. Of course properly set-up, so you can pause/abort any time if necessary.

 

But! Before you would start to work on the above programming task, you should explain what is your goal with this? The problem here is that, you cannot accurately time your software running on Windows, you can expect up to several millisecond fluctuations.

You wrote about you want to do waits like 2 msec, 3 msec, etc... You cannot do this with pure software timing in Windows. However, you can use a proper hardware with built in clock to achieve what you need.

 

So what do you want to do with these msec waits?

0 Kudos
Message 2 of 11
(4,675 Views)

So I didn't read your instructions well, but it wasn't clear at first.  So this isn't a perfect solution.  Instead this will go through one row at a time turning on and off the pin in that row.  I should have probably used a state machine but it was simple enough not to.  Oh and I changed the time to seconds so it could be easier to see.  Is this intended on running on a Windows machine?  You will have way too much jitter to actually turn on and off hardware with software timing, at the timing requirements you have.

0 Kudos
Message 3 of 11
(4,668 Views)

Thank you for the tip on the state machine, and thank you for the example code I will take a look at it soon.

 

But yea, I wrote ms, but my intention was to multiply it by 1000 and do it in seconds instead. My goal is to upload a text file with information like I posted before, and it will then turn on/off some daq hardware that sends signals. I am using an array so I control different lines on the DAQ hardware, and I thought it would be the best way. 

 

I want the wait time (In seconds) just so I can watch the daq hardware turn on/off at certain times. And it is intended for a regular computer machine.

0 Kudos
Message 4 of 11
(4,653 Views)

Yes, then this will work. But use a proper state machine, otherwise you have no option to stop/abort/pause an ongoing operation in a sane way ("sane way" means you handle properly for example an abort procedure: you set your HW outputs to a initial state if necessary, etc...).

0 Kudos
Message 5 of 11
(4,645 Views)

Can someone give a good example of a state machine....I have never used one before.

0 Kudos
Message 6 of 11
(4,640 Views)

hmm, the best thing if you start some LabVIEW course. You need to learn quite a few aspects to be able to make a proper state machine, so I would recommend you to start with some learning, depending on your available access for resources:

 

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

 

And here are some actual state machine examples:

http://www.ni.com/tutorial/7595/en/

 

But if you google for it, and search the forum, you find vast amount of info regarding to state machines...

0 Kudos
Message 7 of 11
(4,630 Views)

State Machine


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(4,625 Views)

Is there any other way to do this then a state machine.....possibly an easier way?

I've been looking at state machines and cannot seem to figure out how to program it in this scenario

0 Kudos
Message 9 of 11
(4,561 Views)

State machine is easy. The simplest, scaleable architecture. I've seen really crappy developers go amazing places with a simple state machine.

Follow the links you were given above which are from the Rules and Guidelines page.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 10 of 11
(4,541 Views)