04-23-2020 10:00 AM
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.
Solved! Go to Solution.
04-23-2020 10:09 AM
04-23-2020 10:29 AM
Sorry, here is the VI. Speed is not calculated since I dont have correct distance.
04-23-2020 10:49 AM
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.
04-23-2020 11:27 AM - edited 04-23-2020 11:27 AM
In regards to prettypwnie's mention of the shift register, here is a crude example you can work from.
04-23-2020 02:13 PM
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…
04-24-2020 04:42 AM
Combining Gerds suggestion an Altenbach favorite, i think i had an Altenbach moment. 🙂
04-24-2020 05:45 AM
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 !
04-24-2020 06:14 AM
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…
04-27-2020 02:22 AM
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.