Home › Forums › TinyG › TinyG Projects › TinyG + Raspberry Pi
- This topic has 14 replies, 6 voices, and was last updated 10 years, 2 months ago by Zootalaws.
-
AuthorPosts
-
March 18, 2013 at 4:36 am #3881burnsbMember
In the beginning stages of building a cnc mill. Plan to use a Raspberry Pi as the front end.
In order to save on usb ports on the Rpi I connected the TinyG to the Rpi’s GPIO, bypassing the ftdi chip. They are both running at 3V logic levels. (The Rpi does recognize the usb connection, it comes up as /dev/ttyUSB0 and functions as below with minicom)
To do this, one must disable the Rpi boot and shell through serial. See here: http://elinux.org/RPi_Serial_Connection
Then at the command prompt enter:
sudo minicom -b 115200 -o -D /dev/ttyAMA0
Currently using minicom to spin motors and check things out. On the TinyG I set Enable CR on TX to $ec=1 to get better formatting from the TinyG.I powered up the TinyG after running minicom, as it supposedly sends modem initialization garbage upon being ran. I haven’t dug in and looked into this yet.
March 18, 2013 at 6:56 am #3883aldenMemberThat’s great. Thanks for documenting this. Please let us know how this project goes.
Alden
March 25, 2013 at 2:44 am #3948burnsbMemberGot python on the Rpi talking to the TinyG.
I should add that I’m using the Adafruit version of Raspbian, Occidentalis which has enhanced low-level hardware support.
After freeing up the uart as in my above post, install the python-serial routines. (Same process to install minicom, you must have network connection to install either of these. Although there are ways of doing it with manually downloaded packages)
At a command prompt enter:
<code>sudo apt-get install python-serial</code>
Before I was able to get python-serial to work I had to reboot the Rpi. I suspect that the port was not free due to prior minicom use.
In IDLE I created a new file. Note, don’t name it serial. It will try to import the current file if you do.
test code:
<code>
import serial
serialport = serial.Serial(“/dev/ttyAMA0”, 115200, timeout=0.5)
serialport.write(“\r”)
serialport.write(“?\r”)
response = serialport.readlines(None)
print str(response)
</code>When the port is opened by python, it sends the TinyG an x character. I haven’t figured out where this is coming from.
Next up is learning about JSON, how to use python’s JSON interpreter, and learning enough python to do what I want.I hope in the next few weeks to begin a blog with an overview of my garage/shop and journal the build process. Particularly relevant developments to the TinyG I will repost here if that is okay.
End goals:
I plan to build a CNC mill/printer. It will have removable heads such that either a milling spindle or 3d printer head may be used. When in milling configuration it will have available table mounted 4th axis for rotary milling capability. The bed will be mounted to the X axis, Y and Z axis on a bridge. Raspberry Pi based gui frontend for the TinyG incorporating the various features of CNC controls I like. I want to take from the feature sets of Fanuc, HAAS, Fadal, and even a couple of things from the Acramatic series. I want to build a pendant that in addition to a handwheel, controls most machine functions. Somewhat like the later Cincinnati or HAAS pendants. It will interface through spi to the Rpi.To these ends I have a Atlas 6″ lathe with milling attachment, and an asian floormount drill press, and various other power and hand tools. 4 3.4V 2.0A NEMA23 steppers in the 100 oz/in range.
May 30, 2013 at 7:38 pm #4155rickkayeMemberI am trying to control my TinyG from a Raspberry Pi. Unlike the OP, I am connecting them through a USB cable (/dev/ttyUSB0). Using minicom on the RP, I can’t get the TinyG to respond. When I press the reset button on the TinyG, minicom sees the TinyG output, so I know the connection is good. The TinyG also responds fine when I connect it to my Mac over USB.
I was wondering if you had any thoughts on what might be wrong. Thanks.
Rick
June 1, 2013 at 8:00 am #4157aldenMemberNot sure what’s going on. TinyG needs a standard 115,200 setup
– 115,200 baud, 8 data bits, 1 stop bit, no parity.If you are going to stream to it from the terminal emulator you should also enable XON/XOFF on both tinyg and the terminal emulator.
June 1, 2013 at 10:41 pm #4159rickkayeMemberYes, I had it set to 115,200 8N1. Since I couldn’t get minicom to work, I moved on to controlling the TinyG with a python script as burnsb described above. That worked perfectly. Then I just tried the command line command
echo g0x100 > /dev/ttyUSB0
and that worked. So, the minicom failure is still a mystery. Now, I will write a C program to control the TinyG which is my ultimate goal anyway.June 5, 2013 at 6:07 pm #4164aldenMemberGood news. Please let us know if you find out why minicom didn’t work.
-Alden
June 21, 2013 at 12:48 am #4206burnsbMemberSorry for the late post. Still working on this project. Currently have the Rpi talking json to the tg. Working on gui stuff with tkinter.
As far as minicom goes, I’ve quit using it. Instead I’ve been using miniterm:
pi@raspberrypi /usr/bin $ miniterm.py -e –cr /dev/ttyAMA0 115200- This reply was modified 11 years, 5 months ago by burnsb. Reason: formatting
June 22, 2013 at 6:21 pm #4221rickkayeMemberThanks for the update. miniterm works here over USB:
miniterm.py –cr /dev/ttyUSB0 115200
August 19, 2013 at 6:10 pm #4415laleeMemberWhen using Minicom, the easiest way to check that communications is working is to press Ctrl-X (“reset TinyG”), and possibly Ctrl-M and Ctrl-J to force a carriage-return and linefeed.
You should be able to get a response.
While Minicom is not an “official” method, I have found it to be usable enough to do ASCII uploads of GCode files with a few setting tweaks.
I have a writeup on my blog along with my thoughts on what may be a root-cause in the TinyG firmware preventing ASCII uploads via Minicom or even a “cat [filename] > /dev/ttyUSB0” from working.
In a nutshell, disabling echo, status verbosity, and text verbosity should keep the line free for TinyG to transmit flow-control characters unimpeded. If you want extra reliability, drop the baud rate to 38400.
- This reply was modified 11 years, 3 months ago by lalee. Reason: blog link got eaten by wp?
August 20, 2013 at 9:18 pm #4417lisemanMemberAny luck getting OctoPrint controlling a synthetos tinyg CNC via a raspberry pi? I’m seeing the output in ‘terminal’ when I issue commands by echoing directly over usb, but octoprint sticks at ‘connecting.’
August 20, 2013 at 9:51 pm #4418burnsbMemberlalee- very cool.
liseman- I’m not famillar with OctoPrint, but what distro are you using and what are your port settings?
I haven’t had much time to work on this lately (been doing piecework with my lathe on the weekends for extra money).
Last thing I did was getting a tinyg state loaded into python, i.e. all co-ords, active codes, etc. Having trouble with some sort of overflow. I’m at work and can’t remember exactly what the issue was, but it seemed to be an error on the pi side. I may try slowing down the baud as lalee suggests.
August 31, 2013 at 8:57 pm #4443laleeMemberI’ve not had experience with OctoPrint, so I can’t comment on that specifically. The requirements list for running it kind of turned me off.
I’ve had tough luck with Raspberry Pi. The linux usb driver (dwc_otg) is some of the shoddiest funk I’ve ever had the displeasure of fixing. Try running a HD webcam off the USB port, and the USB driver falls apart at the seams. It also doesn’t help that the RPi folks refuse to acknowledge there’s a problem, even though they’ve hired a guy to specifically work on that code since January. *Sigh*, hopefully it gets better soon.
At the moment, I’m knee-deep into enhancing the TinyG firmware to operate a ShapeOko/TinyG based 3D printer – at least something usable enough to print up the parts I need for my next machine. ‘Wish TinyG was MIT-licensed to continue forward with it on the next machine build, but can understand the desire to restrict commercial use. I’ll have to go clean-room for the next machine’s hardware/firmware combo.
Anyway, while glossing over the TinyG firmware code, I noticed the serial buffers are on the small side at only 256 bytes. After recompiling with each direction’s buffer bumped up to 1K, I seem to be getting reliable results at 115K on my v6.
September 1, 2013 at 1:39 am #4444burnsbMemberFwiw, I bypassed the usb on both the Rpi and the Tinyg, and instead used the Rpi and Tinyg uart. As they are both 3v logic I just connected up the two lines and ground. I did this because I didn’t want to add a usb hub to be able to use X.
It wouldn’t surprise me if the broadcom hardware uart was superior to the Raspbian software serial routines.
September 4, 2014 at 1:16 am #6708ZootalawsMemberSo… it’s been a year. How did this project end up?
I am just in the throes of building an OpenBuilds Ox and already have a couple of Pi’s around for Octoprinting my 3D printer, so am interested in the results.
Running tgFX for Tiny control would be the aim, connected over ethernet.
-
AuthorPosts
- You must be logged in to reply to this topic.