08-07-2007 04:36 PM
08-07-2007 09:13 PM
08-07-2007 11:29 PM
@USChris wrote:
I have a knob that changes the voltage on a power supply over GPIB. How do I make the program only change the voltage when the knob is moved, rather than continuously even if the knob doesn't change?
Well, why would it change the voltage if the knob is not moved? wouldn't that result in the same, unchanged voltage. I;) assume you only want to send a command if the value actually changes.
The exact implementation depends on the rest of your code. if the loop needs to spin because of other code, place the voltage update code inside a case structure. Using a shift register, compare the current with the previous value and execute the update case only if they are different.
If the loop can pause until something happens, you can use an event structure for "knob:value changed". IT will only execute whenever the knob changes.
08-08-2007 03:55 PM