Commit Graph

537 Commits

Author SHA1 Message Date
Sonny Jeon
3bb92b2530 Update README.md 2014-01-14 10:37:37 -05:00
Sonny Jeon
cc9afdc195 Lots of re-organization and cleaning-up. Some bug fixes.
- Added a new source and header file called system. These files contain
the system commands and variables, as well as all of the system headers
and standard libraries Grbl uses. Centralizing some of the code.

- Re-organized the include headers throughout the source code.

- ENABLE_M7 define was missing from config.h. Now there.

- SPINDLE_MAX_RPM and SPINDLE_MIN_RPM now defined in config.h. No
uncommenting to prevent user issues. Minimum spindle RPM now provides
the lower, near 0V, scale adjustment, i.e. some spindles can go really
slow so why use up our 256 voltage bins for them?

- Remove some persistent variables from coolant and spindle control.
They were redundant.

- Removed a VARIABLE_SPINDLE define in cpu_map.h that shouldn’t have
been there.

- Changed the DEFAULT_ARC_TOLERANCE to 0.002mm to improve arc tracing.
Before we had issues with performance, no longer.

- Fixed a bug with the hard limits and the software debounce feature
enabled. The invert limit pin setting wasn’t honored.

- Fixed a bug with the homing direction mask. Now is like it used to
be. At least for now.

- Re-organized main.c to serve as only as the reset/initialization
routine. Makes things a little bit clearer in terms of execution
procedures.

- Re-organized protocol.c as the overall master control unit for
execution procedures. Not quite there yet, but starting to make a
little more sense in how things are run.

- Removed updating of old settings records. So many new settings have
been added that it’s not worth adding the code to migrate old user
settings.

- Tweaked spindle_control.c a bit and made it more clear and consistent
with other parts of Grbl.

- Tweaked the stepper disable bit code in stepper.c. Requires less
flash memory.
2014-01-10 20:22:10 -07:00
Sonny Jeon
7a85ab896d Updates to some stepper algorithm commenting 2014-01-05 11:54:59 -07:00
Sonny Jeon
3c3382ff75 New build info feature. (per @Analogreality request)
- New build info feature. Hidden command ‘$I’ will print the build info
for your Grbl firmware. Users may also write an identifying message
within it via ‘$I=‘ with up to 32 characters. (no more, or else it will
break).

- Adjusted the max number of startup lines to 3. Majority of people
will only need one.

- Fixed a compile error with spindle_control.c. A rogue #endif was
causing problems.
2014-01-05 10:27:34 -07:00
Sonny Jeon
1baff785f5 Variable spindle output. Resolved conflicts in last push.
Resolve conflicts.
2014-01-04 12:13:49 -07:00
Sonny Jeon
8b5f306851 Cleaned up variable spindle output (PWM). Code and config comments.
- Variable spindle speed output as a configuration option. Thanks
@EliteEng! When enabled, the Z-limit (D11) and spindle enable(D12) pins
switch to allow access to the hardware PWM output on pin D11.
Otherwise, everything should work as it does.

- Removed option for inverting the spindle and coolant enable pins.
This is a safety hazard, especially for the spindle. When Grbl
initializes, all pins are momentarily low until it finishes booting. If
an invert is enabled, this means the spindles can be energized briefly
during this time. If users need signal inversion, it’s recommended to
just wire in an inversion circuit instead.

- Cleared out references to spindle variable output in terms of step
signal. This isn’t complete and requires more deliberation before
installing.

- Cleared up and cleaned up some code and config comments.
2014-01-04 12:12:44 -07:00
Sonny Jeon
0104cad56a Merge pull request #322 from EliteEng/dev
Update to fix compile error
2014-01-03 06:23:39 -08:00
Rob Brown
1c4097352d Update to fix compile error
Update to fix compile error
2014-01-03 19:35:56 +08:00
Sonny Jeon
e7cd94e2bc Merge pull request #318 from EliteEng/dev
PWM Spindle Control and Invert Spindle & Coolant Pins
2014-01-02 16:56:02 -08:00
Rob Brown
ce5f94d675 Update spindle_control.c
Updated spindle_control.c due to compile error.
2014-01-03 07:42:22 +08:00
Sonny Jeon
f8dd8fa54d Fix for M7/8/9 modal group checks. Updated AMASS frequency cutoffs and code cleaned.
- Updated Grbl version to 0.9c and build number.

- G-code parser was missing modal group violation checks for M7/8/9
commands. Added them.

- Updated the Adaptive Multi-Axis Step Smoothing (AMASS) cutoff
frequencies so that the trade between the 16-bit Timer1 accuracy and
the level step smoothing are somewhat better balanced. (Smoothing isn’t
free, but a higher accuracy timer would provide high cutoff
frequencies.)
2014-01-02 12:12:35 -07:00
Sonny Jeon
4f987d2a5e Update README.md 2014-01-02 09:24:46 -07:00
Rob Brown
c0381799eb PWM Spindle Control and Invert Spindle & Coolant Pins
PWM Spindle Control and Invert Spindle & Coolant Pins
2014-01-02 12:42:22 +08:00
Sonny Jeon
f10bad43b2 Minor bug fixes: Homing travel calculations. Cycle resuming after spindle and dwell commands.
- Homing travel calculations fixed. It was computing the min travel
rather than max.

- Auto-start disable and pausing after spindle or dwell commands.
Related to plan_synchronize() function call. Now fixed, but still need
to work on the system state.

- Pushed a fix to make this branch more Arduino IDE compatible. Removed
extern call in nuts_bolts.c

- Updated the stepper configuration option of enabling or disabling the
new Adaptive Multi-Axis Step Smoothing Algorithm. Now works either way.

- Updated some copyright info.
2013-12-30 22:02:05 -07:00
Sonny Jeon
15a803e36f Merge pull request #201 from Protoneer/master
Made a few changes to make the code compatible with the Arduino IDE. Sorry about the tardiness!
2013-12-30 20:23:54 -08:00
Sonny Jeon
47cd40c8dc Incomplete push but working. Lots more stuff. More to come.
- NEW! An active multi-axis step smoothing algorithm that automatically
adjusts dependent on step frequency. This solves the long standing
issue to aliasing when moving with multiple axes. Similar in scheme to
Smoothieware, but more advanced in ensuring a more consistent CPU
overhead throughout all frequencies while maintaining step exactness.

- Switched from Timer2 to Timer0 for the Step Port Reset Interrupt.
Mainly to free up hardware PWM pins.

- Seperated the direction and step pin assignments, so we can now move
them to seperate ports. This means that we can more easily support 4+
axes in the future.

- Added a setting for inverting the limit pins, as so many users have
request. Better late than never.

- Bug fix related to EEPROM calls when in cycle. The EEPROM would kill
the stepper motion. Now protocol mandates that the system be either in
IDLE or ALARM to access or change any settings.

- Bug fix related to resuming the cycle after a spindle or dwell
command if auto start has been disabled. This fix is somewhat temporary
or more of a patch. Doesn’t work with a straight call-response
streaming protocol, but works fine with serial buffer pre-filling
streaming that most clients use.

- Renamed the pin_map.h to cpu_map.h to more accurately describe what
the file is.

- Pushed an auto start bug fix upon re-initialization.

- Much more polishing to do!
2013-12-30 18:44:46 -07:00
Sonny Jeon
5ab2bb7767 Incomplete dev code push, but working. Lots of updates/fixes/improvements. Much still to polish.
- Ugh. Github just erased my list of improvements and changes due to a
conflict and forcing me to resolve it. Hope this goes through.

- Major stepper algorithm change. Trashed the old v0.9 edge
branch-style stepper algorithm. It’s fine, but it was susceptible to
aliasing noise when moving very slow or very fast. It also had a bit of
CPU overhead. It was written to solve a standing issue with v0.8
master, where it couldn’t generate a smooth acceleration abocve
10-15kHz. But, with new step segment buffer in v0.9c, it inadvertently
fixed the acceleration problem with v0.8 stepper algorithm. So, what
does it mean for you? Smoother stepper pulses and likely higher step
frequencies.

- Stepper algorithm now uses Timer1 and Timer2, instead of Timer0 and
Timer2. Timers 0 and 2 can be swapped if there is an issue.

- With the old v0.8 stepper algorithm, the STEP_DELAY_PULSE
configuration option is also back.

- NEW! Hard limit software debouncing. Grbl now employs the AVR’s
watchdog timer as a way to monitor the hard limit pins and checking
their states after a delay. This is a simple software debouncing
technique and may help alleviate some of the false trigger some users
have been complaining about. BUT, this won’t fix electric noise issues!

- Fixed an issue with the new homing cycle routine where it wasn’t
honoring the acceleration and axis speed limits depending on the homing
cycle mask. Now does. Also, updated the homing direction mask code to
be a little cleaner.

- Moved the main part of the homing cycle control and execution to
motion_control.c, where it fits better.

- Removed the STATE_INIT system state as it was redundant. Made the
system states into bitflags so multiple system states can be checked
via one if statement.

- Reorganized the power-up routine to work with the new system states.
2013-12-29 20:51:48 -07:00
Sonny Jeon
bfb8639606 Merge branch 'dev' of https://github.com/grbl/grbl into dev
Conflicts:
	limits.c
2013-12-29 20:36:00 -07:00
Sonny Jeon
903b462b2e Merge branch 'dev' of https://github.com/grbl/grbl into dev
Conflicts:
	limits.c
2013-12-29 20:34:51 -07:00
Sonny Jeon
8550d2c3f9 Merge pull request #312 from scottrcarlson/dev
Fixed homing_dir_mask functionality in the re-written homing_cycle.
2013-12-27 12:26:27 -08:00
Scott R Carlson
eefc25be91 Hard Limits configured for active high.
Added the use of homing_dir_mask to homing_cycle
2013-12-27 15:09:00 -05:00
Sonny Jeon
331a2cd094 Update README.md 2013-12-10 22:36:35 -07:00
Sonny Jeon
3054b2df77 Revamped homing cycle. Axis limits and max travel bug fixes. Build info. Refactored config.h.
- Revamped and improved homing cycle. Now tied directly into the main
planner and stepper code, which enables much faster homing seek rates.
Also dropped the compiled flash size by almost 1KB, meaning 1KB more
for other features.

- Refactored config.h. Removed obsolete defines and configuration
options. Moved lots of “advanced” options into the advanced area of the
file.

- Updated defaults.h with the new homing cycle. Also updated the
Sherline 5400 defaults and added the ShapeOko2 defaults per user
submissions.

- Fixed a bug where the individual axes limits on velocity and
acceleration were not working correctly. Caused by abs() returning a
int, rather than a float. Corrected with fabs(). Duh.

- Added build version/date to the Grbl welcome message to help indicate
which version a user is operating on.

- Max travel settings were not being defaulted into the settings EEPROM
correctly. Fixed.

- To stop a single axis during a multi-axes homing move, the stepper
algorithm now has a simple axis lock mask which inhibits the desired
axes from moving. Meaning, if one of the limit switches engages before
the other, we stop that one axes and keep moving the other.
2013-12-10 22:33:06 -07:00
Sonny Jeon
76e7445a85 Merge pull request #301 from shapeoko/master
added shapeoko2 profile
2013-12-10 11:02:45 -08:00
Edward
bfa8ebcac1 added shapeoko2 profile
shapeoko 2 uses 2mm GT2 belting and 20tooth pulleys
2013-12-10 11:10:36 -06:00
Sonny Jeon
b562845d9d Deceleration to zero speed improvements. Update defaults.
- A minor issue with deceleration ramps when close to zero velocity.
Should be virtually unnoticeable for most CNC systems, but fixed in
this push and accurate to physics.

- Updated some of the junction deviation defaults. Because the new
stepper algorithm can easily maximize a CNC machine’s capabilities or
simply go much faster, this means the speed in which it enters
junctions has to be a little more constrained. Meaning that, we have to
slow a little bit down more so that we don’t exceed the acceleration
limits of the stepper motors.
2013-12-07 20:08:24 -07:00
Sonny Jeon
d00525d384 Pushed bug fixes. Updated readme.
- G18 plane select fix from XZ-plane to ZX-plane per right hand rule.

- Added volatile declaration for rx_buffer_tail in serial.c. No real
effect to operation as avr-gcc adds this upon compilation. Helps with
porting issues when using a different compiler.
2013-12-07 10:10:36 -07:00
Sonny Jeon
a87f25773c Pushed limits active high option. Updated defaults.h. Misc bug fixes. Cleaned up codebase.
- Pushed limit switch active high option (i.e. NC switches).

- Updated defaults.h to be in-line with the new settings.

- Refactored feed hold handling and step segment buffer to be more
generalized in effort to make adding feedrate overrides easier in the
future. Also made it a little more clean.

- Fixed G18 plane select issue. Now ZX-plane, rather than XZ-plane, per
right hand rule.

- Cleaned some of the system settings by more accurately renaming some
of the variables and removing old obsolete ones.

- Declared serial.c rx_buffer_tail to be volatile. No effect, since
avr-gcc automatically does this during compilation. Helps with porting
when using other compilers.

- Updated version number to v0.9b.

- Updates to README.md
2013-12-07 08:40:25 -07:00
Sonny Jeon
2f6663a0b9 Reinstated feed holds into new stepper algorithm and planner. Rough draft, but working.
- Reinstated the feed hold feature with the new stepper algorithm and
new optimized planner. It works, but will be re-factored a bit soon to
clean up the code.

- At this point, feedrate overrides may need to be installed in the
v1.0 version of grbl, while this version will likely be pushed to the
edge branch soon and pushed to master after the bugs have been squashed.

- Measured the overall performance of the new planner and stepper
algorithm on an oscilloscope. The new planner is about 4x faster than
before, where it is completing a plan in around 1ms. The stepper
algorithm itself is minutely faster, as it is a little lighter. The
trade-off in the increased planner performance comes from the new step
segment buffer. However, even in the worse case scenario, the step
segment buffer generates a new segment with a typical 0.2 ms, and the
worse case is 1ms upon a new block or replanning the active block.
Added altogether, it’s argubly still twice as efficient as the old one.
2013-12-04 21:49:24 -07:00
Sonny Jeon
cc3212d54a Merge pull request #289 from Travis-Snoozy/master
Add support for active-high limit switches
2013-11-23 14:04:36 -08:00
Travis Snoozy
e8345fdb88 Add support for active-high limit switches 2013-11-22 18:12:29 -08:00
Sonny Jeon
b36e30de2e Yet another major stepper algorithm and planner overhaul.
- Overhauled the stepper algorithm and planner again. This time
concentrating on the decoupling of the stepper ISR completely. It is
now dumb, relying on the segment generator to provide the number of
steps to execute and how fast it needs to go. This freed up lots of
memory as well because it made a lot tracked variables obsolete.

- The segment generator now computes the velocity profile of the
executing planner block on the fly in floating point math, instead of
allowing the stepper algorithm to govern accelerations in the previous
code. What this accomplishes is the ability and framework to (somewhat)
easily install a different physics model for generating a velocity
profile, i.e. s-curves.

- Made some more planner enhancements and increased efficiency a bit.

- The changes also did not increase the compiled size of Grbl, but
decreased it slightly as well.

- Cleaned up a lot of the commenting.

- Still much to do, but this push works and still is missing feedholds
(coming next.)
2013-11-22 17:35:58 -07:00
Sonny Jeon
2eb5acaa33 Another merge fix. 2013-10-29 19:43:40 -06:00
Sonny Jeon
b8f0a2399e Merge fixes. 2013-10-29 19:28:44 -06:00
Sonny Jeon
4402a9f74a Merge branch 'dev_2' into dev
Conflicts:
	README.md
	gcode.c
	motion_control.c
	planner.c
	planner.h
	protocol.c
	report.c
	settings.c
	settings.h
	stepper.c
	stepper.h
2013-10-29 19:12:09 -06:00
Sonny Jeon
4f9bcde40e Merge branch 'dev_2' into dev
Conflicts:
README.md
gcode.c
motion_control.c
planner.c
planner.h
protocol.c
report.c
settings.c
settings.h
stepper.c
stepper.h
2013-10-29 19:10:39 -06:00
Sonny Jeon
0ac6c87196 Planner function call fix. More clean up. 2013-10-29 18:55:55 -06:00
Sonny Jeon
27297d444b Updated comments. Changed stepper variable names to be more understandable. Added step locking note.
- Updated config comments and stepper code comments for the new changes.

- Changed stepper algorithm variable names to be more understandable in
what they actually do.

- Added a stepper lock note in default.h per user request.

- Started some code layout in handling feed holds and refactoring the
homing routine to use the main stepper algorithm instead of a seperate
version.
2013-10-29 08:31:48 -06:00
Sonny Jeon
f7429ec79b Cleaned up stepper and planner code.
- Added some compile-time error checking. Will add more in future
pushes to ensure settings are correct and within parameters that won't
break anything.

- Pushed some master branch changes with MEGA pin settings.

- Cleaned up planner code and comments to clarify some of the new
changes. Still much to do here.

- Cleaned up the new stepper code. May need to abstract some of the
segment buffer more to fix the feed holds (and integrate homing into
the main stepper routine). With what's planned, this should make the
stepper algorithm easier to attach other types of processes to it,
where it is now tightly integrated with the planner buffer and nothing
else.
2013-10-24 22:12:13 -06:00
Sonny Jeon
fe03216952 Merge pull request #279 from EliteEng/master
Changed Stepper Pins
2013-10-21 19:19:26 -07:00
Rob Brown
a2457c4d70 Changed Stepper Pins
Changed Stepper Pins so the Step Port Invert Mask matches the UNO
2013-10-18 10:06:07 +08:00
Sonny Jeon
9b426d0c91 Merge pull request #278 from EliteEng/master
Update Pin Change Interrupts on Mega 2560
2013-10-17 07:09:08 -07:00
Rob Brown
3e92fef3b4 Update Pin Change Interrupts so it works
PCIE1 - Interrupt 8 on the Mega is attached to USART0 RX so when any
serial communication was transmitted it was triggering the Reset
Interrupt
2013-10-17 17:05:08 +08:00
Sonny Jeon
0cb5756b53 Fine tuning of new stepper algorithm with protected planner. Adaptive step prediction for segment buffer.
- Cleaned up the new stepper algorithm code with more commenting and
better logic flow.

- The new segment buffer now predicts the number of steps each segment
should have to execute over about 8 milliseconds each (based on the
ACCELERATION_TICKS_PER_SECOND setting). So, for when the whole segment
buffer is full, the stepper algorithm has roughly 40 milliseconds of
steps queued before it needs to refilled by the main program.

- Readjusted the max supported step rate back to 30kHz from the lower
development 20kHz. Everything still works amazing great and the test
CNC machine still runs twice as fast with the new stepper algorithm and
planner.

- Upped the standard serial baudrate to 115200 baud, as it is clear
that the bottleneck is the serial interface. Will now support this, as
well as the old 9600 baud, in new firmware builds.
2013-10-14 21:21:56 -06:00
Sonny Jeon
8a10654b1c New stepper subsystem bug fixes.
- New stepper algorithm with the new optimized planner seems to be
working nearly twice as fast as the previous algorithm.

- For one, the planner computation overhead is probably a fraction of
what it used to be with the worst case being about half still.

- Secondly, anytime the planner plans back to the first executing
block, it no longer overwrites the block conditions and allows it to
complete without lost steps. So no matter if the streams slows, the
protected planner should keep the steppers moving without risk of lost
steps (although this still needs to be tested thoroughly and may
audibly sound weird when this happens.)

- It now seems that the bottleneck is the serial baudrate (which is
good!)
2013-10-12 10:35:26 -06:00
Sonny Jeon
805f0f219c Protected buffer works! Vast improvements to planner efficiency. Many things still broken with overhaul.
Development push. Lots still broken.

- Protected planner concept works! This is a critical precursor to
enabling feedrate overrides in allowing the planner buffer and the
stepper execution operate atomically. This is done through a
intermediary segment buffer.

- Still lots of work to be done, as this was a complete overhaul of the
planner and stepper subsystems. The code can be cleaned up quite a bit,
re-enabling some of the broken features like feed holds, and finishing
up some of the concepts

- Pushed some of the fixes from the master and edge branch to here, as
this will likely replace the edge branch when done.
2013-10-09 09:33:22 -06:00
Sonny Jeon
471a45a1b9 Merge pull request #263 from 0xPIT/master
remove mcu argument for avr-size in makefile as it is not present in GNU...
2013-08-25 11:08:08 -07:00
0xPIT
24280f95a5 remove mcu argument for avr-size in makefile as it is not present in GNU Binutils 2.22 2013-08-25 14:54:10 +02:00
Sonny Jeon
0894183991 Pin map definition cleanup. 2013-08-20 20:05:16 -06:00
Sonny Jeon
e24e67ffe2 Processor-independent pin mapping feature.
- Cleaned up and organized pin mapping concept by @elmom.

- pin_map.h allows for user-supplied pin mapping and port vector
definitions in a centralized file. With more processor types, more
definitions could be added.
2013-08-19 15:07:47 -06:00