My code is not fast enough, i don't know why

More
6 years 3 months ago #175622 by Duongtantai8624
Hi all
My code doesn't seems to catch the event in the right time

Here's the code

o100 sub

M64 P1
M66 P1 L1 Q5
#1 = #5399

o101 if [#1 NE -1]
M65 P1
o101 endif

o100 endsub


My halscope when execute the code, you can see it's not turn off the P1 output immediatly when P1 input was high

Attachment not found



This is my setup, i want to stop the motor in exact position

Attachment not found

Please Log in to join the conversation.

More
6 years 3 months ago #175623 by tommylight
-Might be the scope that is working at 1KHz, so to slow for capturing fast stuff,
-Might be a delay or debounce used in hal,
-Might be the wrong order of execution in the servo thread
Is that for a spindle orientation?
If yes, there is already a component included with LinuxCNC just for that:
linuxcnc.org/docs/html/man/man9/orient.9.html

Please Log in to join the conversation.

More
6 years 3 months ago #175627 by Duongtantai8624
This motor for spin ATC wheel, it's took about 2 second for each round.
i'll check my hal file debounce.

Please Log in to join the conversation.

More
6 years 3 months ago #175630 by tommylight

Please Log in to join the conversation.

More
6 years 3 months ago #175631 by PCW
M66 is not real time, from the Linux M code reference:

In LinuxCNC these inputs are not monitored in real time and thus should not be used for timing-critical applications.


linuxcnc.org/docs/html/gcode/m-code.html#mcode:m66

For real time your stop should be implemented in hal

Please Log in to join the conversation.

More
6 years 3 months ago #175724 by Duongtantai8624
Folow your reply i try to re config my hal file ,but it wont help, i guess i was misunderstood what you mean.

So i try to read hal pin with this test code. If digital pin input 01 = true, do M64 P1
Code:
o100 if [#<_hal[motion.digital-in-01]> NE 0] M64 P1 o100 endif

The read hal pin code is working but i dont know how to use it to catch the event. I try this test code, this code i use to turn off P1 when digital input 01 = false. When i try this code, linuxcnc got crash, i have to reboot linuxcnc.
Code:
M64 P1 o100 while [#1 NE 0] #1 = #<_hal[motion.digital-in-01] o100 endwhile M65 P1

Please show me what im doing wrong

Please Log in to join the conversation.

More
6 years 3 months ago #175744 by PCW
For real time you need to accomplish this in hal with hal components, not gcode.
You can arm/enable the hal logic with M66, but the actual real time logic must be
implemented in hal.

Please Log in to join the conversation.

Time to create page: 0.879 seconds
Powered by Kunena Forum