01-23-2006 02:51 AM - edited 01-23-2006 02:51 AM
Message Edited by Ayman_Metwally on 01-23-2006 02:55 AM
01-23-2006 03:07 AM
This would happen if you actually wired the constant into the shift register as you said you have.
However, a much simpler way of doing this is wrapping the code inside the loop in a case structure and wiring the Init button into it. If the button was pressed, you output 0 (T case). If not, you run your currect code (F case). Making the button a latched button will make it happen only once after you press the button.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
01-23-2006 03:11 AM
I would like to make one correction - wiring the constant into the SR is a required step to make it work, but not the only one. In the bottom loop, you're setting the button to T and immediately to F. In the top loop you only read the value once a second. This will mean that the top loop will be very unlikely to recognize the change in the value of the button.
This is one version of what's known as a race condition - without dependency between the two parts you have no way of forcing them to behave the way you want them to. In general, it's best to try avoiding solutions like these and go for the simpler solutions, because they are less likely to produce race conditions, which can be hard to locate and debug.
01-23-2006 03:18 AM
Hiiii,Ayman
I think this will work for you, and another thing is you can't implement 2 loops simul, coz as per ur vi, if u press the button for stopm, control will go in that loop and it will rotae in that iteration upto which you wont stop it. i am attaching the vi with this.
Thanks,
Nishant
01-23-2006 03:27 AM
Hiii,tst
Check if i am right or not? as per i understand the problem, i think the solution i ve given will work for him, else pls... suggest me if anything goes wrong, i think that, he has implement a wrong loop of while the second one where he was executing that true/false command, bcoz when that command execute first time, then after every time, his control will be in the while loop, until he stop that loop.
Thanks,
Nishant
01-23-2006 03:32 AM
@tst wrote:
This would happen if you actually wired the constant into the shift register as you said you have.
Well, actually I forgot to wire it in the code that I post !!! .. anyway, It doesn't reslove the problem
@ tst wrote:
However, a much simpler way of doing this is wrapping the code inside the loop in a case structure and wiring the Init button into it. If the button was pressed, you output 0 (T case). If not, you run your currect code (F case). Making the button a latched button will make it happen only once after you press the button.
I'm not sure i interpreted your words as you want to .. But I'll try and tell you the result .. Thanks
@tst wrote:
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
Thanks for the advise, But I really don't know why did you offer it ,, Is it because the question is too simple ? maybe !
Hey I provided many good answers here
Many thanks to you.
01-23-2006 03:42 AM - edited 01-23-2006 03:42 AM
tst,
Thanks for your reply .. This is a good point "Racing problem" .. I have to think for another solution .. But as I said before, I'm simplyifing the code posted as possible (There is lots of Database, dataSocket and many analysis functions code) .. But I'm simplyfing it so it can be understood quickly by forum members.
Thanks again for the great help
Edit: The order of the replies is not as I posted it ! Please note that
Message Edited by Ayman_Metwally on 01-23-2006 03:45 AM
01-23-2006 05:08 AM
01-23-2006 05:22 AM
Hiiii, tst
You are right that it is a simple code, but i think Ayaman wants to stop the execution for the miliseconds, so will it happen in your vi? i dont think, coz you dont have stop it anywhere instead, so.....
Thanks,
Nishant
01-23-2006 05:54 AM