Using G64 with M66 for smooth robot control

More
1 year 9 months ago #319015 by hellvetica
Hi, I've been using linuxcnc to control my delta robot arm through HAL pins and M66 commands.
This is my GCODE
Code:
(AXIS,stop) O500 WHILE [1] ( Main loop ) M66 E0 L0 ; Read from motion.analog-in-0 (X) #1 = #5399 ; Store the read value in variable #1 M66 E1 L0 ; Read from motion.analog-in-1 (Y) #2 = #5399 ; Store the read value in variable #2 M66 E2 L0 ; Read from motion.analog-in-2 (Z) #3 = #5399 ; Store the read value in variable #3 G1 X#1 Y#2 Z#3 F1000 ; Move to the new position ; G4 P0.1 ; Wait a short time before the next read (optional) O500 ENDWHILE M30

I connect custom pins to the motion analog in pins and then set the xyz values in my python or c program.
This works great, but when I try to add G64 blending to make the robot keep its speed it doesn't work.
Obviously this is because the trajectory planner doesn't know the next target point until it's read by M66 in the next gcode loop, so I tried adding the next target point into the gcode as well with 6 analog inputs:
Code:
(AXIS,stop) G64 P50 O500 WHILE [1] ; G4 P0.001 ; Wait a short time before the next read (optional) ( Main loop ) M66 E0 L0 ; Read from motion.analog-in-0 (X) #1 = #5399 ; Store the read value in variable #1 M66 E1 L0 ; Read from motion.analog-in-1 (Y) #2 = #5399 ; Store the read value in variable #2 M66 E2 L0 ; Read from motion.analog-in-2 (Z) #3 = #5399 ; Store the read value in variable #3 M66 E3 L0 ; Read from motion.analog-in-3 (X) #4 = #5399 ; Store the read value in variable #4 M66 E4 L0 ; Read from motion.analog-in-4 (Y) #5 = #5399 ; Store the read value in variable #5 M66 E5 L0 ; Read from motion.analog-in-5 (Z) #6 = #5399 ; Store the read value in variable #6 G1 X#1 Y#2 Z#3 F30000 ; Move to the new position G1 X#4 Y#5 Z#6 F30000 ; Load next position O500 ENDWHILE M30

This only works for every other point, because when the gcode loops, the trajectory planner has no information about the next point.

What I would need is to load the next target point into the trajectory planner so that G64 can use it, but not go there with G1. I tried adding O500 continue between the G1s but then the gcode is smart and ignores the second G1.

Is there a way to do this?


 

Please Log in to join the conversation.

More
1 year 9 months ago #319017 by Aciera
Where are you reading those positional values from and how far in advance are they known?

Please Log in to join the conversation.

More
1 year 9 months ago #319021 by hellvetica
The positional values are determined by a camera running object detection.

We're using it for a pick and place system so sometimes the entire move is known ahead of time (when object is being placed) but sometimes i want to change the target depending on camera feedback.

Please Log in to join the conversation.

More
1 year 9 months ago #319023 by Aciera
Have you thought about using the python interface to issue MDI commands to the queue instead of running a parametric gcode program?

Please Log in to join the conversation.

More
1 year 9 months ago #319025 by hellvetica
Yes i played with the python MDI interface but it seemed to me like I couldn't get precise timings for my moves.

We're trying to pick up moving objects from a conveyor belt and MDI seems to have a delay.
Also, we want our robot to be VERY fast and we're going to be pushing it to its limits. MDI doesn't seem to fit into that.

Please Log in to join the conversation.

More
1 year 9 months ago #319033 by Aciera
The problem is that M66 is a 'queuebuster' command that halts the interpreter until gcode execution has caught up which makes it impossible to blend moves before it with moves that come after.

The only other possibility to influence axis position during gcode execution is external offsets:
linuxcnc.org/docs/html/motion/external-offsets.html

Please Log in to join the conversation.

More
1 year 9 months ago #319105 by hellvetica
I'll make some more tests with MDI and see how feasible it is.
Motion blending is a must have for us.

Please Log in to join the conversation.

More
1 year 9 months ago #319117 by hellvetica
Using MDI with python there's a 20ms delay between sending the command and the robot starting the move. There is also a 20ms delay between each MDI command i can send. So if i want to send 10 points to the robot it'll take 200ms to just send the commands.

This is far from ideal for a realtime application. Is there a parameter I can tune to speed up MDI?

Please Log in to join the conversation.

More
1 year 9 months ago #319130 by Grotius
@Hellvetica,

It's what Arciera mentioned before. External offsets could do what you want.
Mdi is just far to slow.

Using a custom trajectory planner:
I can imagine adding gcode lines at runtime including blends trough hal pins at runtime.
And even cancelling existing paht moves, and update them including blend to new target position.



 

Please Log in to join the conversation.

More
1 year 9 months ago #319132 by Aciera
I don't think you''ll get much more speed out of the python interface. There is also 'linuxcncrsh' which is written in c++, which might be worth a try (although as such also non-realtime) You can also connect to it over localhost:
linuxcnc.org/docs/html/man/man1/linuxcncrsh.1.html

Please Log in to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum