I tried to use the DAQ assistant to drive an electromagnet setup. Everything in the code was fine apart from an error message coming everytime I run the code and code stopping execution after that. The error message is the timeout of the DAQ device. When I make it short, It stops after immediately. I make it long time, the code will run until the specified time is reached no matter how many times that you press the STOP button. The only way to stop the code is to abort it altogether. I would like to know what could be done to solve this problem.
Many thanks in advance.
Could you please post the exact error code/message you're receiving from the DAQ assistant?
I have run your code and it stops when I use the STOP button, so I need to know a little more to replicate your issue. What hardware are you reading for the voltage out?
Thank you for your reply. I attached the error message.
I use Keithely 2000 for reading voltage. The DAQ that I use is BNC 2110.
Thanks for the reply. I'm a little confused, the screenshot you sent doesn't correspond to the code I downloaded (from your previous post!). Could you post the same .vi that you are using and getting the error in?
As for the error message - try setting the timeout to -1, this means that it will not time out at all and should clear the error.
Thanks for your help. I tried (-1) but when doing that I could not stop the code unless I abort it. I tried to alter the code slightly to solve the problem. I manage to have it working for just one loop but for more than one loop there is a problem. I would be gateful if you could have a look into the attached code as it the most recent versioin.
Just a couple of questions about your problem, unfortunately I couldn't run the .vi you sent because I miss a lot of the subVI's required.
Do you mean that there is a problem when running the for loops in the code for more than one iteration? Do you want the code to stop itself after a certain number of iterations or is the issue with the stop button not actually stopping the code?
Thanks in advance,
Yes there is problem with running more than one loop. The code just runs the firs loop and continues taking the last data point of the first loop endlessly. I attached the code saved with duplicate hierarchy with some enclosed explanations. Many thanks in advance for your help.
So I have looked at your code and now understand what your issue is. The reason that the outer loop only iterates once, then returns the same values over and over is because there is no condition for the inner loop to stop. Therefore the code gets caught inside this inner loop. When should the inner loop stop iterating? What is the condition required for this?
I would also change the DAQ Assistant (the one in the middle frame just to the left of the two for loops) to continuous sample and connect the input of 'Stop' to the output of a condition which checks if the iteration count of the outer loop is equal to the No. of Runs that you set. This means that the DAQ Assistant will stop once the loop has done its job.