03-31-2015 04:06 PM - edited 03-31-2015 04:07 PM
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.
03-31-2015 04:12 PM - edited 03-31-2015 04:16 PM
03-31-2015 05:06 PM - edited 03-31-2015 05:08 PM
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.
04-02-2015 02:29 PM
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.
04-02-2015 02:56 PM
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.
04-02-2015 03:40 PM - edited 04-02-2015 03:44 PM
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.
04-02-2015 03:58 PM
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)
04-02-2015 04:08 PM
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.
04-02-2015 04:10 PM
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.
04-02-2015 04:22 PM - edited 04-02-2015 04:24 PM
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.