Home › Forums › TinyG › TinyG Projects › Project direction–g-code generated on the fly?
- This topic has 2 replies, 2 voices, and was last updated 10 years ago by jlauer.
-
AuthorPosts
-
December 13, 2014 at 12:20 pm #7167epicycloidMember
Hi — I have an evolving idea that could use a TinyG if I could envision how to do it. Can someone give me some ideas where to start, or what to read, or possibly some direction?
I am working on a 2-axis “machine” that is mostly lathe-like (low RPM spindle, rotating cutter on a slide), where the spindle/mandrel is driven by one motor and a sliderest by another. I’m currently using a Teensy 3.1 for the brains (so think Arduino on steroids).
The current version is a set of “canned” functions, driven by a touchscreen UI. But each function is calculated on the fly, e.g. the user jogs to a starting point (both axes) and jogs to an end point (again, both axes), then says “go”. The calculations are carried out internally and motors execute the function. In the simplest example this would be cutting a spiral, by moving both axes in sync, but most functions are more complex mathematically.
My question is, is there an interface or approach that would let me generate the g-code required (on the Teensy), and then pass it to a TinyG, without exposing the g-code complexity or UI to the user?
I know nothing about JSON other than reading a little on this forum, and I don’t know what potential hiccups might occur if a user wasn’t actually interacting with the command stream through some TinyG-specific UI.
Has anyone done something like this with TinyG? Any suggestions on a direction to pursue?
Thanks,
–Jon
December 13, 2014 at 1:15 pm #7169epicycloidMemberWell, I sort of answered my own question with additional reading of Alden’s TinyG Communications Programming. Very humbling. I don’t know that my programming skills are up to the level to allow me to take advantage of the extensive programmatic interface.
Can anyone point me to any examples somewhere I can at least read through to get an idea just how complex this approach would really be?
Humbly,
–Jon
- This reply was modified 10 years ago by epicycloid.
December 13, 2014 at 9:17 pm #7172jlauerMemberWell, one idea would be to have ChiliPeppr be your glue. If the Teensy can show up as a serial port like an Arduino can, then check out some of the videos I’ve done where ChiliPeppr talks to the Arduino and the TinyG at the same time. This way you could read/write to the Teensy as well as read/write for the TinyG.
You could write a macro that generates the Gcode for what you want. Perhaps go into “recording” mode to grab your final positions after the jog. Store that in a javascript variable. Then go into “run” mode where you calculate out your steps and send them as normal Gcode via ChiliPeppr’s standard programmatic interface.
I suggest looking at all the sample macros in ChiliPeppr. There’s a few that will give you the code commands for what you want. For example, sending Gcode to TinyG is as simple as:
macro.sendSerial(“G0 X0 Y0\n”);Or, you could generate all your Gcode as a string and then send it into the Gcode widget to visualize it. Although the 3D viewer is meant for XYZ positions and with a lathe you won’t get your visual the way you want, but it still could be helpful.
Here’s the macro for injecting code generated Gcode into Gcode widget:
var gcodetxt = “(This is my gcode)\nG92\nG0 Z1\nG1 X10\nY10\nX0\nY0\n”;
var info = {
name: “My gcode file”,
lastModified: new Date()
};
// send event off as if the file was drag/dropped
chilipeppr.publish(“/com-chilipeppr-elem-dragdrop/ondropped”, gcodetxt, info); -
AuthorPosts
- You must be logged in to reply to this topic.