LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

race condition

i think i am having a race condition here that i cant seems to figure it out.
i used to have a stacked sequence. i take it out of the stacked sequence with the flat sequence. and i run wires across using bundle and unbundle.
STATS_DATA_MEAS_PARAM is a global.
it should only get the value AFTER meas_mod SUBVI is executed because meas_mod measure the temperature and store the data in STATS_DATA_MEAS_PARAM.
can someone please help me with this.
i tried creating subvi and things like that, but it didnt seems to work.
can someone sugguest a solution to my problem.
thank you
Best regards,
Krispiekream
0 Kudos
Message 1 of 36
(3,760 Views)

You do have a race condition.  The reading of the global variable is not dependent on anything, so it could happen right away even before the subVI that would be puts a value in that global variable executes.

You would need at least 1 frame of a sequence structure where a wire coming out of the sub VI passes through the frame that the global read occurs.  If you take your picture and turn the oval you true into a frame, and pass one of the pink wires nearby through the frame (since those are dependent on the completion of the subVI), it will do what you want.



Message Edited by Ravens Fan on 07-24-2008 05:44 PM
Message 2 of 36
(3,752 Views)
so that would be the only way to do it?
i didnt want to use frame because i dont like the way it look inside my diagram. but if that is the only way. i guess i can live with it.
thanks!



Message Edited by krispiekream on 07-24-2008 05:22 PM
Best regards,
Krispiekream
0 Kudos
Message 3 of 36
(3,742 Views)

That's the only way I know of.  I don't think a single frame sequence in this case looks bad.

One other way to do it is if you were using a shared variable rather than a global variable.  Shared variables have an error in and error out on their block diagram icon that would allow you to use the error cluster through it to enforce data flow.  However you need LV 8.0 or above to use them.  I don't remember which version of LV you are using from your other posts.  And I can't remember which version of LabVIEW had the error cluster going from a pink wire to the yellow/gold/green wire.

Message 4 of 36
(3,711 Views)


krispiekream wrote:
so that would be the only way to do it?

All you need is a tiny frame containing the two global variables and then wire the output wire of the MeasMod subVI to its border.
  • I think you have overlapping wires between the measMod subVI and the bundle by name following it. Looks messy.
  • The comparison palette contains a primitive to check for "empty string/path?". No need for the equal and the empty path constant.
  • I am not sure why you place the error cluster in the bundle, since you need to unbundle/bundle it everywhere. Why not keep it seperate?
  • The backporch indicator gets written immediately at the program start. Maybe that's OK.
  • Instead of the concatenations of all these six strings, you could use a simple format into string with two DBL inputs and a format specifier that contains all the strings and delimiters.
  • Your VI shows one of the reasons why error clusters are now olive green in newer versions of LabVIEW. 😉 It is very confusing to have both in pink.
Message 5 of 36
(3,706 Views)
When you set the 'mean' value in meas mod, you can just wire it (or all Stat_data_meas_para) via the connector pane to the top level vi. No need for global at all in this part of your project.

Felix
Message 6 of 36
(3,689 Views)
felix,
i think i understand what you mean. but for some reason i tried doing it that way. i dont get the same value.
here is what i have done.
i'll attach some pictures of what i have done. hopefully it is easy to see what i did.

in the first picture. i created an indicator for my STATS_DATA and connect the indicator to the MEAS_Mod subvi to the top corner pane. i run the wire out. then i ran the program.

when the meas_mod is measuring the temperature. the GLOBAL variable is readding 36.83 degree, yet the indicator didn't. it is still not reading anything. so when the value goes out of the meas_mod subvi. it is 0, but it should be reading 36.83
i dont understand that. why is it that it can write to the global but not the indicator i created?

Best regards,
Krispiekream
Download All
0 Kudos
Message 7 of 36
(3,638 Views)

altenbach wrote:
All you need is a tiny frame containing the two global variables and then wire the output wire of the MeasMod subVI to its border.
  • I think you have overlapping wires between the measMod subVI and the bundle by name following it. Looks messy.
  • The comparison palette contains a primitive to check for "empty string/path?". No need for the equal and the empty path constant.
  • I am not sure why you place the error cluster in the bundle, since you need to unbundle/bundle it everywhere. Why not keep it seperate?
  • The backporch indicator gets written immediately at the program start. Maybe that's OK.
  • Instead of the concatenations of all these six strings, you could use a simple format into string with two DBL inputs and a format specifier that contains all the strings and delimiters.
  • Your VI shows one of the reasons why error clusters are now olive green in newer versions of LabVIEW. It is very confusing to have both in pink.


  • yeah, i did overlap the wires between the subvi because it thought it would look cleaner in the program.
  • i dont think i understand what you mean by this "The comparison palette contains a primitive to check for "empty string/path?". No need for the equal and the empty path constant."
  • oh yeah. about the error cluster. that is one of my question too. i dont want to be doing that all the time. it gets boring and waste alot of time, but the reason why i did that because i want to run my wire, left to right. And i dont want it to face race condition, therefore i  run everything left to right. if it is coming error out, then i would bundle it, and then unbundle it when i face another subvi to let the data flow? can you sugguest a solution for me? i really dont like doing it that way. 
  • also, can you show me what you mean by this "Instead of the concatenations of all these six strings, you could use a simple format into string with two DBL inputs and a format specifier that contains all the strings and delimiters.
  • also, i am using labview 7.0


Best regards,
Krispiekream
0 Kudos
Message 8 of 36
(3,636 Views)


krispiekream wrote:
  • i dont think i understand what you mean by this "The comparison palette contains a primitive to check for "empty string/path?". No need for the equal and the empty path constant."
  • also, can you show me what you mean by this "Instead of the concatenations of all these six strings, you could use a simple format into string with two DBL inputs and a format specifier that contains all the strings and delimiters.
  • Well, maybe this was not available in 7.0, but check your palette again (See top of image).
  • The code at the bottom of the image replaces all your formatting (3 string diagram constants, 2 fractional string conversions, 2 integer diagram constants, and the concatenate string operation).

Always pick the alternative with less code. 😄



EDIT:  Of course the label should say: "format string in \-codes display, note the carriage return at the end."  

Message Edited by altenbach on 07-25-2008 11:09 AM
Message 9 of 36
(3,622 Views)
wow, you are the best. its alot better than what i had.

Best regards,
Krispiekream
0 Kudos
Message 10 of 36
(3,603 Views)