Hi All,
I'm working on a project where I would like to send G-Code from an Arduino Mega 2560 to the control board of a 3018 CNC running GRBL 1.1. This board has an 8 pin connector to an offline controller and I'm attempting to send G-code via these pins.
I have found the rx and tx pins on the control board and wired up the Arduino to those pins using SoftwareSerial. Once all is powered up , I get a message on the serial monitor saying "Grbl 1.1f ['$' for help]", so assume the rx bit is woking fine, however I can't seem to get anything I send to work, I've tried sending $, no response , $\n $\r $\n\r also some simple G-code G00 X1 Y1 Z0, nothing. (no "ok", no movment, no error message)
As a sanity check I connected to the grbl board via usb using PuTTy and was able to run typed commands. If I connect the offline controller to the 8 pin connector , it works fine.
I'm confused. The machine works using usb , offine controller, I get output when connected to the rx/tx pins, but can't make it execute commands, what am I missing here?
Thank you , I have amended the code and rewired the Arduino to use Rx/Tx 1 of the mega (pins 18 and 19). I still get the output from the grbl controller board "Grbl 1.1f ['$' for help]" and my input is echoed (for my serial input of $ I get a Serial1 output of $) , but no further reply .
Do you have an extra TTL-to-USB-converter that you could use to listen to the serial communication if you have connected the device which is able to communicate with the 3018 CNC-controller?
Or do you have a 24 MHz 8 channel logic analyser that could record the bitbanging on Rx/Tx ?
With the software SiRok-Pulseview you can analyse the recorded LOW/HIGHs to see each and every single byte that is sended / received.
One difference might be to send only carriagle return
or new line and carriage return or
only new line
or any other start / end-marking character
can putty be configured to print all characters in hexadecimal?
This This will eventually reveal whether non-printable characters are being sent
Hi,
Thank you for the reply, I don't have such equipment unfortunately.
Don't think PuTTy can print hex from communications, but I did try to capture USB data using Wireshark (USB Pcap) , but couldn't make much of it, granted I didn't spend a lot of time on it.
At 115200 bps each character takes 86 microseconds to receive, you add 10 milliseconds of delay.
In that time, more than 100 characters can be received, many of which will be lost due to reception buffer overflow.
At 9600 bps each character takes just over 1 millisecond to receive, you add 10 milliseconds of delay.
In that time 9 characters can be received and several can be lost quickly.
Why do you put those delays?
And what is the reason of having one side of the communication more than 10 times slower than the other (9600 vs 115200)?
Hi, Thank you for the amended code, appreciate your time and help. I tried running it and got the same results as before unfortunately.
The annoying thing is that I can control the darn thing every other way (using usb via G-code sender software and by connecting with PuTTy so no G-code sender, just manually typed commands, also the offline controller that came with the machine works fine using the same pins I'm trying to use) ... Also, I've seen that others have done a similar project successfully using a nano. See link https://www.instructables.com/GRBL-Offline-Controller/ . I don't need an lcd or keypad input as is shown in the link, ultimately, I would send G-code to the Arduino via Bluetooth, that I can do currently, and forward the instructions to the CNC. I thought I would develop the CNC communications part separately before introducing the BT into the mix to keep it simpler, but as it turns out I'm having trouble sending typed instructions to the CNC .....
Thank you for the reply, I had a read on GRBL interfacing on their github page. I can send grbl commands to the machine if I connect to it using PuTTy and it reacts as it's supposed to.
Thank you for the reply, there is no reason for the delays other than me getting desperate and thinking they would help. Thank you for the information though, it is helpful.
Hi, thank you for the help. I'll try and figure something out.
See image below with your code. Again, I get a response form the CNC but entering "$" on its own or by adding NL/CR or NL+CR, I don't get anything back. I'm probably missing something simple here, not sure what though.
You are using an arduino-mega 2560
You use a laptop
you use provisorical wiring.
That's all.
This does not help to analyse or narrow down the problem.
Do you at least understand what listening in parallel
to your laptop running putty directly connected to the 3018-control means?
You might not have the equipment for parallel listening but do you understand what it means?
Do you have another microcontroller? Yes / No
Do you have a 24 MHz 8 channel logic analyser? Yes/ No
Do you have an extra TTL-to-USB-COM-port adapter? Yes / No
For further narrowing down the problem you will need to analyse what the differencies between putty sending the commands
and
your arduino Mega is sending the commands
and this requires some kind of equipment like asked above
Another option might be to send a grbl-command using putty
and looking at the answer that comes back.
and then
connect your arduino-mega directly with putty and then to use putty to send the exact same character-sequence that putty received from the 3018-control
Just to explain the principle:
step putty send request to 3018-control
putty ---->--->--->----3018-control
putty receives an answer
putty ----<----<---<---3018-control-ANSWER
example:
3018-control-ANSWER might be "ABC987"
step 2.
Now connect putty with your arduino-mega
putty -->---->----ABC987--->-----Arduino-mega
and then print the received characters to the serial monitor
Hi StefanL38, thank you for the reply, lots of questions and info in there, I'll try and answer all:
The picture - only meant to show that I'm trying to use the code provided by kolaha and the response, nothing more, otherwise I would have provided closeups, but in summary, yest those are the things I'm using.
Do I understand what parallel listening is, well vaguely, I only got into this a few months ago.
Equipment:
Do I have another microcontroller? -> No
Do I have a logic analyser? -> No
Do I have a TTL to USB adapter? -> No
This is why I tried to use Wireshark with USBPcap, it can listen into USB communication.
In terms of analysing the problem, I understand the principle, and that is why I have used putty to send commands. Unlike a G-Code sender software which may add padding to the typed commands (like NL or CR), putty will only send what I type, so I know exactly what I'm sending.
I do the same with the Arduino, enter characters and wait for the reply.
The results thus far, both the Arduino and putty get the standard greeting from grbl "Grbl 1.1f ['$' for help]", however, while I am able to send commands via putty and they are executed, this is not the case with the Arduino. I type the command into serial monitor, hit enter and nothing, well actually I get an echo, but no reaction from the machine.
I will keep at it , I'm sure it's some oddball of a thing.
You have to connect GND, too, otherwise this will never work. And it could be that your GRBL board 5V line comes from USB, not from the powersupply, so you might want to check that, too.