bdurbrow / grbl-Mega

An 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/gnea/grbl/wiki
MIT License
35 stars 8 forks source link

Enhancement, Laser mode pin #14

Closed thawkins closed 4 years ago

thawkins commented 4 years ago

Would it be possible to have a pin that goes high when lasr mode is enabled. This would allow me to switch laser power though a relay so it is only enabled in laser mode.

bdurbrow commented 4 years ago

In principal, yes... any particular pin you'd like as the default in the cpu_map.h file?

Also, be aware that in the current setup; IIRC laser mode is saved to the EEPROM; causing a write cycle every time it's turned on or off.

When I implement this; I'll see about a compile-time configuration flag to disable the write for that parameter.

thawkins commented 4 years ago

Im not fussy, anything free will do.....

On Sat, Sep 28, 2019, 8:02 PM Britt, notifications@github.com wrote:

In principal, yes... any particular pin you'd like as the default in the cpu_map.h file?

Also, be aware that in the current setup; IIRC laser mode is saved to the EEPROM; causing a write cycle every time it's turned on or off.

When I implement this; I'll see about a compile-time configuration flag to disable the write for that parameter.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bdurbrow/grbl-Mega/issues/14?email_source=notifications&email_token=AAADRSNIFMJDDAHVT3Z3SXLQL5BUZA5CNFSM4I3NING2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72X4YA#issuecomment-536182368, or mute the thread https://github.com/notifications/unsubscribe-auth/AAADRSJF53SFZNO74RCMPK3QL5BUZANCNFSM4I3NINGQ .

thawkins commented 4 years ago

Having thought about it, there is a spare pin on the block with spindle pwm/dir/enable

That is probaly the best place

We also should ensure that spindle enable cannot not go high at all when in laser mode.

thawkins commented 4 years ago

re the eeprom write, that should probably be changed to only write the eeprom on a $x like everything else.

bdurbrow commented 4 years ago

there is a spare pin on the block with spindle pwm/dir/enable

That pin is going to be needed for a spindle tach pulse input.

Next to it, on the AUX 1 port, there is another unused pin - D58. So, that's what I'm going to set as the default for the Laser Mode Active pin.

Of course, one can re-arrange things to one's requirements by editing the cpu_map.h file.

We also should ensure that spindle enable cannot not go high at all when in laser mode.

Um... yeah... that won't work. Some machine setups use that output to turn the laser on. For dual mode devices; I think that handling this in hardware is probably the better choice - either with a relay or an AND gate triggered off of the 'Laser Mode Active' pin. However; I think I'd be less worried about activating the spindle inadvertently - which probably wouldn't have a cutting bit in it, if one were using the machine in laser mode - than inadvertently activating the laser; which can be a nasty hazard if you aren't expecting it.

This is another good reason to have a laser machine in a full enclosure with safety interlock switches.

re the eeprom write, that should probably be changed to only write the eeprom on a $x like everything else.

That's the problem: you enable laser mode with a $32=1 command... which then promptly writes the whole settings struct to the EEPROM... each and every time anything (including laser mode) is changed.

So... what I've done is to remove the unconditional call to write_global_settings() at the end of settings_store_global_setting() and put it in case 255: of that function - sending $255=1 will cause the current settings state to be written to the EEPROM.

Saur0o0n commented 4 years ago

So... what I've done is to remove the unconditional call to write_global_settings() at the end of settings_store_global_setting() and put it in case 255: of that function - sending $255=1 will cause the current settings state to be written to the EEPROM.

Just document it clearly - since it can bring a lot of grey hair for some, trying to find out why machine settings does not save :)

bdurbrow commented 4 years ago

Just document it clearly

It'll be in the Readme.md file that shows up on the main page of this repository. It's the first item listed for the October update.

bdurbrow commented 4 years ago

Closing this issue now because the requested functionality was included in the October 2019 update.