GCodeDriver with KFlop (and other oddball controllers)

204 views
Skip to first unread message

Bradley Parcels

unread,
Dec 3, 2017, 7:59:28 PM12/3/17
to OpenPnP
Hi all,
   I just put a bit of time into getting the GCodeDriver to play nice with KFlop, and thought I'd share my solution for those trying to do the same (either with a KFlop, or another oddball/unique controller). There were just 3 small changes required to make it work a treat:

1. KFlop requires carriage returns instead of newlines after each command to register anything at all
2. The scripting command for moves (accessible from the virtual COM port) requires all axes to be present regardless of them changing or not. (There are many other ways to interact with KFlop, some of which would allow for normal GCode... but by using the virtual com port, no other applications are needed, and it much more closely resembles "normal" OpenPNP solutions).
3. KFlop doesn't return any information as to when the move is complete (again - referring only to when using the vcom port scripting) ... To get this, we need to poll the controller to check when the motion is done.

These fixes for these are really pretty minor:
1. Added a "useCRinsteadOfNewline" boolean attribute to send "\r" instead of "\n" after commands
2. Added another boolean attribute "alwaysSendAllAxes" to simply disable the removal of unmodified axes
3. Added a "POLL_FOR_COMPLETE_COMMAND" which (when filled) works with the "MOVE_TO_COMPLETE_REGEX" to poll for completion status instead of just waiting idly.

With those changes in place, the commands/setup get pretty straightforward too... for example:
CONNECT_COMMAND:
Version
DefineCS = 0 1 2 -1 -1 -1

COMMAND_CONFIRM_REGEX
^Ready*

MOVE_TO_COMMAND:
Vel0={FeedRate:%.0f}
Vel1={FeedRate:%.0f}
Vel2={FeedRate:%.0f}
MoveXYZABC {X:%.4f} {Y:%.4f} {Z:%.4f} 0 0 0

POLL_FOR_COMPLETE_COMMAND:
CheckDoneXYZABC

MOVE_TO_COMPLETE_REGEX:
^1*

I'll attach the complete GCodeDriver.java and the driver section of Machine.xml, below... but with a few notes first:
- As you can see from the move command, I don't actually control my rotation axis with the KFlop (at least not yet)... but it will work just fine if you add the extra variables
- I haven't bothered with most of the other commands just yet (as I haven't finished changing all of my hardware), but I have tested setting/clearing bits, and that works just fine too
- The max feedrate set in the UI will actually be in units/second (i.e. mm/second) instead of the units/minute that the UI says it is... This would be an easy fix to scale, but I wanted to limit changes as much as possible, and I thought it was livable.

If there is call for it, I can send a pull request once I'm a bit more up to speed (I have a fair bit of coding experience, but I'm new to Java/Eclipse/OpenPNP coding, and have very limited experience with git)... Alternatively - feel free to incorporate whatever you like without waiting on me (again - really pretty limited changes, and it's based off the code pulled from GitHub yesterday). I just knew that if I didn't share this now, there would be a moderate-to-high possibility that something shiny would distract me, and it wouldn't get done for months (if at all).

Finally - as it's my first time posting around here, I just wanted to say a huge thanks to Jason and everyone else that has contributed so much to this project... I've been checking in on things occasionally for a year or two (without the time to really dig into things until now), and while it was hugely powerful and exciting even back then... the pace of improvement is just awesome!!! Keep up the great work!

Cheers,
Brad













DriverSection.XML
GcodeDriver.java

Jason von Nieda

unread,
Dec 4, 2017, 10:02:21 AM12/4/17
to ope...@googlegroups.com
Excellent work Bradley! I think we can probably integrate all of this with some minor changes. I’ll put it on the list. Thanks for sharing!

Jason
--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/ef7de0ed-aace-4145-99b2-ea0eb7195631%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason von Nieda

unread,
Dec 9, 2017, 4:40:57 PM12/9/17
to ope...@googlegroups.com
I've created an issue to track this work at https://github.com/openpnp/openpnp/issues/685

Bradley Parcels

unread,
Dec 13, 2017, 7:06:59 AM12/13/17
to OpenPnP
Looks great Jason - love the additional variables... more flexible (and less confusing) than my implementation!
Reply all
Reply to author
Forward
0 new messages