Can I add a force stop condition in a loop

  • Context: MATLAB 
  • Thread starter Thread starter liran avraham
  • Start date Start date
  • Tags Tags
    Condition Force Loop
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
liran avraham
Messages
7
Reaction score
0
i have keithley currnet source that i control with matlab, inside a loop, if i force stop the loop the device continue to output the last current.
my question is can i add if condition that turn of the current source?
for example
if force stop
fprintf(device, ':OUTP OFF')
end
 
Physics news on Phys.org
liran avraham said:
my question is can i add if condition that turn of the current source?

I'm not a MATLAB expert, but one thing you could try is to place a statement at the very end of the loop that sets a variable to true if the loop completes. Then you could check right after the loop to see if the variable was set to true. If not, then the loop was stopped early.
 
that not what i meant.
i asked if there is some way to add a condition to my code that identify a force stop (ctr +c) so when i force stop my current supply output is truned off. in a way some
if (force stop\ctr +c)
turn off device
end

my main loop is endless i built some homemaide temperature controler, i am always measuring tne temperature:
while (1)
...
end
 
liran avraham said:
i asked if there is some way to add a condition to my code that identify a force stop (ctr +c)

My mistake. I'm afraid I don't know if that's possible or not, but perhaps someone else here can help you. Good luck!