fra589 / grbl-Mega-5X

5/6 Axis version of Grbl, the open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on an Arduino Mega2560
https://github.com/fra589/grbl-Mega-5X/wiki
Other
344 stars 161 forks source link

Resuming after a door/alarm state resets M7 (Coolant) state #229

Closed amoineau closed 2 years ago

amoineau commented 2 years ago

Hello,

Context

We are developing a machine that can cut and mark textile. In our configuration, we are using M7/M9 to command a relay thanks to the 'coolant' output. This allows us to direct the spindle signal to the primary or secondary tool, and thus change tool easily from the g-code.

Problem

Unfortunately we noticed that when a door sensor or our emergency button was triggered, GRBL would reset the 'coolant' state. In our case, it means that we revert to the default tool. So if we trigger a door signal mid-shape, we then resume with the wrong tool.

What we tried

In protocol.c, We commented the de-energizing of the coolant when going into sleep state (line 622). So now the coolant isn't reset when triggering a door, however, when sending the resume signal there seems to be a second reset.

What we need

We couldn't find a way to prevent this behaviour, could someone help us find a solution please. We would like the coolant state to be unaltered by door/alarm/hold or any such signal.

Thank you in advance for your help.

fra589 commented 2 years ago

Hi @amoineau,

The 1.2d version of Grbl-Mega-5X have the ability to drive up to 4 digital output with the GCode commands M62, M63, M64, M65 (see http://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m62-m65). The output are connected to the D16, D17, D23 and D25 pins (see https://github.com/fra589/grbl-Mega-5X/wiki/grbl-Mega-5X-pinout) You can use those digital output to drive your tool selection relay. The digital output status is not altered by the door/alarm state.

@++; Gauthier.

amoineau commented 2 years ago

Hello, Thank you for your quick response. I wish we started with that, unfortunately the machine and the board are made, wired... and shipped (only one copy fortunately). Classic "it's not ready/ we need to deliver" situation. So even if it's a perfectly fine solution, I'm afraid we can't implement it unless it's really our last resort.

fra589 commented 2 years ago

Hi @amoineau,

I think it's not a problem if you don't need a real coolant functionality... Remapping pins is easy, you just have to change few lines in the cpu_map.h file: https://github.com/fra589/grbl-Mega-5X/wiki/Pinout-mapping-in-cpu_map.h So, you can remap the coolant output to any other not used pin, then remap one digital output pin to the already wired coolant pin.

@++;
Gauthier.

amoineau commented 2 years ago

Yes I forgot that ! (most of our pins are actually remapped for the home made board) The only downside I still see, is that we are using GRBL plotter and there are leds for the spindle and the mist which allow us to clearly see which tool is running. Since one of the tool is a laser (mostly invisible) it is very useful, if not mandatory, to have this kind of information on screen to quickly see if there is an error.

fra589 commented 2 years ago

Hi,

The status report initiated by '?' is reporting digital output status in the accessory state (A:SCFMD) output when there is one or more digital output active(s). For example, in reply to '?': <Idle|MPos:0.000,0.000,0.000,0.000,0.000|FS:0,0|Ov:100,100,100|A:D0001> The sentence A:D0001 mean that the digital output p0 is on. The accessory state is present in the same message than the override values field (Ov:) in the same message. If there is no digital output accessory state status with the Ov: field, thi mean that is no digital output active. The override values field doesn't appear each time the '?' command is issued, but each accessory state change will trigger the accessory state and override values fields to be shown on the next report. With this, it should be not too difficult to add the code for your leds to your version of GRBL plotter For more details, see the Grbl-Mega-5X interface Wiki : https://github.com/fra589/grbl-Mega-5X/wiki/grbl-Mega-5X-v1.2-interface.

@++; Gauthier.

amoineau commented 2 years ago

Ok, thank you for all these information ! I'll try to see what we can do.

fra589 commented 2 years ago

Hi @amoineau,

The accessory state (A:...) is always sended by Grbl with the Ov: sentence.
If you don't have accessory state in the same message than the Ov:, this mean that all the accessories are off.
The Ov: is pushed after all accessories change.

M64P0
ok
?
<Idle|WPos:0.000,0.000,0.000,0.000,0.000|Bf:35,255|FS:0,0|Ov:100,100,100|A:D0001>
M65P0
ok5
?
<Idle|WPos:0.000,0.000,0.000,0.000,0.000|Bf:35,255|FS:0,0|Ov:100,100,100>

@++; Gauthier.

svenhb commented 2 years ago

If you don't have accessory state in the same message than the Ov:, this mean that all the accessories are off.

Yes I figured out later, also D0000 will never be sent... After realizing this, I deleted my posts...

fra589 commented 2 years ago

Yes, it work like any other accessories states. 😃

amoineau commented 2 years ago

Ok, I was kinda lost on what was happening, I received the mails but couldn't see anything here ^^

svenhb commented 2 years ago

Yes, sorry, I deleted my posts

svenhb commented 2 years ago

Thanks, now I can display the D0 - D3 status: https://github.com/svenhb/GRBL-Plotter/releases Are there any other features (compared to standard grbl) that I am not aware of?

fra589 commented 2 years ago

Hi @svenhb,

Grbl-Mega-5X have capability of 3 to 6 axis, capacity to rename axis (change letter of axis) and capacity to clone (use 2 or more axis for the same letter), there may be some output differences:

@++; Gauthier.

svenhb commented 2 years ago

The $I output report [VER:], [AXS:] and [OPT:]. [AXS:5:XYZAC] mean...

That's interesting - thanks. The rest I already knew 🙂

amoineau commented 2 years ago

Sven you're amazing, thanks for the changes ! And thank you Gauthier for the help :)