11-28-2016 06:47 AM
Hi everyone,
I would like to remotely control my my Rigol function generator. The code I am using is attached below. When I run the VI, I can enable the output as well as the frequency sweep easily. I would like to enable or disable the frequency sweep throughout my experiments. The problem I am facing is that I cannot disable the frequency sweep programmatically using the event structure. What could be wrong? Any suggestions will be highly appprciated
11-28-2016 07:47 AM
I think you are doing "too much" in your Event Structure. You seem to be starting and running the entire Instrument, from Initialize to Configure Waveform to Sweep to Read to Close. Is this what you want to do? Have you considered having Enable Frequency Sweep do nothing more than save its value in a Shift Register, having the other buttons save their values, and having "One Button to Rule Them All" (called "Do Test") that runs the code sequence you show for Enable Frequency Sweep (Initialize through Close)?
The logic behind an Event Structure is "Do Nothing and take no CPU Time until an Event occurs, then handle the Event". Changing Enable Frequency Sweep, to my mind, does not mean "Do an entire test", but "Change what I do when I (eventually) do an entire test". I hope you see the distinction, and I hope this helps you with your project.
Bob Schor
11-28-2016 08:12 AM
You really should look into a State Machine. It can help break things down a little better for you. And I like Bob's idea of just having a single button called "Run Test". You do not even need to store all of the other control's values in a shift register or handle their events. Just read the controls directly in the states that care about them.
11-28-2016 07:24 PM
Hi,
Thank you so much Bob and Crossrulz. Your ideas were of great help. I implemented the State Machine architecture and it does tome what I want. Thank you again,
Regards,
Opuk