You are not logged in.

#1 2017-08-27 21:23:17

achingbrain
Member
Registered: 2017-06-12
Posts: 15

Read build plate position from Grbl

Grbl v1.1 reports the current machine position when the `?` command is sent over the serial port.

E.g. say the build plate is at Z0 and I move it to Z10, then enter ? a few times.  The serial traffic looks like this (minus all the 'ok' messages):

G1 Z10 F100
?
<Run|MPos:0.000,0.000,1.180|FS:100,0|WCO:0.000,0.000,0.000>
?
<Run|MPos:0.000,0.000,2.673|FS:100,0>
?
<Run|MPos:0.000,0.000,4.098|FS:100,0>
?
<Run|MPos:0.000,0.000,6.383|FS:100,0>
?
<Run|MPos:0.000,0.000,8.265|FS:100,0>
?
<Idle|MPos:0.000,0.000,10.000|FS:0,0>

The machine position is reported above in the format Mpos:x,y,z

This could be a better option than delays or [[WaitForDoneMessage]] etc for synchronising movements.

Last edited by achingbrain (2017-08-27 21:23:39)

Offline

#2 2017-08-27 23:45:20

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,541

Re: Read build plate position from Grbl

Some firmwares such as tinyg also reports positioning data.

We have chosen [[WaitForDoneMessage]] over this method for couple of reasons.
1. As you could guess, it introduce delay to movement synchronization. We need to send ? command periodically and process result. Amount of delay depends on how fast we sends ? commands and receive the result.
2. There is no standard response, we need separate regex to parse correct value for each firmware, probably should have option to accept custom regex.
3. Positioning will delegated to RAMPS side instead of raspberry pi. Will make position recovery difficult after restart or crashes.
4. Having progress for movements is quite interesting but are only useful for long movements such as ones being used on CNC like equipment not 3D printers with couple of mm of movements.
5. Synchronizing couple of quick movements will be difficult without delegating positioning to RAMPS side.

At the end I think it could be useful to some users who does not want to use custom firmwares. But we never got request for this feature.

Instead of regex method we could have second more reliable method for synchronization.
[[Until ? <Idle|MPos:0.000,0.000,10.000|FS:0,0>]]
Keep sending the first command until we receive the response matching the second part.

Send command every 0.100s
[[Until 0.100 ? <Idle|MPos:0.000,0.000,10.000|FS:0,0>]]

Offline

#3 2017-08-28 08:45:46

achingbrain
Member
Registered: 2017-06-12
Posts: 15

Re: Read build plate position from Grbl

I think you might want to do some variable substitution in there like:

[[Until 0.100 ? <Idle|MPos:0.000,0.000,[[LayerPosition]]|FS:0,0>]]

Just as long as the comparison takes into account that [[LayerPosition]] might be 10 but the string displayed is 10.000.

As for a standard response, there is the M114 GCode command which reports the current position.  This would be preferable as it's part of the protocol and the output format seems to be well specified although Grbl doesn't support it.

Offline

#4 2017-08-28 09:42:40

achingbrain
Member
Registered: 2017-06-12
Posts: 15

Re: Read build plate position from Grbl

I've forked the Grbl repo and added support for the M114 command - is the NanoDLP source available anywhere so I can extend it to parse the response?  I'd like to make sure it works properly before submitting a PR to grbl.

I found this account but there's not much there.

Offline

#5 2017-08-28 11:39:20

achingbrain
Member
Registered: 2017-06-12
Posts: 15

Re: Read build plate position from Grbl

I was thinking to add something like:

[[WaitUntilZPosition 10.000]]

and/or

[[WaitUntilZPosition [[LayerPosition]]]]

Offline

#6 2017-08-28 19:04:18

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,541

Re: Read build plate position from Grbl

As mentioned we need custom regex to parse position. It will be complex for avg users.

Offline

Board footer

Powered by FluxBB