Hi,
I have a synchronization issue using while loops in parallel.
Anyway,I have two while loops:
1) this loop reads a TTL pulse via a DIO card, and alternates the properties of a slider bar (label, min, max values, and resets the value to 0) between two states (#1 and #2).
2) reads from a VISA serial port, and saves info to a file everytime it reads a new data point. The info consists of the VISA data, and the slider value, and the state of the slider (#1 and #2).
Ok, when looking at my output file. I see inconsistencies: impossible values of the slider bar for either state. This means that while writing to file, the program thought it was still in state #1, but the slider had already been reset to zero and gone to state #2.
My theory:
The way i implemented it is that the state (#1 or #2) is indicated by a boolean indicator on the front panel. It switches whenever it sees a TTL pulse. But the second loop might see a change in the slider value (resetting to zero) but hasn't recorded the Boolean change (both values read via local variables). Hence the inconsistency.
I believe this is due to the slow nature of the front panel on my computer... there seems to be a lag whenever i press a button or open a dialog window.
My Question:
Is there a way to use local variables without displaying their value on the front panel. That is, i want a boolean variable which loop 1 writes to and loop 2 reads from, but have them update instantly... while keeping the loops independent, so that they both acquire data as fast as possible. Hardwiring would be the best, but I can't seem to have two while loops running in parallel while hard wired (they then insist on becoming sequential)
Alternatively:
Is there a Shift-Register-Like function which allows to while loops to be connected directly, but still run independently? In other words, what the best way to implement this scenario:
Loop 2 uses a value generated by loop 1, which is spat out constantly. Both loops would run independently, so loop 2 would use the last updated value by loop 1 for each new iteration... .and wouldn't worry about reusing values (if loop 1 is slower) or missing any values given to him by loop 1 (if loop 1 is faster).