11-24-2012 05:28 PM
like other posters I am very new to LabView, so if this is a really simple problem, please have discretion and still try and point me in the right direction- thank you!
I am trying to measure magnitude of optical mouse displacement by calibrating to a micropositioner.
I have attached the VI below - the original VI was a position sensing VI that was available on the forums -
Basically the problem that I have right now is that I need only the first value that goes into the shift register however it continuously outputs the values when the enter key is not held down.
Eventually I would like to measure the displacement of 2 mice simultaneously to determine an axis of rotation and angular displacement, but I'm not sure how to acquire the position of two mice, so if you have a suggestion for this problem i'd really appreciate that also.
Solved! Go to Solution.
11-24-2012 05:29 PM
11-24-2012 06:15 PM
You did not include the subVIs so it is difficult to tell what your VI is doing.
Both of the Acquire Input Data VIs will return a value every time the loop iterates. It may be the previous value or it may be a default value or it could be something else. Does the VI generate some kind of signal to indicate that the data is valid or has been updated?
It looks like you have two different subVIs with the same name, one for the keyboard and one for the mouse. That can create problems. Rename at least one of them.
Do you need to Close the reference to the keyboard just as you do for the mouse?
Mouse positions are determined by the OS and passed to the application. I do not think the OS distinguishes between multiple mice. When I use two mice and move both simultaneously, the cursor gets very confused and so do I.
11-24-2012 07:32 PM
First, thanks a lot for your help, I really appreciate it-
I guess I'm not really sure what you mean that I didn't include the sub-VI's. there are 4 main sub VI's - they are the mouse initialize, keyboard initialize, mouse acquire, and keyboard acquire VI's. Am I supposed to save these in a separate file so they can be viewed? When I open the displacement VI from the attachment above I can open the subVI's by double clicking the mouse, keyboard, or 2 joystick icons on the main block diagram.
I should have said how the VI operates. When the the enter key is held down "Numeric 2" (front panel) is indicated. When the enter key is not held down "Numeric" is indicated.
What I want is for Numeric to only indicate the very first value that passes through the shift register, or the first value that comes out of the case structure when the enter key is released.
11-24-2012 08:33 PM
You have the subVIs on your computer so LV finds them and installs them when you open the main VI. I do not have them, so LV searches for them but does not find them. You can put them in a zip file so you do not need to have several attachments.
Interesting. I launched your VI again and looked closely at the search window. It thinks those subVIs are in vi.lib: Utilities: Input Devices.llb. No such llb exists on my installation so maybe this is a platform dependent library, although those are usually in vi.lib:Platform. If they are platform dependent, they probably would not work here anyway.
11-24-2012 09:39 PM
That makes sense now. Sorry for my confusion - I don't mean to waste your time, I'm really just getting a feel for how everything works through tutorials.
It is weird though because I tried it both on a remote desktop connection to my school and on my laptop, and in both cases the vi attachment worked fine.
Anyways, attached is the zip file with the sub VI's included.
Thanks so much,
11-25-2012 05:38 PM
Several of the VIs you included in the zip file have Call Library Function Nodes which call code not written in LV and which is platform dependent, so I still cannot run them on my Mac. They are looking for a file on the C drive. Hopefully someone who uses Windows will be abel to help you.
11-26-2012 04:26 PM
Hi Lynn, I'll simplify my question so that you can answer part of my problem without the vi.
WHen I press the return key a value indicating the displacement of the mouse relative to the top left of the screen is passed through the case strucutre. When I release the return key, The same thing happens. However what I want is to do is store the very first value that is passed through the case structure when I press the return key so I can subtract this from the value when I release the return key to find the displacement relative to when I began holding the enter key.
So my question is, if a value is continously changing, how can I save the value at a certain instance?
11-26-2012 06:34 PM
Thank you for clarifying your logic. I modified your program to demonstrate one way of doing this. I replaced the subVIs with two controls: a button marked Return and a slide control called Mouse. I added a shift register to keep track of the previous position of Return and some simple logic to detect only the transitions from T to F and F to T. Then it used two case structures to place the appropriate Mouse value into the shift register and to do the calculations and update the display. The F to T case structure could be replaced with a Select node from the Comparisons palette.
I also increased the wait time so that you can see the transitions LEDs.
11-28-2012 12:53 AM
Perfect, thanks so much for your help!!