Welcome! Log In Create A New Profile

Advanced

G-Code Script

Posted by Suggy 
G-Code Script
April 12, 2017 04:57AM
Don't know if this should be in here or software as I'm not sure where the problem lies but this is my Question

Having trouble writing a start script for my printer, here’s my setup
Printer is same as a CTC beizer but running with Arduino with Ramp’s 1.4
All endstops are plugged into min, 1 hotend and HBP.


Sorry it is almost fully built but these are the only pic I have with me, on hols and printer is at home
When doing a G28 from Repetier-Host works as it should but I cannot get a script to work.
Bed heats up ok, hotend heats up ok, extruder ok, I have made it to start point and the middle of the build plate but when it starts to print it runs to the rear right of the bed and only prints half on and half off the bed.
I am using Simplify3D, is there something I may have missed in S3D?
This is the last script I tried is as follows

;****CTC Large***
G28
M140 ; hbp start
M190 ; wait for bed temp
M104 ; extruder temp start
M 109 ; wait for extruder temp
G1 X106 Y75 Z0 ; bed centre
; **** end of start.gcode ****

Setting in S3D
G-Code Tab
Update Machine Definition Ticked
Build Volume 206x150x250
Origin Offset 103x75x0
Homing Direction X-max Y-max Z-min
Flip Build Table Axis Y-ticked
Update Firmware Configuration UN TICKED?

It heats the bed and hotend before G28
Print area is 206mm x 150mm x 258mm
Using Marlin RC-7
Config h is as follows
Line 38 #ifndef CONFIGURATION_H
Line 39 #define CONFIGURATION_H
Line 52 #define CONFIGURATION_H_VERSION 010100
Line 89 #define STRING_CONFIG_H_AUTHOR "(none, default config)"
Line 90 #define SHOW_BOOTSCREEN
Line 91 #define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION
Line 92 #define STRING_SPLASH_LINE2 WEBSITE_URL
Line 112 #define SERIAL_PORT 0
Line 116 #define BAUDRATE 250000
Line 123 #ifndef MOTHERBOARD
Line 124 #define MOTHERBOARD BOARD_RAMPS_14_EFB
Line 125 #endif
Line 137 #define EXTRUDERS 1
Line 176 #define POWER_SUPPLY 2
Line 179 #define PS_DEFAULT_ON
Line 228#define TEMP_SENSOR_0 1
Line 229 #define TEMP_SENSOR_1 0
Line 230 #define TEMP_SENSOR_2 0
Line 231 #define TEMP_SENSOR_3 0
Line 232 #define TEMP_SENSOR_BED 1
Line 239 #define TEMP_RESIDENCY_TIME 10
Line 240 #define TEMP_HYSTERESIS 3
Line 241 #define TEMP_WINDOW 1
Line 244 #define TEMP_BED_RESIDENCY_TIME 10
Line 245 #define TEMP_BED_HYSTERESIS 3
Line 246 #define TEMP_BED_WINDOW 1
Line 251 #define HEATER_0_MINTEMP 5
Line 252 #define HEATER_1_MINTEMP 5
Line 253 #define HEATER_2_MINTEMP 5
Line 254 #define HEATER_3_MINTEMP 5
Line 255 #define BED_MINTEMP 5
Line 260 #define HEATER_0_MAXTEMP 275
Line 261 #define HEATER_1_MAXTEMP 275
Line 262#define HEATER_2_MAXTEMP 275
Line 263 #define HEATER_3_MAXTEMP 275
Line 264 #define BED_MAXTEMP 150
Line 272 #define PIDTEMP
Line 273 #define BANG_MAX 255
Line 274#define PID_MAX BANG_MAX
Line 275 #if ENABLED(PIDTEMP)
Line282 #define PID_FUNCTIONAL_RANGE 10
Line 284 #define PID_INTEGRAL_DRIVE_MAX PID_MAX
Line 285 #define K1 0.95
Line 289 #define DEFAULT_Kp 22.2
Line 290 #define DEFAULT_Ki 1.08
Line 291 #define DEFAULT_Kd 114
Line 303 #endif
Line 325 #define MAX_BED_POWER 255
Line 327 #if ENABLED(PIDTEMPBED)
Line 331 #define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER
Line 335 #define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER
Line 336 #define DEFAULT_bedKi .023
Line 337 #define DEFAULT_bedKd 305.4
Line 346 #endif
Line 352 #define PREVENT_DANGEROUS_EXTRUDE
Line 354#define PREVENT_LENGTHY_EXTRUDE
Line 356 #define EXTRUDE_MINTEMP 170
Line 357 #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH)
Line 375 #define THERMAL_PROTECTION_HOTENDS
Line 376 #define THERMAL_PROTECTION_BED
Line 401 #define USE_XMIN_PLUG
Line 402 #define USE_YMIN_PLUG
Line 403#define USE_ZMIN_PLUG
Line 409 #define ENDSTOPPULLUPS
Line 411 #if DISABLED(ENDSTOPPULLUPS)
Line 431 #define ENDSTOPPULLUP_XMAX
Line 414 #define ENDSTOPPULLUP_YMAX
Line 415 #define ENDSTOPPULLUP_ZMAX
Line 416 #define ENDSTOPPULLUP_XMIN
Line 417 #define ENDSTOPPULLUP_YMIN
Line 418 #define ENDSTOPPULLUP_ZMIN
Line 420 #endif
Line 423 #define X_MIN_ENDSTOP_INVERTING true
Line 424 #define Y_MIN_ENDSTOP_INVERTING true
Line 425 #define Z_MIN_ENDSTOP_INVERTING true
Line 426 #define X_MAX_ENDSTOP_INVERTING true
Line 427 #define Y_MAX_ENDSTOP_INVERTING true
Line 248 #define Z_MAX_ENDSTOP_INVERTING true
Line 429 #define Z_MIN_PROBE_ENDSTOP_INVERTING false
Line 572 #define DISABLE_E false
Line 573 #define DISABLE_INACTIVE_EXTRUDER true
Line 578 #define INVERT_X_DIR false
Line 579 #define INVERT_Y_DIR false
Line 580 #define INVERT_Z_DIR true
Line 585 #define INVERT_E0_DIR true
Line 586 #define INVERT_E1_DIR false
Line 587 #define INVERT_E2_DIR false
Line 588 #define INVERT_E3_DIR false
Line 598 #define X_HOME_DIR -1
Line 599 #define Y_HOME_DIR -1
Line 600 #define Z_HOME_DIR -1
Line 602 #define min_software_endstops true
Line 603 #define max_software_endstops true
Line 608 #define X_MIN_POS -46
Line 609 #define Y_MIN_POS 0
Line 610 #define Z_MIN_POS 0
Line 611 #define X_MAX_POS 206
Line 612 #define Y_MAX_POS 150
Line 613 #define Z_MAX_POS 258
Line 718 #define BED_CENTER_AT_149_75
Line 752 #define DEFAULT_AXIS_STEPS_PER_UNIT {80,80,3200,88.89}
Line 753 #define DEFAULT_MAX_FEEDRATE {300, 300, 5, 25}
Line 754 #define DEFAULT_MAX_ACCELERATION {3000,3000,100,10000}
Line 756 #define DEFAULT_ACCELERATION 3000
Line 757 #define DEFAULT_RETRACT_ACCELERATION 3000
Line 758 #define DEFAULT_TRAVEL_ACCELERATION 3000
Line 761 #define DEFAULT_XYJERK 20.0
Line 762 #define DEFAULT_ZJERK 0.4
Line 763 #define DEFAULT_EJERK 5.0
Line 793 #define HOST_KEEPALIVE_FEATURE
Line 794 #define DEFAULT_KEEPALIVE_INTERVAL 2
Line 814 #define PREHEAT_1_TEMP_HOTEND 180
Line 815 #define PREHEAT_1_TEMP_BED 70
Line 816 #define PREHEAT_1_FAN_SPEED 0
Line 818 #define PREHEAT_2_TEMP_HOTEND 240
Line 819 #define PREHEAT_2_TEMP_BED 110
Line 820 #define PREHEAT_2_FAN_SPEED 0
Line 909 #define PRINTJOB_TIMER_AUTOSTART
Line 921 #define PRINTCOUNTER
Line 939 #define LCD_LANGUAGE en
Line 963 #define DISPLAY_CHARSET_HD44780 JAPANESE
Line 984 #define SDSUPPORT
Line 1009#define ENCODER_PULSES_PER_STEP 1
Line 1015 #define ENCODER_STEPS_PER_MENU_ITEM 5
Line 1040 #define REVERSE_MENU_DIRECTION
Line 1047#define INDIVIDUAL_AXIS_HOMING_MENU
Line 1142 #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
Line 1253 #define SOFT_PWM_SCALE 0
Line 1290 #define SERVO_DELAY 300
Line 1311 #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75
Line 1313 #if ENABLED(FILAMENT_WIDTH_SENSOR)
Line1314 #define FILAMENT_SENSOR_EXTRUDER_NUM 0
Line 1315 #define MEASUREMENT_DELAY_CM 14
Line 1317 #define MEASURED_UPPER_LIMIT 3.30
Line 1318 #define MEASURED_LOWER_LIMIT 1.90
Line 1319 #define MAX_MEASUREMENT_DELAY 20
Line 1321 #define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA
Line 1325 #endif

I think I have cut out what is irrelevant, I think!
Re: G-Code Script
April 14, 2017 12:38AM
It almost sounds like you have a mis-match between your Configuration.h settings and the Slicer settings. It is important your slicer knows the exact #define X_MIN_POS, #define X_MAX_POS, #define Y_MIN_POS and #define Y_MAX_POS. If it doesn't have the right values, it is going to try to print the part off the bed.
Re: G-Code Script
April 14, 2017 07:58AM
Ok thanks
I'm using S3D 3.1.0 do you know where I need to enter the settings? Do I enter them in Global G-Code Offsets?
Re: G-Code Script
April 14, 2017 09:33AM
If you bring up Slic3r I can help you. I don't have Simplify 3D.
Re: G-Code Script
April 19, 2017 04:42AM
Coupla things.

You don't need

M140 & M190
M104 & M109

You just need M190 Stemp M109 Stemp and it will set the temp and wait for it.

I would guess that the first G1 X106 Y75 Z0 in the script moves the head to bed centre, then the S3D 'Origin Offset 103x75x0' moves it another 103x75 along. Probably get rid of one or the other.
I would think you would need a G28 home to endstops for the printer to know where it is
Why not just Home at 0,0?

Why is there Line 608 #define X_MIN_POS -46 ?

Regards
Re: G-Code Script
April 19, 2017 01:52PM
Ok thanks for the reply.
I hade

M140 & M190
M104 & M109
S3D stets the temp so I don't have to keep changing the Stemp in the script !

If I remove G1 X106 Y75 Z0 from the scrip it just goes to the rear right of the bed

Line 608 #define X_MIN_POS -46 ? Because the print nozzle when homed is 46mm away from the bed

Also if I use M109 S60 the printer don't turn on and I get Heating failed PRINTER HALTED Please reset
If I turn on the printer 1st then run from SD card the extruder heats up 1st

I have worked out a way of making it print from the center and that is to remove G1 X106 Y75 Z0 and to use Toolhead offsets (Tool 0) X 103.00 Y 75.00
This makes it print in the middle of the bed but on the print Preview Mode its at the rear right
Re: G-Code Script
April 20, 2017 08:53AM
Quote

Line 608 #define X_MIN_POS -46
Line 609 #define Y_MIN_POS 0
Line 610 #define Z_MIN_POS 0
Line 611 #define X_MAX_POS 206
Line 612 #define Y_MAX_POS 150
Line 613 #define Z_MAX_POS 258
Line 718 #define BED_CENTER_AT_149_75

This seems a bit of a contradiction, you say Xmin is -46 because at that position the nozzle is 46mm off the bed,so if X0 Y0 is the front left corner of the bed then the center of the bed should be 103_75.
Normally for a cartasian/core XY type printer i would expect the slicer origin to be set to the Z0 Y0 corner.
Re: G-Code Script
April 20, 2017 01:06PM
When all Axis are homed the extruder is to the rear right.

I have attached a diagram, this may help with the following!

Line 608 #define X_MIN_POS -46 Which is 46mm to the right of the bed
Line 609 #define Y_MIN_POS 0 Which is all the way to the rear
Line 610 #define Z_MIN_POS 0 Which is all the way to the top
Line 611 #define X_MAX_POS 206 Bed size 206 x 150
Line 612 #define Y_MAX_POS 150
Line 613 #define Z_MAX_POS 258 Which is all the way to the bottom
Line 718 #define BED_CENTER_AT_149_75 So half of 206 = 103+46 = 149, 75 bed center
Attachments:
open | download - Homeed diagram.png (19.5 KB)
Re: G-Code Script
April 24, 2017 10:22AM
I suppose your rear right is just front left upside down.


You say;
Line 608 #define X_MIN_POS -46 Which is 46mm to the right of the bed

But I believe those positions are travel limits after homing. ie It should home to 0,0 where the switch is, and then be +46 mm if anything. I don't think it would ever go to -46mm position because you have;

"define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS." enabled.


If your bed is 206 wide but 46mm away from the endstop, then X MAX should be 252mm



I think it makes it confusing using the middle of the bed and adding in the offsets
Can you move the endstop to the edge of the bed? ( or fit a bigger bed and make use of that extra 46mm? ) and work from a 0,0 position.



Minor point but I'm suprised at M109 Heating failed PRINTER HALTED. It may be to do with Configuration.adv.h

* If you get false positives for "Thermal Runaway" increase THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 40 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius

but if it works as you have it, it works.
Re: G-Code Script
April 24, 2017 02:04PM
Thanks for the reply, at the moment I have a standard 210x210 mk2 hbp, I intend on making it bigger but it will have to be custom made which bumps the price up, funds are limited at the moment due to bean of work ill for 8 weeks and being self-employed done get any sick pay.
I will try your suggestions when I get time and let you know the outcome.
Once again thanks for the help much appreciated
Re: G-Code Script
May 08, 2017 08:28PM
Hi Ed Would

Tried your suggestion and its still the same,
but thanks for the help anyway
Re: G-Code Script
May 25, 2017 05:39PM
Ed Would, Managed to get a mk2a bed 300x200mm amended the settings to
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS 281.5
#define Y_MAX_POS 157
#define Z_MAX_POS 248
limited by the extruder movement
#define BED_CENTER_AT_140.75_78.5

in S3D
Build volume
X 281.5
Y 157.0
Z 246

Origin Offset
X 140.75
Y 78.5
Z 0.0

Still went to the rear right to start print, but after 2 days off changing settings in the F/W and S3D I finaley sorted it out and it was so simple

Put all F/W setting back to what they were apart from the above bed/print area and in S3d put the Origin Offsets to
X 0.0
Y 0.0
Z 0.0
and hay presto its printing in the middle and the print preview is also in the middle.

But once again thanks for All the help and suggestions from all off you
Re: G-Code Script
June 02, 2017 10:05AM
you xmin should be "0" not "-46"
"-46" is your x offset - in other words how far away your hotend finishes from xmin when you home.
Sorry, only registered users may post in this forum.

Click here to login