LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI transferring data to Instrument just once (Instrument Driver)

Hey everyone,

 

I have created a VI with which I want to control a signal generator. Unfortunately, my VI can only be executed once (run). As soon as I start a test run, the data is transferred to the signal generator. As soon as I change something in my VI, such as the frequency, the change is not transmitted to the signal generator. If I stop the run and want to start again, no data is transferred to the signal generator. Can anyone help me to find the cause of this problem?

My VI is attached

 

Thanks in advance

 

 

0 Kudos
Message 1 of 9
(997 Views)

This VI just does the setting up of the instrument and then ends.  There is no repeating of this unless you are using the Run Continuously (which you should not be doing).

 

1. Your FOR loop is pointless.  I will just use 100% of a CPU core and do nothing but read the controls the number of times you specified.

2. It seems like what you want to do is use a While loop.  Use the Initialize VI before the loop and the Close VI after the loop.  Inside of the loop, I would probably use an Event Structure to set the items when a control's value is changed.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 9
(982 Views)

Thank you.

So I should use something like a state machine. Normally a state machine consists of a while loop and a case structure located within the loop. But is it possible to create it with an event structure? If I use the event structure I have to do an event for every Instrument control, right?

0 Kudos
Message 3 of 9
(939 Views)

It is not a State Machine.  So let's stop that talk.

 

With the Event Structure, you make a different event case for each thing you want to react to, a control's value changing being the most common event type.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 9
(929 Views)

Hi crossrulz,

Thank you.

 

Now I have changed the code a little bit because I will use predefined sequences which I which I can select via the "sequence selection" in the front panel. I hope it makes sense with the case structure.

 

I have another question about how to implement the "Run" button. So if I now select the instrument and the sequence, the "Run" button should execute the specific sequence. How can this be implemented in my VI?

0 Kudos
Message 5 of 9
(882 Views)

@Leamri wrote:

I have another question about how to implement the "Run" button. So if I now select the instrument and the sequence, the "Run" button should execute the specific sequence. How can this be implemented in my VI?


Put the sequence into an Event Structure.  Have an event case for the Run button Value Change event.  The case structure and the enum should be inside of that event case.  You should also have another event for stopping the VI.  I cleaned up one of the cases, I will leave the rest for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(874 Views)

Thank you very much for your help!

 

If I want to start another sequence on the Channel 2 right after the first sequence. Is it a good way to make a new case for it and choosing Channel 2? 

 

 

0 Kudos
Message 7 of 9
(845 Views)

Or just create a control to select which channel is used.  I try to avoid duplication of code whenever possible.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(837 Views)

What do you mean by the control?
I already have a control in each case that selects the channel, but the other settings like frequency, amplitude etc. for the sequences are different. But I want two sequences to be executed per case, one per channel. If I now select "channel 1" in my first case and the corresponding settings for the sequence, I cannot select other settings for "channel 2" in the same case.

Unbenannt.PNG

0 Kudos
Message 9 of 9
(833 Views)