LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help figuring out mistake in true/false strings

You're still missing the point about local variables.

 

You should not have the construct where you are assigning the value of a local variable to an indicator.

The logical wire from the data operation should determine the value put on the indicator.

 

 

0 Kudos
Message 11 of 20
(1,195 Views)
  • You still have race a huge amount of race conditions
  • Why do you have pairs of controls with the same name, that can be very confusing, especially if you use local variables (e.g. "Mixer3"). If you want a digital display for a tank, just "right-click...visible items...digital display" and delete the seperate indicator. Now there is only one terminal.
  • Why do you read from a control and from local variables of the same control literally dozends ot times in parallel. Just read from the terminal and branch the wire. No local variables needed. In fact, all you need is building the five booleans into an array and use boolean array to number. Wire the number to a case structure and make a case for each needed bit pattern. Suddenly, the diagram is only 5% of the original size! 😄
0 Kudos
Message 12 of 20
(1,190 Views)

Can you tell me where i have any Race conditions ? apart from inside the case i should only be wrighting any variable once, and from inside the case it should only write once per case.

Also i will look into a boolean array when i get some time.

Please understand although i do want this to be a functional system, it also has to be visualy understanding, As it is right now the numbers on the Front Panel update in sequence (like a flow) this is important to the diagram, i do not want to loose that.

 

As for the control names i am trying to keep the maths and the display as seperate as i can, the "Mixer" numbers are going to be moved to the global veriables panel once i have this first line finished, at which point i will enable the display on the tanks. To clarify the only numbers on the front panel will be the tank amounts. 

 

As for the last bit of information, This system is going to be updated vai a external system as part of my work. The delay between recieveing 1 set of data to the next could be around 60 seconds. i need the delay in the numbers being updated to allow for that timeframe to pass before checking them again.

(T3S1 update ... 60 seconds ... T3S2 updates ... 60 seconds... T3S3 updates ....)

 

Also i do really appreciate everyones feedback.

0 Kudos
Message 13 of 20
(1,178 Views)

Ok again redone a bit of the code. Put the case select inside a case(logic). Havnt done the actual main case select yet to clear up those race conditions.

 

Is there a way to delay an update ? so i can delay an input by 145ms but have the delay to store the number for that time ?

I really do want to keep the updates as a flow which is why i left the race conditions in there but if its not correct to do that i would like to know the best way of sorting it out.

Download All
0 Kudos
Message 14 of 20
(1,151 Views)

Let's back this up a bit.

What logic are you actually trying to produce?

The whole mechanism is a bit convoluted so maybe it's best to go back to the beginning.

 

You're polling a control panel at 250 ms and dumping data into Global variables.

You're then polling all of the globals at 250ms and doing math and logic on those globals in your front panel.vi.

You're also spinning a high rate parallel loop to poll your global i at 10 ms and do other math on your front panel valves.

 

Your control panel should be the only writer to your global variables. Your front panel.vi should not be doing any global variable writes.

If your front panel.vi needs to incorporate sequencing, you may need to look at using a state machine and think about how global variable changes should cause state transitions.

 

 

0 Kudos
Message 15 of 20
(1,144 Views)

Also, use shift registers for your tank values and use altenbach's suggestion of getting rid of your duplicate indicators for values which are really just digital displays of your tank values.

 

EDIT: a few more things. Fix your numeric representation for i and for T3 Case Select. You want integers, not floats. Similarly on your assignments. If you're setting MS5V1 Flow to a float, use a float instead of an integer. Coercion dots are easy to fix.

0 Kudos
Message 16 of 20
(1,129 Views)
Spoiler
 

ok im trying to produce a simulation of flowign liquids inside a pipe, the numbers on the pipe have to update in sequence to simulate a flow.

aso for running the bottom loop at 10ms thats simple maths, top loop runst at 250 with 25 possible cases (250/25=10) meaning it will detect a change on each cycle of the top loop.

I was (and still am) going to link the case(global Variable) directly to the case select input. at the time i just wanted to see it running in case of any problems (which there was when i was running the second loop at 175ms). 

 

what i want to know right now is if there is a way to code a delay between 2 nodes. e.g.

 

a= 25

delay(245) = 25

after delay(245) b = 25

 

the reason i want it to delay by 245 is so it can send the previous number 5ms before it recieves a new one. there would be a total of 5 delays on this system

145 - T3S1, +145 M1Valve Flow and T3S2 + 145 M2ValveFlow and T3S3 (etc..)

 

Ok to make this easier i think i just may have figured out the solution by accident but here is a screenshot of what i wanted to do. (and for some reason it works as well) Is this the correct solution to remove race conditions from my front panel case select (top loop) ? (set to 500 for testing purposes)

Screenshot_8.png

0 Kudos
Message 17 of 20
(1,119 Views)

LabVIEW does not have variables, it has wires instead.  So called Local Variables ARE NOT VARIABLES, they are actually references to front panel controls and indicators.  Do not use controls and indicators to store data, that's what the wires are for.

 

Global variables can be used to store data but should be used sparingly.  Shift registers may be a better fit.

 

You really neecd to learn about LabVIEW best practices before proceding.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 18 of 20
(1,113 Views)

That "some reason" is called dataflow.

 

You should be able to pick that up from the tutorials.

 

If you go that route, you should realize that you don't need your 250 ms wait anymore and your effective loop time is now going to be 500 ms times the number of flat sequence structures you have introduced.

 

I started illustrating the use of shift registers for the InTank1 in the attachment.

Message 19 of 20
(1,108 Views)

Thanks very much. i can now see a better way of setting out this project.

Appreciate all this help 🙂

 

and when i said for some reasont it worked, that was because i didnt actually think it would work like that, it was just to display an example of what i wanted.

0 Kudos
Message 20 of 20
(1,102 Views)