[教學] Arduino Mega 2560 + RAMPS1.4 + Marlin Firmware

本帖最後由 Offer 於 2014-9-6 14:53 編輯

以下是介紹使用Arduino Mega 2560 + RAMPS 1.4時一些設定及注意事項, 希望在本年內完成!

Marlin 支援的控制板有很多, 但此文我會用Arduino Mega 2560 + RAMPS1.4介紹一下

本帖最後由 Offer 於 2014-9-8 20:39 編輯

Marlin 是一套 3D printer firmware它是結合 sprinter 與 grbl 的功能亦是DIY 3D printer 主流的firmware之一

Arduino Mega 2560
http://arduino.cc/en/Main/arduinoBoardMega2560

RAMPS 1.4
http://reprap.org/wiki/RAMPS_1.4

LCD & SD Card Shield with Panel
http://reprap.org/wiki/RepRapDiscount_Smart_Controller

Marlin
http://reprap.org/wiki/Marlin

Arduino IDE Version 1.05
http://arduino.cc/en/Main/Software

TOP

本帖最後由 Offer 於 2015-2-10 23:00 編輯

先安裝Arduino IDE
Arduino IDE Version 1.05
http://arduino.cc/en/Main/Software

首先用 Arduino IDE 開啟 Marlin 的 project


打開Arduino IDE, 選Com port
Arduino Com Port.JPG

選Board
Arduino Board.JPG

Open Project
open.JPG


選Marlin.pde 或Marlin.ino
Openfile.JPG



下載Marlin源碼你會見這些file
Marlin firmware (我是用2 Jun 2013 Version 1.0.0 beta 1 )
https://github.com/ErikZalm/Marlin/tags
  1. cardreader.cpp
  2. cardreader.h
  3. Configuration.h
  4. ConfigurationStore.cpp
  5. ConfigurationStore.h
  6. Configuration_adv.h
  7. COPYING
  8. createTemperatureLookupMarlin.py
  9. create_speed_lookuptable.py
  10. DOGMbitmaps.h
  11. dogm_font_data_marlin.h
  12. dogm_lcd_implementation.h
  13. fastio.h
  14. language.h
  15. LCD Menu Tree.pdf
  16. LiquidCrystalRus.cpp
  17. LiquidCrystalRus.h
  18. Makefile
  19. Marlin.h
  20. Marlin.pde
  21. MarlinSerial.cpp
  22. MarlinSerial.h
  23. Marlin_main.cpp
  24. Menu Plans.xlsx
  25. motion_control.cpp
  26. motion_control.h
  27. pins.h
  28. planner.cpp
  29. planner.h
  30. Sd2Card.cpp
  31. Sd2Card.h
  32. Sd2PinMap.h
  33. SdBaseFile.cpp
  34. SdBaseFile.h
  35. SdFatConfig.h
  36. SdFatStructs.h
  37. SdFatUtil.cpp
  38. SdFatUtil.h
  39. SdFile.cpp
  40. SdFile.h
  41. SdInfo.h
  42. SdVolume.cpp
  43. SdVolume.h
  44. Servo.cpp
  45. Servo.h
  46. speed_lookuptable.h
  47. stepper.cpp
  48. stepper.h
  49. temperature.cpp
  50. temperature.h
  51. thermistortables.h
  52. ultralcd.cpp
  53. ultralcd.h
  54. ultralcd_implementation_hitachi_HD44780.h
  55. watchdog.cpp
  56. watchdog.h
複製代碼

TOP

本帖最後由 Offer 於 2014-9-7 20:50 編輯

Marlin架構

main lib
Configuration lib
plan motion lib
LCD lib
SD lib
Serial lib
Stepper lib
Temperature lib

RAMPS.jpg

TOP

本帖最後由 Offer 於 2015-1-21 20:17 編輯

在Configuration.h內,要依控制板的型號設定對應 MOTHERBOARD 的參數
  1. // SERIAL_PORT selects which serial port should be used for communication with the host.
  2. // This allows the connection of wireless adapters (for instance) to non-default port pins.
  3. // Serial port 0 is still used by the Arduino bootloader regardless of this setting.
  4. #define SERIAL_PORT 0

  5. // This determines the communication speed of the printer
  6. #define BAUDRATE 250000
  7. //#define BAUDRATE 115200

  8. //// The following define selects which electronics board you have. Please choose the one that matches your setup
  9. // 10 = Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics"
  10. // 11 = Gen7 v1.1, v1.2 = 11
  11. // 12 = Gen7 v1.3
  12. // 13 = Gen7 v1.4
  13. // 3  = MEGA/RAMPS up to 1.2 = 3
  14. // 33 = RAMPS 1.3 / 1.4 (Power outputs: Extruder, Bed, Fan)
  15. // 34 = RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
  16. // 4  = Duemilanove w/ ATMega328P pin assignment
  17. // 5  = Gen6
  18. // 51 = Gen6 deluxe
  19. // 6  = Sanguinololu < 1.2
  20. // 62 = Sanguinololu 1.2 and above
  21. // 63 = Melzi
  22. // 64 = STB V1.1
  23. // 7  = Ultimaker
  24. // 71 = Ultimaker (Older electronics. Pre 1.5.4. This is rare)
  25. // 8  = Teensylu
  26. // 80 = Rumba
  27. // 81 = Printrboard (AT90USB1286)
  28. // 82 = Brainwave (AT90USB646)
  29. // 9  = Gen3+
  30. // 70 = Megatronics
  31. // 701= Megatronics v2.0
  32. // 702= Minitronics v1.0
  33. // 90 = Alpha OMCA board
  34. // 91 = Final OMCA board
  35. // 301 = Rambo

  36. #ifndef MOTHERBOARD
  37. #define MOTHERBOARD 7
  38. #endif
複製代碼
改 MOTHERBOARD 由 7 成為 34, 因為我是使用RAMPS1.4
  1. #ifndef MOTHERBOARD
  2. #define MOTHERBOARD 34
  3. #endif
複製代碼
因為用上了LCD & SD Card 模組所以亦要改下面呢段//LCD and SD support
  1. //#define ULTRA_LCD  //general lcd support, also 16x2
  2. //#define DOGLCD  // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
  3. //#define SDSUPPORT // Enable SD Card Support in Hardware Console
  4. //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)

  5. //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
  6. //#define ULTIPANEL  //the ultipanel as on thingiverse

  7. // The RepRapDiscount Smart Controller (white PCB)
  8. // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
  9. //#define REPRAP_DISCOUNT_SMART_CONTROLLER

  10. // The GADGETS3D G3D LCD/SD Controller (blue PCB)
  11. // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel
  12. //#define G3D_PANEL

  13. // The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB)
  14. // http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
  15. //
  16. // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
  17. //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER

  18. // The RepRapWorld REPRAPWORLD_KEYPAD v1.1
  19. // http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
  20. //#define REPRAPWORLD_KEYPAD
  21. //#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click
複製代碼
把 //#define REPRAP_DISCOUNT_SMART_CONTROLLER前的"//" delete
  1. // The RepRapDiscount Smart Controller (white PCB)
  2. // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
  3. #define REPRAP_DISCOUNT_SMART_CONTROLLER
複製代碼
溫度探頭的設定要改#define TEMP_SENSOR_0,#define TEMP_SENSOR_1,#define TEMP_SENSOR_2,TEMP_SENSOR_BED
  1. //===========================================================================
  2. //=============================Thermal Settings  ============================
  3. //===========================================================================
  4. //
  5. //--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
  6. //
  7. //// Temperature sensor settings:
  8. // -2 is thermocouple with MAX6675 (only for sensor 0)
  9. // -1 is thermocouple with AD595
  10. // 0 is not used
  11. // 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
  12. // 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
  13. // 3 is mendel-parts thermistor (4.7k pullup)
  14. // 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
  15. // 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan) (4.7k pullup)
  16. // 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
  17. // 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
  18. // 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
  19. // 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
  20. // 10 is 100k RS thermistor 198-961 (4.7k pullup)
  21. //
  22. //    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
  23. //                          (but gives greater accuracy and more stable PID)
  24. // 51 is 100k thermistor - EPCOS (1k pullup)
  25. // 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
  26. // 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan) (1k pullup)

  27. #define TEMP_SENSOR_0 -1
  28. #define TEMP_SENSOR_1 0
  29. #define TEMP_SENSOR_2 0
  30. #define TEMP_SENSOR_BED 0
複製代碼
我會使用TEMP_SENSOR_0及TEMP_SENSOR_BED所以改為100k熱敏電阻(NTC)
  1. #define TEMP_SENSOR_0 10
  2. #define TEMP_SENSOR_1 0
  3. #define TEMP_SENSOR_2 0
  4. #define TEMP_SENSOR_BED 10
複製代碼
除左LCD不能作中文顯示其實在language.h 內的"#define LANGUAGE_CHOICE 1"改其他相應的數字便可
  1. // Languages
  2. // 1  English
  3. // 2  Polish
  4. // 3  French        (awaiting translation!)
  5. // 4  German
  6. // 5  Spanish
  7. // 6  Russian
  8. // 7  Italian
  9. // 8  Portuguese
  10. // 9  Finnish

  11. #ifndef LANGUAGE_CHOICE
  12. #define LANGUAGE_CHOICE 1  // Pick your language from the list above
  13. #endif
複製代碼
這是最低溫度保護的設定,基本上是合香港使用不用改,就算在北方有雪的地方使用室內溫度也不會太低吧!主要是預防測溫線短路
  1. // The minimal temperature defines the temperature below which the heater will not be enabled It is used
  2. // to check that the wiring to the thermistor is not broken.
  3. // Otherwise this would lead to the heater being powered on all the time.
  4. #define HEATER_0_MINTEMP 5
  5. #define HEATER_1_MINTEMP 5
  6. #define HEATER_2_MINTEMP 5
  7. #define BED_MINTEMP 5
複製代碼
這是最高溫度保護的設定,基本上是不用改,主要是預防測溫線開路或測溫元件移了位而不停加熱產生危險
  1. // When temperature exceeds max temp, your heater will be switched off.
  2. // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
  3. // You should use MINTEMP for thermistor short/failure protection.
  4. #define HEATER_0_MAXTEMP 275
  5. #define HEATER_1_MAXTEMP 275
  6. #define HEATER_2_MAXTEMP 275
  7. #define BED_MAXTEMP 150
複製代碼
#define EXTRUDE_MINTEMP 170是防止在170度以下時用家把擠出機驅動,如果在測試時你真的想在溫度不足情況下要轉動擠出機可把它改低一點
  1. //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
  2. //can be software-disabled for whatever purposes by
  3. #define PREVENT_DANGEROUS_EXTRUDE
  4. //if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately.
  5. #define PREVENT_LENGTHY_EXTRUDE

  6. #define EXTRUDE_MINTEMP 170
  7. #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
複製代碼
定義工作空間的參數 (單位為mm),如果你的heatbed不是205x205便要修改
  1. // Travel limits after homing
  2. #define X_MAX_POS 205
  3. #define X_MIN_POS 0
  4. #define Y_MAX_POS 205
  5. #define Y_MIN_POS 0
  6. #define Z_MAX_POS 200
  7. #define Z_MIN_POS 0
複製代碼
由於編碼器順時針轉動時LCD游標向上走不是我的習慣所以pins.h要改#define BTN_EN1 33 及
      #define BTN_EN2 31
  1.     #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
  2.       #define BEEPER 37

  3.       #define BTN_EN1 33
  4.       #define BTN_EN2 31
  5.       #define BTN_ENC 35
複製代碼

TOP

佔位用

請暫勿回覆

12345

TOP

佔位用

請暫勿回覆

1234

TOP

佔位用

請暫勿回覆

123

TOP

佔位用

請暫勿回覆

12

TOP

佔位用

請暫勿回覆

1

TOP