Skip to content

Add M3, M4 & M5 spindle/laser commands #6268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 17, 2017

Conversation

thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented Apr 7, 2017

Rebase, cleanup of #6221 by @Bob-the-Kuhn

@Bob-the-Kuhn
Copy link
Contributor

Should I close 6221?

@thinkyhead
Copy link
Member Author

thinkyhead commented Apr 7, 2017

Either close #6221, or you could replace the commits in #6221 with this…

git remote add thinkyhead [email protected]:thinkyhead/Marlin.git
git fetch thinkyhead
git checkout spindle-2-nov-try-4 -b spindle-2-nov-try-4-backup
git checkout spindle-2-nov-try-4
git reset --hard thinkyhead/rc_spindle_m3_m5
git push -f

If that works, it's an interesting way to update a PR. But then, in that case, this might as well be a PR to your branch (esp. since you know how to squash commits).

@Bob-the-Kuhn
Copy link
Contributor

Superseded by PR #6268

@thinkyhead
Copy link
Member Author

This is #6268

@thinkyhead thinkyhead reopened this Apr 7, 2017
@Bob-the-Kuhn
Copy link
Contributor

Apparently I'm not fully awake yet. I've made a couple of silly mistakes this morning.

#define SPINDLE_DIR_PIN 16
#define SPINDLE_LASER_ENABLE_PIN 17 // should have a pull up
#define SPINDLE_SPEED_LASER_POWER_PIN 8 // must have a pull up
#else // Case light
Copy link
Member Author

@thinkyhead thinkyhead Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bob-the-Kuhn

I'd like to find a way to get rid of lines like these in the pins files. We've been trying to make the pins files as agnostic as possible about what features are enabled, so they simply supply the recommended (or required) pins for each feature. We aren't checking the presence of a pin to enable code (as the old Marlin code did). We just check for the enabled feature, and then use whatever pins are assigned.

We've tried some different approaches to this, but generally the idea is to make sure we don't need a lot of #if clauses in the pins files that relate to features.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to go through the files & eliminate the added #if clauses?

Copy link
Member Author

@thinkyhead thinkyhead Apr 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's just set the most sensible default pins, remove the #if clauses referring to the spindle-laser feature, and see what we have left in the pins files after that. There was a movement against requiring too many pin assignments in the main configuration files, which is why we started making the pins files more "exhaustive" on their own.

I'd say, for these pins, wrap each one in an #ifndef clause so they are easily override-able.

#ifndef SPINDLE_DIR_PIN
  #define SPINDLE_DIR_PIN 16
#endif

…etc.

We still haven't settled on how best to handle pin overrides. One universal method would be to have every pin definition be conditional on #ifndef, but that would add a lot of noise to the pins files. The extruder auto fan pins (E0_AUTO_FAN_PIN, etc.) follow a pattern that gives more control from the configs (since these pins also act as enable switches), but it's not the kind of technique you'd want to use for all pins.

@thinkyhead
Copy link
Member Author

thinkyhead commented Apr 7, 2017

For reference, here's how I implemented laser (including software PWM) for the MakerArm branch:
thinkyhead@27eeca8

The branch has later commits expanding on the multi-tool idea.

@thinkyhead thinkyhead force-pushed the rc_spindle_m3_m5 branch 2 times, most recently from fe0955b to f5e1ec7 Compare April 7, 2017 18:53
@thinkyhead
Copy link
Member Author

Split up the commit into 3 so it's easier to view the implementation by itself.

@thinkyhead thinkyhead force-pushed the rc_spindle_m3_m5 branch 2 times, most recently from c503204 to 7c6c621 Compare April 11, 2017 10:30
@thinkyhead
Copy link
Member Author

@Bob-the-Kuhn I just did a rebase, so check the pins file and make sure it's intact, exactly what you want. Particularly the last several lines.

@thinkyhead
Copy link
Member Author

thinkyhead commented Apr 30, 2017

This past week I implemented LASER using Timer 5 with a resolution of 80 levels of PWM current.

@thinkyhead thinkyhead added this to the 1.1.1 milestone Apr 30, 2017
@thinkyhead thinkyhead force-pushed the rc_spindle_m3_m5 branch 4 times, most recently from 98e5186 to 3023249 Compare May 15, 2017 03:53
@thinkyhead
Copy link
Member Author

thinkyhead commented May 15, 2017

@Bob-the-Kuhn

I'm getting this ready to merge. I moved the documentation from the lengthy comment in the configuration file to a Laser/Spindle page on the website. It's pretty much the same text, just reformatted with Markdown into a more readable form. The table, especially.

I'd like to have your opinion on how we might combine this PR with multi-tool support, which I've reduced to the main skeleton in this commit:

6c4b9ed

Mainly I want to include it because it implements the laser with some more options. It can be a simple on/off laser or one that operates with both a 12V on/off power pin plus a 5V 25KHz PWM signal pin. It also includes another simple "foam cutter" tool that operates with M3/M4/M5 — but it simply switches a 12V heater pin on or off (no PWM). Placeholders for other tool modes are included also.

@thinkyhead thinkyhead force-pushed the rc_spindle_m3_m5 branch 4 times, most recently from da792bd to 6fdd7f5 Compare May 17, 2017 05:55
@thinkyhead thinkyhead force-pushed the rc_spindle_m3_m5 branch 5 times, most recently from d9acbd1 to ebaabed Compare May 17, 2017 08:01
@thinkyhead thinkyhead merged commit 91278b9 into MarlinFirmware:RCBugFix May 17, 2017
@thinkyhead thinkyhead deleted the rc_spindle_m3_m5 branch May 17, 2017 09:20
@Bob-the-Kuhn
Copy link
Contributor

FANTASTIC!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants