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

More
6 years 3 months ago - 6 years 3 months ago #175622 by Duongtantai8624
My code is not fast enough, i don't know why was created 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
Last edit: 6 years 3 months ago by Duongtantai8624.

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

More
6 years 3 months ago #175623 by tommylight
Replied by tommylight on topic My code is not fast enough, i don't know why
-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
6 years 3 months ago - 6 years 3 months ago #175627 by Duongtantai8624
Replied by Duongtantai8624 on topic My code is not fast enough, i don't know why
This motor for spin ATC wheel, it's took about 2 second for each round.
i'll check my hal file debounce.
Last edit: 6 years 3 months ago by Duongtantai8624.

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

More
6 years 3 months ago #175630 by tommylight
The following user(s) said Thank You: Duongtantai8624

Please Log in or Create an account 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
The following user(s) said Thank You: Duongtantai8624

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

More
6 years 3 months ago - 6 years 3 months ago #175724 by Duongtantai8624
Replied by Duongtantai8624 on topic My code is not fast enough, i don't know why
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
Last edit: 6 years 3 months ago by Duongtantai8624.

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

Time to create page: 2.051 seconds
Powered by Kunena Forum