reprap:anet:anet_mainboard_overclocking

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
reprap:anet:anet_mainboard_overclocking [2018/01/04 05:23] – [Updating the bootloader] gmarsh23reprap:anet:anet_mainboard_overclocking [2018/12/02 02:27] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ===== Anet Motherboard Overclocking ===== ===== Anet Motherboard Overclocking =====
  
-This page is a work in progress: I'm unfamiliar with the formatting syntax used on here, and I'm preparing this article over the span of a few days with the bit of free time I have availablePlease be patient :)+HEADS UP: This page is very much draft, and it's definitely not easy to follow at this point.
  
 +Also, my experience developing for Atmel AVR parts is done using AVR-GCC and/or Atmel Studio, and I haven't really picked up the proper 'Arduino way' of doing things. There's probably much more easy/elegant methods of doing the bootloader installation than I've explained here.
 +
 +This is a wiki, so feel free to expand on this article or make changes as you see fit.
 +
 +Thanks!
 ==== Table of Contents ==== ==== Table of Contents ====
  
Line 20: Line 25:
       * pins_ANET_10.h       * pins_ANET_10.h
       * speed_lookuptable.h       * speed_lookuptable.h
-  * Compile and install new firmware +  * Compile and install new Marlin firmware
-  * Potential issues+
  
 ==== Introduction ==== ==== Introduction ====
Line 29: Line 33:
 I overclocked my printer for fun, and to learn more about the guts of Marlin. I overclocked my printer for fun, and to learn more about the guts of Marlin.
  
-Additionally, my build now has a stiff AM8-inspired frame, higher stepper motor currents, etc... and is capable of printing well over 100mm/s, and I've reached the point where turning up the speed further results in the printer stuttering when going around corners, because the planner can't keep up.+Additionally, my build now has a stiff AM8-inspired frame, higher stepper motor currents, 0.5mm nozzle, etc... and is capable of printing with decent quality at speeds well above 100mm/sI reached the point where turning up the speed further results in the printer stuttering when going around corners, because the planner couldn't keep up.
  
 The 12864 LCD that I have on the printer doesn't help the situation either; it's well understood that having a graphic LCD on the printer slows down the printer, as sending pixels serially to the display takes away time from the planner. I could go back to the original character LCD display, but having a knob spoils me, and the Anet V1.0 card doesn't have sufficient I/O pins to hook up both a character LCD and a knob. The 12864 LCD that I have on the printer doesn't help the situation either; it's well understood that having a graphic LCD on the printer slows down the printer, as sending pixels serially to the display takes away time from the planner. I could go back to the original character LCD display, but having a knob spoils me, and the Anet V1.0 card doesn't have sufficient I/O pins to hook up both a character LCD and a knob.
 +
 +I could just buy a proper 32 bit board, that would fix this problem entirely, but that's no fun :)
  
 === Is this reliable/safe? === === Is this reliable/safe? ===
Line 37: Line 43:
 According to its datasheet, the ATMega1284P processor used on the Anet V1.0 motherboard is rated for 20MHz operation at the operating point of 125 degrees C and +4.5V. If you run the processor at a higher voltage (like the regulated +5.0V that the Anet motherboard provides) and a more reasonable operating temperature, the processor should be capable of running at a higher frequency while remaining stable. Overclocking a microcontroller isn't much different from overclocking a desktop CPU in this regard. According to its datasheet, the ATMega1284P processor used on the Anet V1.0 motherboard is rated for 20MHz operation at the operating point of 125 degrees C and +4.5V. If you run the processor at a higher voltage (like the regulated +5.0V that the Anet motherboard provides) and a more reasonable operating temperature, the processor should be capable of running at a higher frequency while remaining stable. Overclocking a microcontroller isn't much different from overclocking a desktop CPU in this regard.
  
-//If you're mounting your printer in an enclosure for printing ABS or whatever, this means you'll be running the processor much hotter. Overclocking the processor beyond 20MHz probably isn't a good idea.//+//If you're mounting your printer in an enclosure for printing ABS or whatever, this means you'll be running the processor in a much hotter ambient environment than normal. Overclocking the processor beyond 20MHz probably isn't a good idea in this case.//
  
-As far as safety goes, 3D printers by nature aren't safe, especially cheap printers like the A8. There's a chance your printer could malfunction and cause damage or injury, and doing this modification does not make the printer any safer. If the processor running on the printer crashes outright, Marlin uses the watchdog timer in the processor and should reboot. But it's possible that silent corruption of the processor's state could occur, and Marlin does not have any safeguards against this. **I can therefore make no guarantees of safety, and I'm not responsible for any bad consequences if your printer does something it shouldn't.**+As far as safety goes, 3D printers by nature aren't safe, especially cheap printers like the A8. Even without this modification, there's a chance your printer could malfunction and cause damage or injury, and doing this modification does not make the printer any safer. If the processor running on the printer crashes outright, Marlin uses the watchdog timer in the processor and should reboot. But it's possible that silent corruption of the processor's state could occur, and Marlin does not have any safeguards against this. **I can therefore make no guarantees of safety, and I'm not responsible for any bad consequences if your printer does something it shouldn't.**
  
 === Tools required === === Tools required ===
Line 45: Line 51:
 To change the crystal, you will need soldering iron, solder (lead or lead free is fine), solder wick, and a suitable place to work. Desoldering HC49S packages is a pain in the ass, having two irons or a hot air rework station greatly helps with getting the old crystal off. To change the crystal, you will need soldering iron, solder (lead or lead free is fine), solder wick, and a suitable place to work. Desoldering HC49S packages is a pain in the ass, having two irons or a hot air rework station greatly helps with getting the old crystal off.
  
-Having a power supply to power the control board outside of the printer during reflashing greatly helps, this lets you make sure that everything works before you reassemble your printer. The Anet board will run from a 9V to 15V supply.+Having a power supply to power the control board outside of the printer during reflashing is very convenient, this lets you make sure that everything works before you reassemble your printer. The Anet board will run from a 9V to 15V supply.
  
 Doing this modification requires updating the bootloader on the ATMega1284P chip, so you'll need an ISP capable programmer to do this. I suggest getting a USB ISP programmer which is supported by the "avrdude" application. Doing this modification requires updating the bootloader on the ATMega1284P chip, so you'll need an ISP capable programmer to do this. I suggest getting a USB ISP programmer which is supported by the "avrdude" application.
Line 53: Line 59:
 === Choosing a new crystal === === Choosing a new crystal ===
  
-The Anet V1.0 board requires a "HC-49S" surface mount crystal. Choose one with an 18 to 22pF load capacitance, as this best matches the load capacitance provided on the Anet board.+The Anet V1.0 board requires a "HC-49S" surface mount crystal. Choose one with a 12pf load capacitance, as this best matches the load capacitance provided on the Anet board.
  
 Here are some suitable crystal frequencies to choose from: Here are some suitable crystal frequencies to choose from:
Line 64: Line 70:
 | 27MHz | +68.8% | +35% | May be unstable.\\ significant baud rate error (see below)\\ Can be salvaged from video equipment (DVD players, etc) | | 27MHz | +68.8% | +35% | May be unstable.\\ significant baud rate error (see below)\\ Can be salvaged from video equipment (DVD players, etc) |
  
-If you're using the USB interface of the printer, using Octoprint for example, the crystal you choose affects how accurate the baud rate of the Mega1284P's UART will be at a given baud rate. For reliability reasons this should not exceed +-5%; ideally this value is less than +-2.5%. If you only printing from the SD card, this isn't an issue.+Note: If you're using the USB interface of the printer, using Octoprint for example, the crystal you choose affects how accurate the baud rate of the Mega1284P's UART will be at a given baud rate. For reliability reasons this should not exceed +-5%; ideally this value is less than +-2.5%. If you don't plan on using the printer's USB connection, this isn't an issue.
  
-MHz (below), baud (right) ^ 115200 ^ 230400 ^ 250000 ^ 460800 ^ 500000 ^ 921600 ^ 1000000 ^ 1500000 ^ +Crystal freq (below), baud (right) ^ 115200 ^ 230400 ^ 250000 ^ 460800 ^ 500000 ^ 921600 ^ 1000000 ^ 1500000 ^ 
-16 | 2.1% | -3.5% | 0% | 8.5% | 0% | 8.5% | 0% | 33% | +16MHz | 2.1% | -3.5% | 0% | //8.5%// | 0% | //8.5%// | 0% | //33%// 
-20 | -1.4% | -1.4% | 0% | 8.5% | 0% | -9.6% | -16.7% | -16.7% | +20MHz | -1.4% | -1.4% | 0% | //8.5%// | 0% | //-9.6%// //-16.7%// //-16.7%// 
-24 | 0.16% | 0.16% | 0% | -7.0% | **0%** | 8.5% | 0% | 0% | +24MHz | 0.16% | 0.16% | 0% | //-7.0%// | **0%** | //8.5%// | 0% | 0% | 
-25 | 0.5% | -3.1% | -3.8% | -3.1% | 4.2% | 13% | 4.2% | 4.2% | +25MHz | 0.5% | -3.1% | -3.8% | -3.1% | 4.2% | //13%// | 4.2% | 4.2% | 
-27 | 1% | -2.3% | -3.6% | 4.6% | -3.6% | 8.4% | 12.5% | 12.5% |+27MHz | 1% | -2.3% | -3.6% | 4.6% | -3.6% | //8.4%// //12.5%// //12.5%// |
  
 To calculate for different clock frequencies and baud rates, use the following math: To calculate for different clock frequencies and baud rates, use the following math:
  
-  * UART divisor = (Processor clock) / 8 / Desired baud rate +  * UART divisor = crystal frequency / 8 / Desired baud rate 
-  * Actual baud rate = (Processor clock) / 8 / rounded divisor value+  * Actual baud rate = crystal frequency / 8 / rounded divisor value
   * Actual baud rate and desired baud rate should be +-5%, preferably +-2.5%   * Actual baud rate and desired baud rate should be +-5%, preferably +-2.5%
  
Line 94: Line 100:
  
 === Downloading and compiling Optiboot === === Downloading and compiling Optiboot ===
 +
 +**If you're using a 24MHz crystal, just copy this paste and save it as a .hex file:** https://pastebin.com/Tv1EHPmc
  
 You'll need to download and compile Optiboot first. More information can be found on the Optiboot github page: https://github.com/Optiboot/optiboot/wiki/CompilingOptiboot You'll need to download and compile Optiboot first. More information can be found on the Optiboot github page: https://github.com/Optiboot/optiboot/wiki/CompilingOptiboot
Line 99: Line 107:
 Use the following options to compile it for the Anet V1.0 board. Change the "24000000" value to the frequency of the crystal you're using in Hz - don't forget the L on the end.  Use the following options to compile it for the Anet V1.0 board. Change the "24000000" value to the frequency of the crystal you're using in Hz - don't forget the L on the end. 
  
-  make AVR_FREQ=24000000L BAUD_RATE=57600 LED=A4 atmega1284p UART=0+  make AVR_FREQ=24000000L BAUD_RATE=57600 LED=A4 UART=0 atmega1284p
  
 Save the .hex file for later. Save the .hex file for later.
Line 111: Line 119:
 === Flashing new firmware === === Flashing new firmware ===
  
-Use AVRDUDE:+Use AVRDUDE to set the fuse/lockbit values on the processor, then program in the new bootloader: 
 + 
 +  avrdude -p atmega1284p -c <your programmer> -U hfuse:w:0xDE:m lfuse:w:0xf7:m efuse:w:0xfc:m lock:w:0x2f:
 +  avrdude -p atmega1284p -c <your programmer> -U flash:w:optiboot_atmega1284p.hex
  
-  avrdude -p atmega1284p -c <your programer> -U flash:w:optiboot_new.hex+The fuse values given move the bootloader start address to 0xFE00/0x1FC00 (word/byte) which frees up 3K of application space from the bootloader section. The lock bits prevent the bootloader from overwriting itself and bricking the board, if you send in a code image which is big enough to expand into the bootloader space.
  
 Once the board is programmed, connect the board to your PC via its USB connection, and attempt to "ping" the new bootloader with the following avrdude command. Change "COM1" to the serial port corresponding to the printer on your computer. Once the board is programmed, connect the board to your PC via its USB connection, and attempt to "ping" the new bootloader with the following avrdude command. Change "COM1" to the serial port corresponding to the printer on your computer.
Line 139: Line 150:
 ==== Marlin changes ==== ==== Marlin changes ====
  
-A number of files in Marlin have to be modified for operation at frequencies other than 16 or 20MHz.+A number of files in Marlin have to be modified for operation at frequencies other than 16 or 20MHz. This is in addition to the changes to the Configuration.h and Configuration_adv.h files.
  
 === platformio.ini === === platformio.ini ===
Line 172: Line 183:
   #define DELAY_9_NOP DELAY_1_NOP; DELAY_8_NOP   #define DELAY_9_NOP DELAY_1_NOP; DELAY_8_NOP
  
-Lastly, find the following section:+Next find the following section:
  
   #if CYCLES_PER_MICROSECOND == 16   #if CYCLES_PER_MICROSECOND == 16
Line 180: Line 191:
   #endif   #endif
  
-Add the two middle lines shown, with the values altered to correspond to the crystal frequency you've chosen. Here is the setting for 24MHz - Note that "DELAY_20_NOP" and "DELAY_4_NOP" add up to 24.+Add the two additional lines shown (the #elif line and the line after), with the "24" value altered to correspond to the crystal frequency you've chosen. Here is the setting for 24MHz - Note that "DELAY_20_NOP" and "DELAY_4_NOP" add up to 24. If you're using a frequency that isn't a multiple of 1MHz, then round up (eg, use 25 for a 24.576MHz crystal)
  
   #if CYCLES_PER_MICROSECOND == 16   #if CYCLES_PER_MICROSECOND == 16
Line 190: Line 201:
   #endif   #endif
  
-=== pins_ANET_10.h ===+=== Marlin/pins_ANET_10.h ===
  
 If you're using the stock A8 display, you can ignore this section. If you're using the full graphics display from the A6, this is required or else the display on the printer will be garbled. If you're using the stock A8 display, you can ignore this section. If you're using the full graphics display from the A6, this is required or else the display on the printer will be garbled.
Line 206: Line 217:
   #define ST7920_DELAY_3 DELAY_7_NOP   #define ST7920_DELAY_3 DELAY_7_NOP
  
 +=== Marlin/speed_lookuptable.h ===
 +
 +Marlin only comes with two lookup tables provided in this file, for operation at 16MHz and 20MHz. For other clock frequencies, a new stepper speed lookup table has to be added.
 +
 +Here is a replacement for the file which has the 24MHz table added: https://pastebin.com/KchhubLN
 +
 +To generate a table for a different frequency, Marlin provides a Python script in the buildroot/share/scripts which can be used to generate a new table. For example, to generate a table for 25MHz operation, use the following:
 +
 +  python createSpeedLookupTable.py --cpu-freq 25 > new_table.h
 +
 +If you're using a crystal frequency which isn't a multiple of 1MHz, you'll need to edit the script to remove the "* 1000000", and call the script with --cpu-freq <hz> instead.
 +
 +==== Compiling and installing new firmware ====
  
 +There are many guides online describing how to compile and install Marlin on an Anet A8. Find one and link it here :)
  • reprap/anet/anet_mainboard_overclocking.1515039824.txt.gz
  • Last modified: 2018/12/02 02:27
  • (external edit)