GRBL using a TRUE serial port?? SO3 mod?

Discussion about the arduino based g-code interpreter, grbl
garetbiglow
Posts: 76
Joined: Fri Dec 26, 2014 6:33 pm

GRBL using a TRUE serial port?? SO3 mod?

Post by garetbiglow » Thu Jun 04, 2015 7:53 pm

I'm getting frustrated with the USB layer on the GRBL controllers. I think it's causing a number of issues due to the USB Serial emulation. I frequently have issues (~1 in 10 jobs) where the machine will bug out and stop during a job. The carbide motion software likes to freeze and loose connection with the controller after quitting a job as well. This buggy behavior is unacceptable when machining black walnut or zebra wood or something that costs 30-40 bucks for a piece. Especially when there is no elegant way to resume from the current position where the drop out occurred (quitting the job crashes the connection, requires a board reset and loses the coordinates). I really want to try talking direct with a true Serial port RS232 right to the RX and TX pins on the ATMEGA328 (obviously with signal conditioners to operate at the correct voltages). I can't think of a reason this would not work? I know I will need to use something like UGS 2.0.0 nightly or the Carbide Motion software in order to maintain the specific SO3 header or go back to a standard Arduino UNO + GRBL Shield + UGS 1.0.8 or something.

-Can anyone thing why this would not work? Honestly, I'm surprised more people don't discuss this instability. I have 3 machines with GRBL controllers on them, and they all seem to glitch out from time to time.

-I have routed my DWP611 power and the Carbide Motion power cables off one side of the machine, and the USB cable off the other side of the machine, so I'm pretty sure it's not noise related. The only refinement I can think of here would be to use ferite bead clamps on either end of the USB cable.

Any ideas? Thoughts?
SO3 #0196

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by cvoinescu » Thu Jun 04, 2015 8:03 pm

It will work. I've done it, and it does indeed solve the USB drops.

For the permanent solution, I opted to to use a cheap USB-to-serial converter followed by galvanic isolation. When completely isolated, USB does not drop anymore.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

Brian Stone
Posts: 295
Joined: Tue Oct 21, 2014 1:52 am
Location: Seattle, WA

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by Brian Stone » Thu Jun 04, 2015 10:28 pm

Specifically, what kind of isolation are you using. Opto-isolation? And is it a product, or did you make your own?
Shapeoko 2 #7353
1500x1000mm Shapeoko/X-Carve Hybrid, Nema-23's, Belt-Driven Z-Axis /w ACME Screw, Dewalt 611, Soundproof Enclosure
[Fusion 360 | Illustrator] -> Universal G-Code Sender

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by cvoinescu » Fri Jun 05, 2015 12:07 am

I tried both optocouplers (6N137) and a "digital isolator" (transformer-based, all integrated -- the Analog Devices ADuM1301, if I recall correctly). I did it on a breadboard first, then I designed a shield for the Arduino Uno that had a DC-DC converter to get 12 V for the Arduino VIN and for a fan out of the motor supply, a FTDI 232RL, and the ADuM isolator. The shield sat between the Arduino and the GAUPS or gShield, and you plugged the USB into it instead of the Arduino. It worked very well. I then got busy and did not pursue this (and I was not completely happy with the DC-DC converter circuit), but I still have two or three bare PCBs for it. (I posted about it on the forum, a while ago.)
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

garetbiglow
Posts: 76
Joined: Fri Dec 26, 2014 6:33 pm

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by garetbiglow » Tue Jun 09, 2015 5:15 pm

This is very interesting. So you isolated your supply voltage (+12) through a DC-DC converter, and used a cheap USB to Serial converter on your shield connecting one side to USB and the other to the TTL RX and TX pins on the atmega328? Is that right?

Isn't that still using a USB to serial conversion? One of the large problems with USB i've heard is that it's buffered, so for real time applications it isn't ideal. Using a standard COM port is not buffered, and is much better suited to this type of application. Feel free to disagree, I'm not 100% confident of my source for this information. I'm trying to find some good high level discussions on USB vs Serial, but have not come across anything yet.
SO3 #0196

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by cvoinescu » Tue Jun 09, 2015 6:54 pm

This is what I did: I connected USB to a cheap USB-to-serial adapter. I connected the serial side of that (TTL levels) to optocouplers (two transmitting, one receiving -- you need RX, TX and DTR). I wired the other side of the optocouplers into Arduino RX, TX, and RESET (via 100 nF capacitor). I powered the Arduino from the motor power supply, using a step-down DC-DC converter to 12 V into V_IN, also used for a fan (normally, the Arduino and the 5 V side of the motor drivers would be powered from USB, but that was now isolated). I made no connection at all between the USB side of things and the Arduino side, not even ground.

Yes, my arrangement still used USB-to-serial, but that, in itself, was not the problem. The ground loops or transients or interference or whatever electrical problems caused the USB to drop did not propagate through the galvanic isolation, and I had a 100% reliable USB connection to my machine.

Incidentally, because of how GRBL does flow control, buffering makes no difference; so while I agree with you in the general case, it doesn't matter here.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

garetbiglow
Posts: 76
Joined: Fri Dec 26, 2014 6:33 pm

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by garetbiglow » Tue Jun 09, 2015 11:11 pm

Ahhh, ok that makes a lot more sense. I'm working on a drawing to illustrate this. Another question for you:

Why is DTR important? I have used it in the past to program bootloaded atmega328's but I never really knew why I needed it?
SO3 #0196

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by cvoinescu » Tue Jun 09, 2015 11:49 pm

garetbiglow wrote:Ahhh, ok that makes a lot more sense. I'm working on a drawing to illustrate this.
I posted schematics and took part in long discussions on this back in the day -- if only I could find my own posts easily.
garetbiglow wrote:Why is DTR important? I have used it in the past to program bootloaded atmega328's but I never really knew why I needed it?
I was going to mention that, but I got distracted and I forgot. DTR is not important, except if you want to be able to upgrade the firmware easily via the isolated USB interface. You can still do it, but you have to start the upgrade process and quickly press RESET to start the bootloader on the Arduino. (Wiring the DTR gives the software on the PC a way to reset the Arduino to enter the bootloader automatically. That's all it does.)
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

garetbiglow
Posts: 76
Joined: Fri Dec 26, 2014 6:33 pm

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by garetbiglow » Wed Jun 10, 2015 3:40 am

Ahh ok, thats what I though. Typically I don't upload hex through the Arduino IDE, I just use the ISP header + AVRdude so the bootloader (and DTR to force a reset) is not needed.

So Carbide Motion got back to me and says that the Carbide Motion software needs the VID/PID from the USB section of the board (atmega16u2??). Using your concept, what if I build a board that sat between the USB cable and the USB port on the board? All it would do is optoisolate RX and TX, and dead end 5V and GND (the optoisolator being powered by the carbide motion side of the circuit). The PCB has it's own 5V supply already.

I really do think what I'm experiencing is a ground loop problem. My laptop power supply brick is ungrounded, but my monitor is grounded. As soon as i touch the VGA case to the VGA port on my laptop, I can hear the shapeoko stepper motors reset.

Alternatively, I might use a second laptop that I have, connect it only to the Shapeoko, and remote connect with my main computer. This also frees up my main computer for more solidworks and stuff while the Shapeoko is cutting.

Thoughts?
SO3 #0196

garetbiglow
Posts: 76
Joined: Fri Dec 26, 2014 6:33 pm

Re: GRBL using a TRUE serial port?? SO3 mod?

Post by garetbiglow » Wed Jun 10, 2015 3:54 am

Ah, it appears USB isolation is not so simple. Here's a chip that claims to do it however:

http://www.digikey.ca/product-detail/en ... ND/2183012
SO3 #0196

Post Reply