Welcome! Log In Create A New Profile

Advanced

Graphic LCD - show layer number

Posted by DaveOB 
Graphic LCD - show layer number
July 03, 2015 04:02PM
Hi all

New to 3D print ( 1 week now ) but a little experience with Arduino.

Just assembled a kit ( Prusa i3 ) and really loving this new 'toy'.

Have the RepRapDiscount Full Graphic Smart Controller connected to the Arduino and display is good.

But can not find anything online about adding the layer number to the display.

I understand that the Marlin firmware can't know the total number of layers ( unless it first counted them in the gcode file on the SD card ) but I do know from when I Sliced the job and created the gCode file how many layers I am expecting.

So what has to be changed in the code ( I assume for the Arduino ) so that the layer number ( let's use space for 3 digits ) at the bottom right of the screen ( so at the end of the message line ).

Should be simple to have an int variable declared ( int LayerCounter = 0 ) at the start of the print, and increase each time the Z axis is retracted, and displayed on the LCD.

Any of the gurus out there know what needs to be changed ?
Re: Graphic LCD - show layer number
July 03, 2015 04:23PM
There is a function that is called whenever a G1 and G0 gcode is received and the parameters include axis and mm. You can create a global var and each time that z changes you increase it and this is a layer counter.

Problem is if you use autobed level then Z is always changing.

There is also a function for lcd display of text.
Re: Graphic LCD - show layer number
July 03, 2015 04:25PM
Quote
thetazzbot
There is a function that is called whenever a G1 and G0 gcode is received and the parameters include axis and mm. You can create a global var and each time that z changes you increase it and this is a layer counter.

Problem is if you use autobed level then Z is always changing.

There is also a function for lcd display of text.

Many Thanks. That is what I am looking for.

Any chance you know the names of the functions, as my code knowledge is a bit limited to understand the structure of all the source code.
Re: Graphic LCD - show layer number
July 04, 2015 02:15AM
You canĀ“t use z-movement for layer count, when you have retraction enabled ( which is usually the case )
My gcode looks like this:
...
;Put printing message on LCD screen
M117 Printing...

;Layer count: 105
;LAYER:0
M107
G0 F7800 X66.891 Y47.995 Z0.150
...
G1 F1200 X56.275 Y114.117 E162.93272
;LAYER:1
M106 S84
G1 F3600 E158.43272
G1 Z0.350
Marlin "knows" the overall layercount and layerchange is also written in the code.
You just have to find a way to print it. Look for the calculation routine for the "xx % printed " part...
Re: Graphic LCD - show layer number
July 04, 2015 12:26PM
I just use z height and a calculator lol.

(Z height - First layer thickness) / layer height
Sorry, only registered users may post in this forum.

Click here to login