LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse cursor speed

Solved!
Go to solution

Hi,

I have a slight problem with calculating cursor speed. I get my X and Y coordinates with a event and I´m using shift register to build array of those coordinates. How do I calculate distance that cursor traveled and also how can I calculate cursor speed. I´m using trigonometry to calculate distance between two points and I´m getting some nonsence numbers.  

 

Thanks for any solution.

0 Kudos
Message 1 of 10
(1,314 Views)

Hi Jony,

 

when your calculation gives nonsense numbers then most probably your calculation is wrong (implemented)...

 

Maybe you should attach your VI?!

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
0 Kudos
Message 2 of 10
(1,300 Views)

Sorry, here is the VI. Speed is not calculated since I dont have correct distance.

0 Kudos
Message 3 of 10
(1,292 Views)

Use the probe tool to look at the arrays on your shift registers. After the first five elements get filled up, more and more get added, but those first five stay the same. So you are always comparing the current mouse position to the same number every time.

 

If you want to compare the current mouse position to the mouse position 5 iterations ago, you could try using an array that you keep at a fixed size of 5, or else you could also try pulling the shift register down 5 times, up to you.

0 Kudos
Message 4 of 10
(1,266 Views)

Shift Register Demo.png

In regards to prettypwnie's mention of the shift register, here is a crude example you can work from.

0 Kudos
Message 5 of 10
(1,235 Views)

To get a more (easily) scalable version of this "shift register dragged to 5 outputs" you should have a look at the Pt-By-Pt-DataQueue: this also gives you the sample from 5 iterations ago, if configured correctly, while allowing easy changes to create shorter/longer queues…

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
0 Kudos
Message 6 of 10
(1,183 Views)
Solution
Accepted by topic author KonyJony

Combining Gerds suggestion an Altenbach favorite, i think i had an Altenbach moment. 🙂

Mouse distance travelled.png

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 7 of 10
(1,139 Views)

Thanks, for reply !

 

Just one last question, what are those block that look like a queue, or better could you post the VI ? Thanks a lot !

0 Kudos
Message 8 of 10
(1,133 Views)

Hi Kony,

 


@KonyJony wrote:

Just one last question, what are those block that look like a queue,


Did you read my messages? It's explained in the text…

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
Message 9 of 10
(1,119 Views)

I think my example can be optimized (i haven't tried this) by reducing the queue to 9, then the Pushed out value (not used currently) should be the 10th and you don't need the Delete from array to get the last one.

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(1,049 Views)