Hello community,
I'm trying to build a laser engraver. I have done the mechanical part but had a problem with grbl firmware. I have tried a lot of scenarios.
I'm using A4988 motor drivers and I have already set vRef. Used 12V PSU with adjustable amp.
Scenario 1
UNO + A4988 with test code => Works perfectly.
Scenario 2
UNO + A988 + Arduino Cnc Shield with test code => Works perfectly (So, there is no problem with my shield)
Scenario 3
UNO + 4988 with grbl => Not working
Scenario 4
UNO + 4988 + Cnc Shield with grbl => Not working
According to scenario results I have problem with grbl setup.
How do I setup grbl:
- Download src from GitHub - gnea/grbl: An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino
- Include library grbl-maser/grbl
- Examples /grbl/grblUpload
- Upload
Also tried same steps with old grbl 0.9 (GitHub - grbl/grbl: An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino)
How do I test grbl:
- Universal G Code Sender
- Laser GRBL
- GCodes like G21G92X-1 (via arduino serial monitor)
I'm sure that my motor wirings are correct, because it works on scenario 1 and scenario 2.
I'm sure that my motor driver is working, because it works on scenario 1 and scenario 2.
I can share my wirings if it's necessary to see them.
I have used 2,3,4 for step and 6, 7, 6 for direction pins. (I get these pins from grbl's cpu_map file)
Here's the test code that I have mentioned.
// Define stepper motor connections and steps per revolution for the X axis motor:
#define dirPin 5
#define stepPin 2
#define enablePin 8 // ******** name the enable pin
#define stepsPerRevolution 200
void setup()
{
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enablePin, OUTPUT); // ******** set the enable pinMode
digitalWrite(enablePin, LOW); // ******** enable the motors
}
void loop()
{
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
// Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < 5 * stepsPerRevolution; i++)
{
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
delay(1000);
// Set the spinning direction counterclockwise:
digitalWrite(dirPin, LOW);
//Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < 5 * stepsPerRevolution; i++)
{
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
delay(1000);
}