[SOLVED] Can you benevolently MITM UART (thinking grbl jog pendant direct to ATMEGA328P)
Simon Merrett wrote 01/06/2018 at 21:42 • 0 pointsSolution (for starters): https://hackaday.io/project/29627-grbl-man-in-the-middle-cnc-jog-pendant
I was looking at the options for putting a jog controller/pendant on a grbl machine. The latest versions of grbl have good support for a jog controller but it seems like you're dependent on the ability of your gcode sender program to receive keyboard strokes and send them to the ATMEGA328P.
I know you _could_ put an ATMEGA32U4 in HID role and go through the computer but can't we get the command going more directly to the machine controller?
I've had a quick crawl through stackexchange and it seems like you can't add two UART Tx sources to one Rx input. So can we put an ATMEGA between the computer and the grbl controller to receive computer gcode and forward it on to the grbl controller (using two serial ports). If a jog input is received, it buffers any incoming computer commands, tells the computer when the buffer is full, sends the jog command and then continues to send computer commands.
Any thoughts?
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I think Frank Herman had a similar project working a while back: https://github.com/xpix/XLCD/wiki/XLCD-Module-works-as-proxy-or-spy-on-serial-grbl-line.
Are you sure? yes | no
Yes, that's really similar - I suspect that it was different choice of search language that meant I didn't find it when I was looking. His is definitely more professional than my hacked one!
Are you sure? yes | no
Wired-Or?
https://en.wikipedia.org/wiki/Wired_logic_connection
(disclaimer: I don't know what a gerbil controller is, or why you would make it want to jog).
Are you sure? yes | no
Thanks, I'll give that a look. grbl is a cnc controller program. Jogging is moving the tool relative to the material from human commands, as opposed to moving it based on the gcode generated from a CAD file to make a part. You'd use it to initially line up the tool and the material if you don't have an automated method for this.
Are you sure? yes | no
Ah, I see now. OK, well wired-or will work, though you'll have to take into consideration the possibility of collisions if both things try to transmit at the same time. It might not matter if the use case is something 'use the jog controller; done. now use the other controller; done.'
For a more robust mechanism, you could put in a device to merge the two streams 'properly'. E.g., the ever-popular 'Blue Pill' board costs around USD$ 2 from China and has 3 UARTS, so it could receive, handshake, buffer and merge the data streams properly (presumably at the command protocol level). I guess, depending on what the 'jog controller' actually does, it might even be able to subsume that functionality.
Are you sure? yes | no