Python actual_position instruction accuracy

More
3 years 8 months ago #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:
Code:
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 to join the conversation.

More
3 years 8 months ago #264955 by andypugh
Why do you want this? Have you considered HALScope to capture the data?

Please Log in to join the conversation.

More
3 years 8 months ago #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 to join the conversation.

More
3 years 8 months ago #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 to join the conversation.

More
3 years 8 months ago #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 to join the conversation.

Time to create page: 0.084 seconds
Powered by Kunena Forum