Page 1 of 2
How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 10:32 am
by kyd2020
Hello everyone,
I was wondering if anyone has ever tried to use programming language (Python, C/C++, etc.) to generate Acorn-flavored G-code? I am doing 3D printing project using the Acorn CNC board, so I would like to automate the G-code generation and connect with the Acorn board. I know that Cura has the ability to connect with Mach3 and LinuxCNC, but not Acorn, so I want to try writing a slicing program connecting with Acorn board.
If anyone has ever tried this approach, please let me know. Any favorable response will be appreciated!
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 1:13 pm
by cncsnw
Yes, I do that sort of thing all the time. You just have to know how to open and write to a text file. And of course have a handle on the math and geometry for the task at hand....
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 2:53 pm
by GBCues
cncsnw wrote: ↑Mon Mar 09, 2020 1:13 pm
. . . . You just have to know how to open and write to a text file. And of course have a handle on the math and geometry for the task at hand....
That's a pretty big handle!!
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 3:03 pm
by tblough
Here's everything you need to know.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 3:53 pm
by Muzzer
The Fusion 360 post processor is written in Javascript and....generates Acorn flavour g code. Presumably the idea of using a higher level language to generate g code is intended to make the process easier - some form of GUI comes to mind. That may be called a CAM program, which Fusion 360 has too.
Loads of videos and tutorials on how to create / edit Fusion 360 post processors using Visual Studio Code etc. Speaking as a non-softie, it's actually fairly easy to pick up (Googling that might be a good place to start). If you really are intent on creating your own (browser-based?) front end, Javascript might be a good starting point and you could reuse a lot of existing work if you look into the Fusion body of work.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 8:54 pm
by cncsnw
Sometimes an external code generator, written with whatever programming tool is familiar and expedient, can be a helpful solution even for situations where the the geometry is trivial.
One of the first ones I wrote for a customer was a plasma deposition cycle: very much like the Intercon facing cycle, but without the unwanted header / end-of-program overhead; with better pass-width equalization; and with rounded corners for continuous movement. Trivial geometry, but it made the customer's life easier and made his machine run better.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Mon Mar 09, 2020 9:32 pm
by briuz
If you do any math, don't use floating point variables. You'll need to use integers and keep track of the decimal place. Otherwise, floating point errors will add up and your part will be way off.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Tue Mar 10, 2020 8:32 am
by eng199
briuz wrote: ↑Mon Mar 09, 2020 9:32 pm
If you do any math, don't use floating point variables. You'll need to use integers and keep track of the decimal place. Otherwise, floating point errors will add up and your part will be way off.
That humor is a little too dry even for my taste. I'm going with tblough's post for the win.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Tue Mar 10, 2020 9:24 am
by briuz
Sorry but I didn't mean to be humorous. I've done this and ran into the dimensions drifting due to an attempt to use floating point variables. So I had to do all the math with integers and make my own math functions.
eng199 wrote: ↑Tue Mar 10, 2020 8:32 am
briuz wrote: ↑Mon Mar 09, 2020 9:32 pm
If you do any math, don't use floating point variables. You'll need to use integers and keep track of the decimal place. Otherwise, floating point errors will add up and your part will be way off.
That humor is a little too dry even for my taste. I'm going with tblough's post for the win.
Re: How to use programming language to generate Acorn-flavored G-code?
Posted: Tue Mar 10, 2020 12:45 pm
by DannyB
briuz wrote: ↑Tue Mar 10, 2020 9:24 am
Sorry but I didn't mean to be humorous. I've done this and ran into the dimensions drifting due to an attempt to use floating point variables. So I had to do all the math with integers and make my own math functions.
eng199 wrote: ↑Tue Mar 10, 2020 8:32 am
briuz wrote: ↑Mon Mar 09, 2020 9:32 pm
If you do any math, don't use floating point variables. You'll need to use integers and keep track of the decimal place. Otherwise, floating point errors will add up and your part will be way off.
That humor is a little too dry even for my taste. I'm going with tblough's post for the win.
You can just use a proper multiprecision floating point library, like MPFR, and tell it the exact precision you need out of what calculations.
Alternatively, i suspect fixed precision decimal float suffices for almost all things we are talking about here.