[grbl Issue#1009] M3 M4 M5 commands

未分类 bolang 6个月前 (10-14) 52次浏览

Issue #1009 | 状态: 已关闭 | 作者: meatom | 创建时间: 2016-06-07


Hello,
I’ve been using my mini laser engraver with GRBL 0.9i, so decided to upgrade to version 0.9j.
The issue is that now the engraver does not turn the laser on with the M3/M03 command. To turn on the laser now I have to use M4, and M3 to turn off. The M5 command doesn’t make any effect.
I’ve measured the voltage at pin 13, that is hooked with an mosfet, and it just goes high with M4 command.
The user PCPayne openned the issue #949 with the same problem, but no solution was provided.
I tried to downgrade to version 0.9i but it still not working. Disabling/enabling the #DEFINE VARIABLESPINDLE and #DEFINE USESPINDLEDIRASENABLEPIN settings in config.h had no effect.
I tried with a different Arduino and measured the pin 13 but it doesn’t goes high with M3 command.


评论 (5)

#1 – chamnit 于 2016-06-07

@meatom : Pin 13 is the spindle direction pin. Not enable.

Recently, Grbl changed how spindle enable works to be compliant to the LinuxCNC g-code standard. You’ll need to set a spindle speed greater than zero and have M3/4 active to ensure that the spindle turns on. So if you have VARIABLESPINDLE and USESPINDLEDIRASENABLEPIN enabled, pin 13 will not turn on if spindle speed is zero.

If you have VARIABLE_SPINDLE disabled, the spindle enable pin moves from pin D11 to D12 and works as a simple on/off pin. In this case, it doesn’t require a S spindle speed word to turn on.


#2 – kardinal7 于 2016-07-25

I’m trying to put GRBL to control the spindle, and I kinda achieve that, but I can’t stop the spindle. I can change the spindle speed s500/s100 commands but the M5 command doesn’t work. is there any configuration to config the pin value on the stop situation?

Or else what is the pin value in stop situation.


#3 – chamnit 于 2016-07-25

@kardinal7 : Make sure you have your pin wired correctly. In v0.9, the spindle enable pin is on D12.


#4 – truvisual 于 2018-02-27

@chamnit :I’ve GRBL 1.1f on a Arduino Mega2560 + Ramps 1.4 and running LaserGRBL.
Can you help me please? It’s about PWM. M3/M4 and M5 command work, in that way, LaserGRBL says ok.
But only on and off is possible. The S command doesn’t work. I’ve read alot in the Internet about that.
I’m a absolute beginner in GRBL and Arduino.
The situation, when i type in M3/M4 or M5 it turns on and off. Same by s127 M3 or M3 s127…
But with full power. The PWM is on Servo Pin 4.

I got a 2,5W blue Laser with a Laserdriverboard (TTL) and 5V.
So, i can’t connect it to D9 or D8, because D9 and D8 are 12V.

In LaserGRBL M3/M4 and M5 are for the Laser, in my case, M3 etc. is to Servo Pin D4.
Where do i have to make any changes, that the Spindlespeed is taken effect of the commants S0, S127, S255 etc.?
Which are the keywords for the reason?
SPINDLEENABLE or SPINDLEPWM_???
I got the Lasers TTL on PIN D4, + on D4 and – on ground.
I put a multimeter on it, to messure the V. It’s always 5V

Here is a part of the cpu_map.h

// Define spindle enable and spindle direction output pins.
#define SPINDLEENABLEDDR DDRG
#define SPINDLEENABLEPORT PORTG
#define SPINDLEENABLEBIT 5 // 5 MEGA2560 Digital Pin 4 - Ramps 1.4 Servo 4 Signal pin
#define SPINDLEDIRECTIONDDR DDRE
#define SPINDLEDIRECTIONPORT PORTE
#define SPINDLEDIRECTIONBIT 3 // 3 MEGA2560 Digital Pin 5 - Ramps 1.4 Servo 3 Signal pin

// Define flood and mist coolant enable output pins.
#define COOLANTFLOODDDR DDRB
#define COOLANTFLOODPORT PORTB
#define COOLANTFLOODBIT 4 // MEGA2560 Digital Pin 10 - Ramps 1.4 12v output
#define COOLANTMISTDDR DDRH
#define COOLANTMISTPORT PORTH
#define COOLANTMISTBIT 6 // MEGA2560 Digital Pin 9 - Ramps 1.4 12v output

// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR DDRK
#define CONTROL_PIN PINK
#define CONTROL_PORT PORTK
#define CONTROLRESETBIT 1 // Pin A9 - RAMPS Aux 2 Port
#define CONTROLFEEDHOLD_BIT 2 // Pin A10 - RAMPS Aux 2 Port
#define CONTROLCYCLESTART_BIT 3 // Pin A11 - RAMPS Aux 2 Port
#define CONTROLSAFETYDOOR_BIT 4 // Pin A12 - RAMPS Aux 2 Port
#define CONTROL_INT PCIE2 // Pin change interrupt enable pin
#define CONTROLINTvect PCINT2_vect
#define CONTROL_PCMSK PCMSK2 // Pin change interrupt register
#define CONTROLMASK ((1<RESETBIT)|(1<FEEDHOLDBIT)|(1<CYCLESTARTBIT)|(1<SAFETYDOORBIT))

// Define probe switch input pin.
#define PROBE_DDR DDRK
#define PROBE_PIN PINK
#define PROBE_PORT PORTK
#define PROBE_BIT 7 // MEGA2560 Analog Pin 15
#define PROBEMASK (1<BIT)

// Advanced Configuration Below You should not need to touch these variables
// Set Timer up to use TIMER4B which is attached to Digital Pin 8 - Ramps 1.4 12v output with heat sink
#define SPINDLEPWMMAX_VALUE 1024.0 // 1024.0 Translates to about 1.9 kHz PWM frequency at 1/8 prescaler
#ifndef SPINDLEPWMMIN_VALUE
#define SPINDLEPWMMIN_VALUE 1 // Must be greater than zero.
#endif
#define SPINDLEPWMOFF_VALUE 0
#define SPINDLEPWMRANGE (SPINDLEPWMMAXVALUE-SPINDLEPWMMINVALUE)

//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLETCCRAREGISTER TCCR4A
#define SPINDLETCCRBREGISTER TCCR4B
#define SPINDLEOCRREGISTER OCR4C // OCR4C
#define SPINDLECOMBBIT COM4C1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLETCCRAINIT_MASK ((1<TCCRB
INIT_MASK ((1<OCRA
REGISTER OCR4A // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLEOCRATOPVALUE 0x0400 // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLEPWMDDR DDRH
#define SPINDLEPWMPORT PORTH // PORTH
#define SPINDLEPWMBIT 4 // 5 MEGA2560 Digital Pin 8

#endif


#5 – danielgimeno 于 2020-09-11

Hi there, I’m starting with commands M3 M4 and M5, with a RAMPS 1.5 on an Arduino Mega. My question is how can I select from gcode, the different ports (there are 4) in ramps. IS there a kind of “M3 port 1”?

Thank you Daniel.

update. Making deeper research I found out the command M340 would fit my needs. I hope grbl understand it


原始Issue: https://github.com/grbl/grbl/issues/1009

喜欢 (0)