LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating a read/write field

Hello,

Simple question.  LV has controls and indicators...but I need a field that does both.

 

I am writing a value to a register (writing the value should clear a certain bit within the register), so I want the field that I write to, to immediately update with what it reads back.

 

In other words, I need a field on the front panel that I can both write to (a control) and then read into (an indicator).

 

I see LV has shared variables but I'm not sure if this is what I need or if there's a simpler solution.  Can someone point me in the right direction?

 

many thanks

0 Kudos
Message 1 of 8
(2,645 Views)

Here is a suggestion.

 

Make the field a control.  Use it to write to the register.  Read the register back, but wire the output to a property node created from the control (right click in the block diagram and select create property node _> value).  Then change the property to Write.

 

The value you read back from the register will be displayed in the same control which sent the initial value.

 

Dual purpose control 🙂

Message 2 of 8
(2,644 Views)

Looks like it works...to emulate my register system I just made 2 for loops that each just run 1 cycle.  The first one grabs the value of the control and passes it off to the 2nd loop, which uses a reference to the control to change it's value property.

 

Great suggestion, thanks so much!  Now I just have to figure out how to put this in my code.  I'm actually using labview scripting to create a bunch of controls and indicators...now I have to figure out how to create a reference to a control via scripting.  Thanks again.

0 Kudos
Message 3 of 8
(2,641 Views)

Have you looked at this thread?

0 Kudos
Message 4 of 8
(2,634 Views)

C/P of discussion from PM..

The question was:  Is it ok to use Local Variables to pass data between the loops.

 

Reply:  (without seeing the code)

 

I would recommend to stay away from Local Variables.  Their use (and abuse) lead to the Dark Side..

The reason is that Local Variables do not respect the data flow and are often the cause for race conditions.

 

I would have to look at your code... But you can do the experiment yourself.  Have a look at the results and check to see if you have two values side-by-side.  If you do, that is a sure sign of a race condition.

 

You have two loops running in parallel.  There is no synchronization between them on how long one iteration takes... One loop might take 10ms, whereas the other takes 9 ms.  on the 10th iteration, the faster loop will have caught up the slower loop and will either read stale data, or will write data and will overwrite it before the slower loop gets a chance to read it.  The 2nd scenarion is worse, because there is no way to detect that a race condition occurred, unless you do the experiment and wire the lopp iterations, which is a sequential list of numbers and you look for missing numbers.

 

If you use 2 loops and want to share bdata between the two, I would recommend using a Notifier or a Queue.

 

0 Kudos
Message 5 of 8
(2,609 Views)

OK, notifiers look like they could work.

 

I have a read loop and a write loop running in parallel.  Each iteration of the loops simply refreshes my indicators and reads from my controls.

 

I looked at a notifier example and think I understand the concept...however, I'm not sure what to hook up to the 'notification' input of the Send Notification function.  I say that because there's no guarantee that when I read the registers on a given loop, that any data will have changed.  Likewise for the write...until the user changes the value, what's written out will not change.

 

To simplify the question, I attached a picture that shows what I'm talking about...read loop on the left, write loop on the right:

What I'm saying is that there's no guarantee on any iteration of the loop that either:

a) on the left hand side, the input string will change

b) on the right hand side, any of the boolean/numeric controls will change

 

Thanks

0 Kudos
Message 6 of 8
(2,605 Views)

Oh boy...

 

I didn't know what you were up to, so you may need to change your architecture...

If you want the loops to iterate based on change in value, then you need a state machine with an Event Handler.

The Event Handler could fire events based on what changed. 

 

What causes the values to change?  Is it an operator or does it happen programmatically?  In other words, do you poll a target for new data..

 

The more we know about what you are doing and how you want the software to behave, the easier it will be to propose a solution.

0 Kudos
Message 7 of 8
(2,596 Views)

This is connected to an FPGA through a DCN interface.  Each iteration of the write loop samples the current value of my controls and enqueues them into a queue that is sent to an FPGA (where a debug interface dequeues the elements and writes the data).  Similarly, the FPGA is enqueuing current register values to a separate queue, which is sent back to me.  This queue is what my 'read' loop polls, retrieving one element at a time and updating indicators accordingly.

0 Kudos
Message 8 of 8
(2,593 Views)