kennylevinsen / gocnc

CNC tool in Go
MIT License
66 stars 16 forks source link

This is exactly what I've been looking for...I get an error installing it....I'm new on GO and I'm not a programmer #10

Closed EzDuzitEZ closed 8 years ago

EzDuzitEZ commented 8 years ago

Hello Joushou,

Your program is exactly what I've been looking for. Your assistance will be greatly appreciated. I'm new to GO. I followed directions and they worked but I get this message about "CutterCompensation" as noted below:

C:\>go get github.com/joushou/gocnc
# github.com/joushou/gocnc/vm
Go\EZ\src\github.com\joushou\gocnc\vm\main.go:143: unknown State field 'CutterCompenstation' in struct literal

C:\>go get -u github.com/joushou/gocnc
# github.com/joushou/gocnc/vm
Go\EZ\src\github.com\joushou\gocnc\vm\main.go:143: unknown State field 'CutterCompenstation' in struct literal

C:\>cd \Go\EZ\src\github.com\joushou\gocnc\

C:\Go\EZ\src\github.com\joushou\gocnc>go build
# github.com/joushou/gocnc/vm
vm\main.go:143: unknown State field 'CutterCompenstation' in struct literal

C:\Go\EZ\src\github.com\joushou\gocnc>

Regards, Isidoro

kennylevinsen commented 8 years ago

Hi!

I had unfortunately messed up, and committed broken code (CutterCompensation, not CutterCompenstation!). It compiles now.

Feel free to try again. I recommend that you check your gcode with something like chillipeppr to make sure that the optimization passes aren't messing things up. Make sure that you don't see any "stray" movements that look like the cutter is going to crash into the material. I do not know of any such issues (I just fixed up optfloat, which could cause that kind of thing), but better be safe than sorry. Generally speaking, optlift and optvector are safe, optfloat and optdrill should be safe (set --drillfeed for that one), and optpath is very experimental - I wrote it to help speed up gcode from Easel, but easel may have changed, it the implementation is kind of tricky. It disables itself if it detects complicated gcode, but I haven't used it that much, as I switched over to Fusion360, which generally makes better gcode (and far too complicated gcode for optpath, anyway).

To check things, use the -o option to export the gcode, and throw it into the web tool chillipeppr (use the grbl or tinyg view - it doesn't matter which), and manually inspect the model.

Regarding Go, I hope you'll enjoy the ride, but note that gocnc was my first Go project (porting a similar, but simpler and much slower tool I had written in Python). The code is mildly speaking not the prettiest thing in the world. Feel free to hack around on it, but don't use it as a reference for pretty code!

EzDuzitEZ commented 8 years ago

Hello Joushou, Thanks for all the info. I really appreciate your program and the support. I hate to give you extra work but I ran into a different issue as noted below:

C:\>go get github.com/joushou/gocnc
# github.com/joushou/gocnc
Go\EZ\src\github.com\joushou\gocnc\main.go:430: undefined: syscall.SIGTSTP
Go\EZ\src\github.com\joushou\gocnc\main.go:438: undefined: syscall.SIGTSTP

C:\>go get -u github.com/joushou/gocnc
# github.com/joushou/gocnc
Go\EZ\src\github.com\joushou\gocnc\main.go:430: undefined: syscall.SIGTSTP
Go\EZ\src\github.com\joushou\gocnc\main.go:438: undefined: syscall.SIGTSTP

C:\Go\EZ\src\github.com\joushou\gocnc>go build
# github.com/joushou/gocnc
.\main.go:430: undefined: syscall.SIGTSTP
.\main.go:438: undefined: syscall.SIGTSTP

Thanks again!!

kennylevinsen commented 8 years ago

Right, that was a windows incompatibility. I just fixed that. On Unix platforms, ctrl-z would pause the gcode sender, but the signal that ctrl-z sends is not available on windows. I'd have to read keyboard input (necessary for future features anyway), but in the meanwhile, I have just disabled the ctrl-z feature for Windows, so that things compile.

Note that I have edited your messages in order to add code fences. See https://guides.github.com/features/mastering-markdown/ for more information about markdown syntax.

EzDuzitEZ commented 8 years ago

Hello again Joushou, Thanks for letting me know about that Markdown syntax. I couldn't figure out how to fix the format...lol

I'm using windows 10. Should I install something other than windows on my laptop to better run GO programs?

My apologies for giving you so much work. I got one more message similar to the previous ones :-(

C:>go get github.com/joushou/gocnc 
[# github.com/joushou/gocnc] 
Go\EZ\src\github.com\joushou\gocnc\main.go:428: undefined: registerSignals

C:>go get -u github.com/joushou/gocnc 
[# github.com/joushou/gocnc] 
Go\EZ\src\github.com\joushou\gocnc\main.go:428: undefined: registerSignals

C:\Go\EZ\src\github.com\joushou\gocnc>go build 
[# github.com/joushou/gocnc] 
.\main.go:428: undefined: registerSignals

Thanks again!!

kennylevinsen commented 8 years ago

Hi,

Sorry for the delay - I have been quite busy.

Yes, the issues you have experienced have all been because you ran Windows, which I never tested gocnc for. I should have solved all the issues by now, though (I can build for Windows myself) - Can you give it another go?

EzDuzitEZ commented 8 years ago

Hello Joushou,

I appreciate the support! It installed with no problems :-) but now I get a different message when executing commands as noted below:

C:\Go\EZ\src\github.com\joushou\gocnc>gocnc c:\work\test.txt
VM failed: line 6: Unsupported commands left in block: O1

C:\Go\EZ\src\github.com\joushou\gocnc>gocnc --optbogus c:\work\test.txt
VM failed: line 6: Unsupported commands left in block: O1

Thanks again!!!

kennylevinsen commented 8 years ago

Your gcode contains flow control codes. I have intended to implement static flow control evaluation, but it is not currently supported, mainly because I know of no gcode generators that generate flow control.

Where is your gcode from? It may be possible for you to avoid flow control. Is it very necessary

EDIT: Scratch that! It's just a program name. I read it as small o, which is flow control. I'll take a look.

kennylevinsen commented 8 years ago

gocnc should now ignore the program name (O1, which sets the name to "1"). Give it another shot!

EzDuzitEZ commented 8 years ago

Hello Joushou,

I can update the post processor to output the G-code in any format needed to run your program. I'm mostly interested in your program to "minimizes moves between sections of a job, kills redundant code, and just tries to make Grbl and the router waste less time"

This is the latest message:

C:\Go\EZ\src\github.com\joushou\gocnc>gocnc c:\work\test.txt
VM failed: line 4: Unsupported commands left in block: H9(.200 dia test tool=no dia comp)

This is the G-code in the test.txt file:

%
O0001
G54 H9 T9 M6 (.200 dia test tool=no dia comp)
G0 G15 X12000 Y0 S2000 M3 H1
G90 Z1000 M8
G1 Z0 F200
X10000
X100
X0
X-1000
X-2000
G0 Z1000
X1414 Y-1414
G1 Z0 F200
X0 Y0
X-7071 Y7071
X-8485 Y8485
G0 Z1000 M9
M2
%

Thanks again!!

kennylevinsen commented 8 years ago

Right. There were a few problems in that input. I just fixed things so that G15, which disables polar mode in Mach3 and therefore does nothing, is ignored (G16, which enables Mach3 polar mode, will throw an error).

The other issue is that you're issuing tool length index changes without G43. I am not sure if this is legal, and I have nothing to test behaviour against. If you skip the H's (you haven't enabled tool length offsetting anyway, which is done with G43), then thing should be fine.

Another thing to note is that you are not specifying the units in the gcode. gocnc assumes metric units in this case, and always explicitly export in metric, but it's a good idea to always include the unit in your gcode, as you never know what a machine defaults to.

For fun, this is your code when run through optvector:

(Exported by gocnc)
G21G90

M6 T9
G49
M3S2000
G94
G40
G0X12000
M8
G0Z1000
F200
G1Z0
X-2000
G0Z1000
X1414Y-1414
G1Z0
X-8485Y8485
M9
G0Z1000
X0Y0
M5
G0Z0

As you can see, it has removed a few of your move commands that had no effect. Your code was 212 bytes, and the output from gocnc is 151 bytes, but should do the exact same.

Note that this code is simple enough that the optimizations have no effect on run time. The reduced code size is useful if you're cutting fast, and your controller cannot parse input fast enough. Other optimisations, like optfloat which tries to ensure that you always move as fast as possible when above your material, or optlifts, which always make sure that Z lifts are rapid, have no effect on this simple test code, but can make a difference for very long jobs. optpath mainly helps when your code comes from makercam or easel, which, at least when I wrote gocnc, had terrible path planning.

(Ignore that gocnc puts a lot of things on empty lines - this is simply in order not to be too complicated in the exporter)

kennylevinsen commented 8 years ago

I have added an option, --allowremainingwords, which causes gocnc to just emit a warning instead of fail when there are unused words left in a block, such as a H-word without a G43 command. You can use that if you won't want to change your postprocessor.

EzDuzitEZ commented 8 years ago

Hello Joushou, The code is for very old Okuma CNC machines that don't use decimal points or G43 for offset and instead use G15 H(Offset #). When I first ran across this machines I thought the same thing. Specially not having the Cancel Canned cycles or prep codes...but that's the way it goes with these specific machines...lol

The changes you made solved any install/update/execute messages I was previously getting for Windows....now when I run the commands I get messages giving me status but the original file remains unchanged. Could you please tell me what I'm doing wrong? See below.

C:\Go\EZ\src\github.com\joushou\gocnc>gocnc --allowremainingwords test.txt
Metrics
[-------------------------]
   Moves: 18
   Feedrates (mm/min): 200
   ETA: 2h47m5s
   X (mm): -8485 <-> 12000
   Y (mm): -1414 <-> 8485
   Z (mm): 0 <-> 1000
[-------------------------]

C:\Go\EZ\src\github.com\joushou\gocnc>gocnc --optbogus test.txt
Metrics
[-------------------------]
   Moves: 18
   Feedrates (mm/min): 200
   ETA: 2h47m5s
   X (mm): -8485 <-> 12000
   Y (mm): -1414 <-> 8485
   Z (mm): 0 <-> 1000
[-------------------------]

C:\Go\EZ\src\github.com\joushou\gocnc>

Thanks again :-)

kennylevinsen commented 8 years ago

Hi,

You need to use the -o option to save the new file (gocnc can also send the code over a serial port to grbl or others, which is why -o is not the default). You also need --opt to enable optimizations. In your case, the command becomes:

gocnc --allowremainingwords --opt -o test-out.txt test.txt

--opt is the big optimization toggle - without this, no optimizations will occur regardless of other options. This toggle is there to ensure that people didn't accidentally use optimizations without understanding what they do. Using only this, you get the default optimizations, which means --optvector, --optfloat and --optlifts. --optvector is fancier than --optbogus. --optbogus only removes moves that have absolutely no effect on the output, where --optvector removes moves that make changes below a certain tolerance (defaults to 0.0003mm, but settable with --vtolerance), so optvector generally does more. You can replace --optvector with --optbogus using --no-optvector --optbogus.

Is it okay for you to not send G15Hn to your machine? That is, have you programmed tool length offsets into the machine? If you use the offsets, I'll have to make you an okuma exporter that sends G15Hn to your machine. Currently, gocnc sees G43Hn as a tool length change, and will output G43Hn as well. Unfortunately, it'll be a little tricky to make gocnc understand G15Hn as input, but if your postprocessor can send a G43Hn, I can make gocnc translate it to a G15Hn to your machine without an issue.

(Note that gocnc only sees G43Hn as a tool length change, and does not consider Hn to be a tool length change - it merely gives you a warning in this case. LinuxCNC and Mach3 documentation skimps a bit on this topic, but I think this is the correct behaviour.)

EzDuzitEZ commented 8 years ago

Awesome Joushou!! I got my first translated file....yeeeyy....no worries about the G43. It's easier to change the G43 than eliminating all Bogus Moves manually

I'm very impressed with what can be done on GO programming and I will definitely take those online classes after I'm done with this project I'm working on.

I would love to buy you some cold ones Joushou. You saved me tons of work with this program. There should be a PAYPAL thingy so people like me can contribute to developers :-)