Python actual_position instruction accuracy

More
19 Feb 2023 19:21 #264824 by cnc_rocket
Hi there

Here is the following that I want to do:
-  While my cnc is moving, I want to have a python script that spits out the position of my cnc combined with a current timestamp.
-  And I want this to happen as fast as possible.

So I came up with the following idea:
stamp1 = time.time()
cords = s.actual_position
stamp2 = time.time()
stamp = (stamp1 + stamp2)/2

I take a timestamp before I fetch the actual_position and one after, then I take the average of both.
I was wondering how accurate this is.
Could anybody give me a bit more detail in how the s.actual_position attribute works?

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 13:13 #264955 by andypugh
Why do you want this? Have you considered HALScope to capture the data?

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 15:02 #264959 by cnc_rocket
Thank you for your answer.
So, I have a laser sensor connected to my mill machine.
This laser sensor measures the distance to the underling surface.
I have a program where I can read out the sensor's value, with his timestamp.
Based on this timestamp, I want to match my CNC's position.
So I thought to write a python script that would spit out the CNC position and timestamp.
I didn't consider HALScope, and I don't know how I would extract that information and read that information into python.

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 15:58 #264963 by andypugh
Generally I would avoid Python (or anything else userspace) for this sort of thing.

How does the sensor value get into the system? Can it be sampled in a realtime component and passed on to a HAL pin?

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 17:03 #264967 by cnc_rocket
No, the sensor is connected with an Ethernet cable.
The sensor sends UDP packages to the computer.
And in a packet, the time difference with the previous packet is specified.

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum