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
(2,950 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/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(2,936 Views)

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

0 Kudos
Message 3 of 10
(2,928 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
(2,902 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
(2,871 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/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(2,819 Views)
Solution
Accepted by 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! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 10
(2,775 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
(2,769 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/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 10
(2,755 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! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(2,685 Views)