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

More
24 Jul 2020 12:08 - 24 Jul 2020 12:12 #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


This is my setup, i want to stop the motor in exact position
Attachments:
Last edit: 24 Jul 2020 12:12 by Duongtantai8624.

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

More
24 Jul 2020 12:46 #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
The following user(s) said Thank You: Duongtantai8624

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

More
24 Jul 2020 13:01 - 24 Jul 2020 13:02 #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.
Last edit: 24 Jul 2020 13:02 by Duongtantai8624.

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

More
24 Jul 2020 13:14 #175630 by tommylight
The following user(s) said Thank You: Duongtantai8624

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

More
24 Jul 2020 13:21 #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
The following user(s) said Thank You: Duongtantai8624

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

More
25 Jul 2020 09:43 - 25 Jul 2020 10:30 #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
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.
M64 P1
o100 while [#1 NE 0]
#1 = #<_hal[motion.digital-in-01]
o100 endwhile
M65 P1

Please show me what im doing wrong
Last edit: 25 Jul 2020 10:30 by Duongtantai8624.

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

More
25 Jul 2020 14:14 - 25 Jul 2020 14:14 #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.
Last edit: 25 Jul 2020 14:14 by PCW.
The following user(s) said Thank You: thefabricator03

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

Time to create page: 0.143 seconds
Powered by Kunena Forum