Software Serial - GRBL - Machine Getting stuck

I am doing a XY plotter using CoreXY mechanism.

**The electronics is : **
Two Atmega 328, 1 reads Gcode from SD card and sends it via Software Serial to another Atmega which has GRBL 1.1 installed in it.

Using 2 A4988 Drivers to drive the Nema 17 stepper motors. Vref is 0.65a on both.

The Software:
Initially reads a setting File (which has all the settings of the CoreXY ... resets the coordinates to 0 after homing)
then it scans the directory Data for files (all the Gcode files will be stored here) and then reads one file by another and sends data to the Secondary ATmega328 via Software Serial.

The issues:
Initially the whole system was working correctly, it will scan the files, get the files list, run the settings.txt file, then once homing done, will get the first file, read it and send it to through Software Serial to the secondary ATMEGA328.

But, after a few workings, now while reading the data file, the carriage (XY) stops moving and freezes. When I use the serial print and via FTDI read the master Atmega, there is not any data reflecting on the Arduino com port.

Don't know why the system is getting stuck

Efforts made:
changes the driver - same problem
changes the Atmega's - same problem
Installed GRBL 0.9 - same problem

I have attached the setting file, and Arduino code on the Master ATMEGA 328

What can be done?

settings.txt (330 Bytes)

Sand_Art_Code.ino (6.67 KB)

Your SD-Card may be dying.

changed my SD card module too.

should I try a different SD card?

Try it.

What baud rate are you using for Software Serial?

I would not use Software Serial for a demanding job like that.

...R

I would agree with Robin here.

The once doing the work does have its normal serial available so ensure you are using that.
The one with the SD card "might" be able to use software serial but you should keep the baud rate lower.

Also what are your GRBL settings as some of them are critical and having them to high may also cause the issues that you see.

Some information seems to be missing from your post ?

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Robin2:
What baud rate are you using for Software Serial?

I would not use Software Serial for a demanding job like that.

...R

Using a software serial rate of 115200

ballscrewbob:
I would agree with Robin here.

The once doing the work does have its normal serial available so ensure you are using that.
The one with the SD card "might" be able to use software serial but you should keep the baud rate lower.

Also what are your GRBL settings as some of them are critical and having them to high may also cause the issues that you see.

Some information seems to be missing from your post ?

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

The settings of GRBL are in the Settings.txt file already enclosed. enclosed here again.
if I reduce the baud rate of the GRBL and software serial to 57600 will it help?

perikaruppan:
Using a software serial rate of 115200

Start at 9600 to see if that helps with the problem, 115200 may be too high for software serial to be reliable with a continuous stream.

If it does not help then the problem is possible elsewhere.

Also make sure you are not crabbing the whole rig.
Do a 10mm move and check the end to en measurements.
Then a 50mm move in the same direction and check again.
Repeat until you reach the end of travel.
There should be no more than 0.5 mm difference (preferably better) between each side the whole way across the range.

Also ensure belts are tensioned equally, too little and crabbing can happen
Too tight and stalls can occur.
Belt deflection comes in to play here as a rough guide to tension.

OP's GRBL settings.

$0=10
$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=3
$11=0.010
$12=0.002
$13=0
$20=0
$21=1
$22=1
$23=3
$24=25.000
$25=1500.000
$26=100
$27=2.000
$100=40.000
$101=40.000
$102=40.000
$110=1000.000
$111=1000.000
$112=1000.000
$120=75.000
$121=75.000
$122=75.000
$130=415.000
$131=415.000
$132=450.000
$X
M5
$H
G10 P0 L20 X0 Y0 Z0
G01 F2500

$25 is very high try a lower value 300 to start.
$26 should be default until you have it working so 250.
$100-101-102 seem particularly slow and you might want to increase those depending on the motors you are using but stock values will depend a little on the motor and the driver stepping mode.
Stock values here for NEMA 17 and the same driver are 800.
$120, 121, 122 also seem off. 25 is my value here.
I cannot say if your travels are correct or not as my machines are different to yours.

Your F factor may be a little high too so try reducing that to 1000 or lower.

You appear to have some settings missing so I presume you are on a lower version of GRBL.

ballscrewbob:
Start at 9600 to see if that helps with the problem, 115200 may be too high for software serial to be reliable with a continuous stream.

If it does not help then the problem is possible elsewhere.

Also make sure you are not crabbing the whole rig.
Do a 10mm move and check the end to en measurements.
Then a 50mm move in the same direction and check again.
Repeat until you reach the end of travel.
There should be no more than 0.5 mm difference (preferably better) between each side the whole way across the range.

Also ensure belts are tensioned equally, too little and crabbing can happen
Too tight and stalls can occur.
Belt deflection comes in to play here as a rough guide to tension.

OP's GRBL settings.

$0=10

$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=3
$11=0.010
$12=0.002
$13=0
$20=0
$21=1
$22=1
$23=3
$24=25.000
$25=1500.000
$26=100
$27=2.000
$100=40.000
$101=40.000
$102=40.000
$110=1000.000
$111=1000.000
$112=1000.000
$120=75.000
$121=75.000
$122=75.000
$130=415.000
$131=415.000
$132=450.000
$X
M5
$H
G10 P0 L20 X0 Y0 Z0
G01 F2500

Thanks for the input... I tried using 57600, it stalled
but one thing that I found out was if I am using the FTDI at the master Arduino to see the serial output, then the whole system is working fine.... when I remove the FTDI to see the serial output, and run the system as stand alone ... then its getting stalled.
will reduce the baud rate to 9600 and start there and see as suggested.

Add schematics of the working and non working methods so we can see what the real differences are.

ballscrewbob:
$25 is very high try a lower value 300 to start.
$26 should be default until you have it working so 250.
$100-101-102 seem particularly slow and you might want to increase those depending on the motors you are using but stock values will depend a little on the motor and the driver stepping mode.
Stock values here for NEMA 17 and the same driver are 800.
$120, 121, 122 also seem off. 25 is my value here.
I cannot say if your travels are correct or not as my machines are different to yours.

Your F factor may be a little high too so try reducing that to 1000 or lower.

You appear to have some settings missing so I presume you are on a lower version of GRBL.

#25 homing seek , works perfectly at that speed of 1500, ill try to reduce it to 300
#26 changed to 250
#100-102 : using a 20 teeth 2mm GT2 on a Nema 17 which has 200 steps per mm, so as per the calculations its 40 steps per mm
I am using GRBL version 1.1
travel distances are correct and I have measured on multiple angles.
Reduced F to 1000
Can you tell me what other settings am I missing?

will add the schematics and images shortly

That is for grbl 1.1 which I recommend

Use an Arduino Mega which has 3 spare Hardware Serial ports that can comfortably work at 115200 baud.

GRBL is complicated enough without messing it about with different baud rates.

...R

Thanks for your inputs.

I am looking at the costing of the ICs also of an Atmega328 and a 2560.

I have attached the schematics and also th working image of the product.

When I have the FTDI linked onto my computer to read the serial outputs, the whole system works perfectly.

But when removed is where the problem lies.. I added a slight delay of 15ms after reading each line from SD card and while sending the Gcode to the GRBL. but still no success... may b e an increased delay?

Still confused as to what the error might be.

Replace the SD card Also with an high speed one.

Schematic.pdf (18.2 KB)

More out of curiosity what size is the PSU and do you have the common ground in place between both boards ?

perikaruppan:
I am looking at the costing of the ICs also of an Atmega328 and a 2560.

I did not realise you are building your own PCB. The Atmega 2560 is only available as a surface mount device. If you would prefer a DIP chip then the Atmega 1284 has one spare HardwareSerial port

...R

For ~ 20 bucks you get an orangepi-nano -lts. it's capable for running linuxcnc on it's own, just add stepper drivers. Or you can get any raspberrypi and hock up an arduino to it's usb port. Anything is better than 2 arduinos + 1 sd-card.

Or get one of these $11 Mega boards, very compact.