# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Mouse cursor speed

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.

Message 1 of 10
(1,314 Views)

## Re: Mouse cursor speed

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
Message 2 of 10
(1,300 Views)

## Re: Mouse cursor speed

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

Message 3 of 10
(1,292 Views)

## Re: Mouse cursor speed

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.

Message 4 of 10
(1,266 Views)

## Re: Mouse cursor speed

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

Message 5 of 10
(1,235 Views)

## Re: Mouse cursor speed

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
Message 6 of 10
(1,183 Views)
Solution
Accepted by topic author KonyJony

## Re: Mouse cursor speed

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

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 7 of 10
(1,139 Views)

## Re: Mouse cursor speed

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

Message 8 of 10
(1,133 Views)

## Re: Mouse cursor speed

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)

## Re: Mouse cursor speed

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.