LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flat sequence structure with While Loop

Obviously, you completely misunderstood the suggestion of replacing the sequence structure with a FOR loop. You actually made it worse! All you need is a single FOR loop, autoindexing on arrays of delays and values.

 

Nobody here has the patience to troubleshoot a gigantic diagram full of race conditions. Can you reduce the problem to a simple small program that still shows the problem?

Message 11 of 21
(1,738 Views)

Here it is sir, 

 

It is the previous version of the program and I made it smaller.

 

Thank you

0 Kudos
Message 12 of 21
(1,736 Views)

This is still not sane code!

 

  • You start out with a greedy loop.
  • In the upper parts you have many loops inside a loop and if you stop any of the inner loops, it cannot be restarted until all other loops have completed too. To stop that loop pyramid, All stop buttons need to be operated. No user wants to do that!
  • The lower case structure is on the toplevel diagram, meaning it runs once immediately at the start of the program with whatever the controls contain and then never again.

 

Since the code makes no sense, It would be better to explain what the program is supposed to do. How is it operated and what do you expect to happen as a function of changing any of the controls at runtime?

 

0 Kudos
Message 13 of 21
(1,732 Views)

Another tip would be to not do everything at once.  Limit it to 2 or 3 of those things, and perhaps 2 or 3 of those steps.  Once you get it working on a smaller scale, it will be easier to scale it up to more steps and more things by taking advantage of For Loops and Arrays?

 

Here are some tutorials

LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 14 of 21
(1,728 Views)

Hi sir,

 

The program is connected a board controlled with Atmega2560 chip which is the same chip that Arduino Mega uses. It is designed for the Selenoid Valve Body test machine. Here is a video shows one of the most popular software in this field: https://www.youtube.com/watch?v=Zfxm-ZvveQs

 

I deleted all the stop buttons and collect the program only in 1 while loop, attached it. 

 

The main software works like this;

1 digital button only gives high value,

1 digital button only gives low value,

1 PWM button controlled by arrowed buttons in the frontend side of the VI,

Duty Cycle value sets the up and down buttons to work,

And I am trying to make a test program that will run some of the pwm's in a set time with a value like in the time sequence step by step. That's all for now. The next step is saving the Analog read values from a pin in a tdms file. But it is the next step.

The main software works and I can control the Duty cycle with buttons, I can read the current value with the sensor. The program works pretty fine. The only thing I could not do that is running test steps. 

 

Best,

0 Kudos
Message 15 of 21
(1,727 Views)

Your flat sequence structure is set to run after your main while loop runs.  Is that what you want?

The main while loop just plays around with reading buttons and then changing the % duty cycle on those indicators.

Your Arduino writes are being based off of local variables.  You should be using wires!

But only after you hit stop, does the flat sequence run, updating those indicators.  But that is a visual display.  The code that writes data to the Arduino no longer executes again.

 

You need to step away from LabVIEW, grab a pencil and paper, and write down in a flowchart format what you are trying to do.  Right now your code represents a disorganized thought process.

 

 

0 Kudos
Message 16 of 21
(1,723 Views)

Yes sir,

 

This is the exact problem that I cannot solve. How to orginize them. I swear that I read a lot and watched a lot. But, no solution. I want to stop the while loop till the test end. But in that case the connection goes. While the test is not running, I want to use the arrowed buttons to control the duty cycle. But when I press the Test button, I want all the arrowed buttons to stop and only the test will be running.

 

I am now not sure how to organize it. This is not the first time that I am using LabVIEW with an Arduino board. But it is the most complicated one. I tried many ways and also used it with the example codes that come from Linx etc.  Again, no solution. That's why I do want help, and I do need help 😞

0 Kudos
Message 17 of 21
(1,719 Views)

Two loops.  Producer/consumer.

 

Producer loop contains an event structure that handles the buttons.

Consumer loop contains the code to interface with Arduino.

There is a queue that passes commands and data from Producer to Consumer.

When you start the program, there it is in a mode that is your setup mode.  (Keep track of it with a boolean in a shift register).  When you press the buttons, in the respective event cases, it sends the command and data to the consumer loop that writes them to the arduino.

When you press the test button, it sends the sequence data to the consumer loop.  It then changes the boolean to the opposite value.  (I would do true for initial case and false for the "test" mode.  If you happen to press an arrow button after that, the event case will execute, but because the boolean is false, it won't send a command.

0 Kudos
Message 18 of 21
(1,702 Views)

Exactly, 

 

But I am not sure how to solve the problem. I attached the simpler version of the program. Still no response, communication lost after running the test.

 

Best,

0 Kudos
Message 19 of 21
(1,693 Views)

Did you google "Producer Consumer"?

 

Or go to File >> New...

Producer/Consumer  Events

Capture

 

The one where you had separate loops was more correct, but you can't have one loop dependent on the other with wires between them.  You should google "Dataflow" as well.

 

Message 20 of 21
(1,683 Views)