Grbl provides control pulses that control stepper motors. It connects to stepper drivers that actually drive the steppers. To connect a stepper driver you need to connect three wires from the Arduino to each controller board: Ground, Step and Direction. Step is pulsed once for each step the stepper should move. Direction indicates the direction of the step. By default Grbl holds Direction low for forward motion and high for reverse.
By default Grbl uses the AVR port D for stepping pulses. PD0, PD1 and PD2 is step signal for X, Y and Z axis respectively. PD3, PD4 and PD5 is direction signals accordingly. So e.g. for the X stepper controller you shoud connect Step to PD0 and Direction to PD3.
To make things simple, the Arduino is not marked according to AVR port-mnemonics. Referring to the chart below we see that PC0-PC5 corresponds to the pins named “analog input” 0-5.
The pin mapping is identical for atmega 328
If you need to – and you are building Grbl yourself – you can reassign all ports used by Grbl by editing config.h
. The relevant piece of code looks like this:
#define STEPPING_DDR DDRD
#define STEPPING_PORT PORTD
#define X_STEP_BIT 2
#define Y_STEP_BIT 3
#define Z_STEP_BIT 4
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 6
#define Z_DIRECTION_BIT 7
For performance reasons all step and direction-pins need to be on the same port, but you can pick port and bits at will. Make sure STEPPING_DDR and STEPPING_PORT point to the same port, and always do a full clean before you rebuild after changing config.h as changes in header-files will not automatically lead to recompilation of the affected units. Rebuild like this:
% make clean && make
Andre tekster | ||