Integer movements?

436 views
Skip to first unread message

Mark Farver

unread,
Sep 21, 2016, 10:08:44 PM9/21/16
to ope...@googlegroups.com
Using the GCode driver is there a way to shift the decimal point? The
machine I'm trying to control works in solely in integers of 1/1000
inch.

I see that mils isn't a defined Length unit.

Jacob Christ

unread,
Sep 21, 2016, 10:18:02 PM9/21/16
to OpenPnP
From looking at this page:


And this setup

G0 {X:X%.4f} {Y:Y%.4f} {Z:Z%.4f} {Rotation:E%.4f} F{FeedRate:%.0f} ; Send standard Gcode move
M400 ; Wait for moves to complete before returning

My guess is that you need to make a custom driver that multiplies the XYZ values before sending them to the output.  But Jason might have something up his sleeve.  We use a Smoothie board and that is all done on the board.

Jacob


Jacob Christ
ProLinear/PONTECH, Inc.
+1 (909) 652-0670 Phone
http://www.pontech.com


--
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+unsubscribe@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/CACNU6M6-N-ZTf0oi%2BV5_ytyOyKvr3HMdB8rvN7Cp%3DkA5%2BLqYNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mark Farver

unread,
Sep 21, 2016, 10:40:29 PM9/21/16
to ope...@googlegroups.com
On Wed, Sep 21, 2016 at 10:18 PM, Jacob Christ <ja...@pontech.com> wrote:
> My guess is that you need to make a custom driver that multiplies the XYZ
> values before sending them to the output. But Jason might have something up
> his sleeve. We use a Smoothie board and that is all done on the board.

I figured that would be the case, but I thought I should check if
there wasn't an easier way first.

Mark Farver

Mark Harris

unread,
Sep 22, 2016, 12:23:30 AM9/22/16
to ope...@googlegroups.com
What controller are you using - thats a pretty odd requirement?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Mark Farver

unread,
Sep 22, 2016, 6:51:33 AM9/22/16
to ope...@googlegroups.com

On Sep 22, 2016 12:23 AM, "Mark Harris" <ma...@rris.com.au> wrote:
>
> What controller are you using - thats a pretty odd requirement?
>

I am trying to modernize an old (mid 1990s) era Quad 4c pick and place.  The original motion control board is closed loop using optical encoders and controlled serially, but it only works in integers.  Keeping it saves a lot of trouble, since it is already tied into the encoders and limits and I have full documentation for it. 

The undocumented Z80 powered embedded CPU board, the 25 year old vision system and the DOS based setup PC/download application get junked and replaced with OpenPNP.

Given the oddity of what I am doing I don't mind having to do a new driver, I just wanted to be sure there wasn't an alternative first.

Mark Farver

Jason von Nieda

unread,
Sep 22, 2016, 7:58:47 AM9/22/16
to ope...@googlegroups.com
Hang tight, I will have a solution for you in the next couple hours.
--
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.

Jason von Nieda

unread,
Sep 22, 2016, 10:57:12 AM9/22/16
to ope...@googlegroups.com
Mark,

I thought this would be a quick change, but maybe not. I was going to add Integer variables to the MOVE_TO_COMMAND that convert the values to ints instead of doubles, but that doesn't really solve the problem, right? Since if you told the machine to move to 0.1mm we'd end up just sending the value 0.

I think this can be solved one of two ways:

1. We can add mils as a unit of measure to the system. This is relatively easy, I think, although I'd have to imagine working in mils would be kind of a pain.
2. A custom or modified driver. Really all it would come down to is making a copy of the GcodeDriver, using the system in Inches mode and moving the decimal before sending the commands, as you said. This is probably the better option if you are a programmer. If this sounds like something that you are not able to take on, let me know, and I'll see if I can come up with something easier.

Jason

Mike Harrison

unread,
Sep 22, 2016, 11:02:40 AM9/22/16
to ope...@googlegroups.com
On Thu, 22 Sep 2016 14:57:01 +0000, you wrote:

>Mark,
>
>I thought this would be a quick change, but maybe not. I was going to add
>Integer variables to the MOVE_TO_COMMAND that convert the values to ints
>instead of doubles, but that doesn't really solve the problem, right? Since
>if you told the machine to move to 0.1mm we'd end up just sending the value
>0.
>
>I think this can be solved one of two ways:
>
>1. We can add mils as a unit of measure to the system. This is relatively
>easy, I think, although I'd have to imagine working in mils would be kind
>of a pain.

Maybe microns would be more sensible ?

evilwulfie

unread,
Sep 22, 2016, 11:23:37 AM9/22/16
to ope...@googlegroups.com
Us in the USA were taught to use mils. Everybody else uses microns.
If a change were to be made i would like to see both added as something
to pick from.
Yes us backwards folks in the US need to switch but old habits are hard
to break !

Jason von Nieda

unread,
Sep 22, 2016, 11:25:19 AM9/22/16
to ope...@googlegroups.com
Turns out this is actually easier than I thought. I'll release a new version tonight that supports both Mils and Microns. 

Currently I'm just planning to do this in the driver, not in the UI. Do people want the UI to work in Mils and Microns as well?

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.

Mark Farver

unread,
Sep 22, 2016, 11:43:56 AM9/22/16
to ope...@googlegroups.com
On Thu, Sep 22, 2016 at 10:57 AM, Jason von Nieda <ja...@vonnieda.org> wrote:
> I think this can be solved one of two ways:
>
> 1. We can add mils as a unit of measure to the system. This is relatively
> easy, I think, although I'd have to imagine working in mils would be kind of
> a pain.

Mils are pretty common in the industry. As I recall Centroid files
can be in mil, inch or mm. Eagle supports mils, mm, and inches, but
as I recall of of its internal calculations are done as integer values
with a resolution of 1/10000mm. (Which leads to some really weird
conversions some days.) Despite loathing English units I do a lot of
design entirely in mils as all of my board houses specify their hole
size, trace width etc limits in mils.

I don't know enough about the internal coordinate system used in
OpenPnP yet, but I would think that mils, mm, inches should all be
supported, and the system should know how to translate between them.

I can re-calibrate the machine to use measurements other than mils
(there is a configurable conversion factor between the encoders and
the units used) but it still only handles integers. The machine is
questionable accuracy below one mil, so truncating some smaller value
floating value would be acceptable.

Could you add a attribute to the machine configuration for conversion
factor? ie "<units>inches</units><machine_to_units_ratio>1000/1</machine_to_units_ratio>
The driver would then use that factor for converting between machine
units (when machine position is read) or when building a movement
command. the scope of that conversion would be limited to within the
GCode/machine driver itself.

Mark Farver

Jason von Nieda

unread,
Sep 22, 2016, 11:56:08 AM9/22/16
to ope...@googlegroups.com
This change is now pushed. If you download "Latest" from http://openpnp.org/downloads/ it will be there.

Here is what is changed:

* LengthUnit now supports Mils and Microns and converts between them and all the other supported units. 
* GcodeDriver already had support for converting to units before sending commands, so nothing changes there. We just needed these units supported.

So, to configure your driver, in machine.xml:

1. On the driver line look for the units attribute and change it to Mils. Mine looks like this after the change:
<driver class="org.openpnp.machine.reference.driver.GcodeDriver" port-name="/dev/tty.usbmodem1411" baud="115200" flow-control="Off" data-bits="Eight" stop-bits="One" parity="None" set-dtr="true" set-rts="false" units="Mils" max-feed-rate="1000" timeout-milliseconds="5000" connect-wait-time-milliseconds="1000">

2. Change your MOVE_TO_COMMAND from the default to something like this:
G0 {X:X%.0f} {Y:Y%.0f} {Z:Z%.0f} {Rotation:E%.0f} F{FeedRate:%.0f}

Note the use of %.0f as the format specifier. This tells the formatter to emit any number of digits to the left of the decimal, and no digits to the right of the decimal. Since there are no digits, it automatically omits the decimal.

The end result of this is that whatever unit you are using in the UI (currently Inches and Mms are supported), these will be converted to integer mils before being sent to the controller. Here is an example of the output from my test, with the above configuration:

10:51:11,771 DEBUG      ReferenceCamera moveTo((435.766362, 254.525412, NaN, 0.000000 mil), 0.51)
10:51:11,773 DEBUG          GcodeDriver sendCommand(G0 X436 Y255   F510, 5000)...
10:51:11,773 TRACE          GcodeDriver [/dev/tty.usbmodem1411] >> G0 X436 Y255   F510
10:51:11,779 TRACE          GcodeDriver [/dev/tty.usbmodem1411] << ok
10:51:11,779 DEBUG          GcodeDriver sendCommand(G0 X436 Y255   F510, 5000) => [<Idle,MPos:-331.93,252.49,0.73,-63.42>, ok]

I think that should get you going. Let me know if it doesn't.


Now, if folks want to support Mils, Microns and other stuff in the UI as well, that is a bigger change, although still not very big. But it would be a low priority for me since I think it's reasonable, for now, to work in Inches or Mms in the UI. If this is something you want, please file a feature request at https://github.com/openpnp/openpnp/issues

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.

Mark Farver

unread,
Sep 22, 2016, 7:37:20 PM9/22/16
to ope...@googlegroups.com
On Thu, Sep 22, 2016 at 11:55 AM, Jason von Nieda <ja...@vonnieda.org> wrote:
> * LengthUnit now supports Mils and Microns and converts between them and all
> the other supported units.
> * GcodeDriver already had support for converting to units before sending
> commands, so nothing changes there. We just needed these units supported.

Awesome. At first glance it appears to work just enough to get me to
the next issue.

The machine accepts commands like this (absolute motion, it can also
do relative moves):

Move X:
AA MA10000; GD;

Move Y:
AA MA,10000; GD;

Move Z:
AA MA,,1000; GD;

Move XY&Z
AA MA1000,1000,1000; GD;

This does not work:
AA MA1000,,; GD;

Basically, you aren't allowed to have commas for trailing, empty axis,
but you must have them for ones before. Is this another case of "You
should probably just write your own driver class?"

You can move single axis with a different prefix:
Move X: AX MA1000
Move Y: AY MA1000

This almost calls for a simple templating library like Ruby's ERB
library. Then the commands could have rudimentary code in them.

Mark

Jacob Christ

unread,
Sep 22, 2016, 7:44:35 PM9/22/16
to OpenPnP
Mark,

Any one of these should work:

AA MA {X:X%.0f}, {Y:Y%.0f}, {Z:Z%.0f}; GD;

Or...

AA MA{X:X%.0f}; GD;
AA MA,{Y:Y%.0f}; GD;
AA MA,,{Z:Z%.0f}; GD;

Or...

AX MA{X:X%.0f}; GD;
AY MA{Y:Y%.0f}; GD;
AZ MA{Z:Z%.0f}; GD;

Jacob


Jacob Christ
ProLinear/PONTECH, Inc.
+1 (909) 652-0670 Phone
http://www.pontech.com

--
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+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

Jacob Christ

unread,
Sep 22, 2016, 7:46:32 PM9/22/16
to OpenPnP
Mark,

OpenPNP always sends all axis positions in absolute positions with any move.  This can be frustrating if you start up OpenPNP and it thinks your machine is in a different location than what your controller thinks. Many crashes caused by this issue.

Jacob

Jacob Christ
ProLinear/PONTECH, Inc.
+1 (909) 652-0670 Phone
http://www.pontech.com

Mark Farver

unread,
Sep 22, 2016, 7:58:00 PM9/22/16
to ope...@googlegroups.com
On Thu, Sep 22, 2016 at 7:44 PM, Jacob Christ <ja...@pontech.com> wrote:
> Any one of these should work:
>
> AA MA {X:X%.0f}, {Y:Y%.0f}, {Z:Z%.0f}; GD;
>
> Or...
>
> AA MA{X:X%.0f}; GD;
> AA MA,{Y:Y%.0f}; GD;
> AA MA,,{Z:Z%.0f}; GD;

The first command is more or less what I attempted (minus the second
X/Y which seem to be literals) How does the above suppress the
trailing commas? I'll keep reading the format string stuff, might be
missing something obvious.

Mark

Jacob Christ

unread,
Sep 22, 2016, 8:10:56 PM9/22/16
to OpenPnP
Mark,

I maybe confused one what Open PNP sends an axis doesn't move.  I was assuming it always fills in a value.  Go with the second option.

Jacob

Jacob Christ
ProLinear/PONTECH, Inc.
+1 (909) 652-0670 Phone
http://www.pontech.com


Mark

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Jason von Nieda

unread,
Sep 22, 2016, 9:56:12 PM9/22/16
to OpenPnP
Mark,

Unfortunately I can't think of a way to do this offhand without code changes. I have been considering adding scripting support to the GcodeDriver, or possibly making a ScriptingDriver that would make this possible, but it's not something that will happen overnight.

If you are actively in the process of trying to get this machine up and running right now your best bet is probably to modify the GcodeDriver yourself. If you can come up with a set of changes that are useful in the general case, perhaps we could integrate them so you don't have to stay on your own fork.

Jason


On Thu, Sep 22, 2016 at 7:10 PM Jacob Christ <ja...@pontech.com> wrote:
Mark,

I maybe confused one what Open PNP sends an axis doesn't move.  I was assuming it always fills in a value.  Go with the second option.

Jacob

Jacob Christ
ProLinear/PONTECH, Inc.
+1 (909) 652-0670 Phone
http://www.pontech.com

On Thu, Sep 22, 2016 at 4:57 PM, Mark Farver <mfa...@mindbent.org> wrote:
On Thu, Sep 22, 2016 at 7:44 PM, Jacob Christ <ja...@pontech.com> wrote:
> Any one of these should work:
>
> AA MA {X:X%.0f}, {Y:Y%.0f}, {Z:Z%.0f}; GD;
>
> Or...
>
> AA MA{X:X%.0f}; GD;
> AA MA,{Y:Y%.0f}; GD;
> AA MA,,{Z:Z%.0f}; GD;

The first command is more or less what I attempted (minus the second
X/Y which seem to be literals) How does the above suppress the
trailing commas? I'll keep reading the format string stuff, might be
missing something obvious.

Mark

--
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.

--
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.

Miroslav Petrovic

unread,
Nov 22, 2021, 1:01:20 AM11/22/21
to OpenPnP
Hi Mark
I am newbabie to this forum (62 years old babie)  and having old quad machine (total of 2000 hours) it was flooded and controller is out of function. What is current situation with the use of your Quad? Is it in working condition? If Yes, can you share some idea for using openpnp retrofit. I am getting smoothieboard with arm processor and looking to keep as many hardware on the machine possible with exception op placing head for which I want dual head solution and top and bottom vision.
Can you give me your opinion on this ? ANY help will be highly appreciate.
Thank you
Miro  

ma...@makr.zone

unread,
Dec 1, 2021, 11:26:04 AM12/1/21
to OpenPnP
Just for the record: OpenPnP can now Force-send coordinates using the XF, YF, etc. variables.

See the Wiki:
Reply all
Reply to author
Forward
0 new messages