LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing a Shift register to intialize its value

Greetings everybody,
 
I'll try to simplify my problem as possible .
 
I need to Force a shift register to intialize its value (while not the loop is in its first iteration)
 
Please see my VI .. It's all clear there.  ( LV ver 7.0)
 
Thanks in advance

Message Edited by Ayman_Metwally on 01-23-2006 02:55 AM

-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 1 of 15
(3,784 Views)

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).


___________________
Try to take over the world!
0 Kudos
Message 2 of 15
(3,770 Views)

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.


___________________
Try to take over the world!
Message 3 of 15
(3,769 Views)

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

0 Kudos
Message 4 of 15
(3,760 Views)

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

0 Kudos
Message 5 of 15
(3,755 Views)

 


@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 ! Smiley Surprised

Hey I provided many good answers hereSmiley Very Happy

Many thanks to you.

 


 

-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 6 of 15
(3,755 Views)

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

-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 7 of 15
(3,752 Views)
I couldn't look at Nishant's code as it's 7.1, so attached is an example of what I meant. Note how much simpler it is and how it is less likely to go wrong. This is what I mean when I refer to going for the simple solutions. The same thing could be done with an event structure and a timeout case.
 
Yes, the advice about the tutorials is a standard advice I give (I only need 2 mouse clicks for it) whenever I see a question which is simple enough, and working properly with SRs and case structures is fairly basic. You should consider taking NIs courses as they are supposed to put some emphasis on proper style.

___________________
Try to take over the world!
Message 8 of 15
(3,742 Views)

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

0 Kudos
Message 9 of 15
(3,736 Views)
I think that he only meant he wants to stop the loop once so that it can be started again. The ultimate goal for this was resetting the SR, which is what my VI shows.

___________________
Try to take over the world!
Message 10 of 15
(3,702 Views)