Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
reprap:anet:anet_mainboard_overclocking [2018/01/04 02:36] – [Directions] gmarsh23 | reprap:anet:anet_mainboard_overclocking [2018/01/04 15:39] – [Crystal selection and replacement] gmarsh23 | ||
---|---|---|---|
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 | + | HEADS UP: This page is very much a 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' | ||
+ | |||
+ | 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 ==== | ||
- | * Why overclock? | + | |
- | * Is this reliable/ | + | |
- | * Requirements | + | * Is this reliable/ |
- | * Crystal selection | + | * Tools required |
- | * Directions | + | * Crystal selection |
- | * Crystal replacement | + | * Choosing a new crystal |
- | * Bootloader installation | + | * Replacing the crystal |
- | * Marlin firmware changes | + | * Updating bootloader |
+ | * Downloading and compiling Optiboot | ||
+ | | ||
+ | | ||
* platformio.ini | * platformio.ini | ||
* macros.h | * macros.h | ||
* pins_ANET_10.h | * pins_ANET_10.h | ||
* speed_lookuptable.h | * speed_lookuptable.h | ||
- | | + | |
- | * Potential issues | + | |
- | ==== Why overclock? | + | ==== Introduction ==== |
+ | |||
+ | === Why overclock? === | ||
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, | + | Additionally, |
The 12864 LCD that I have on the printer doesn' | The 12864 LCD that I have on the printer doesn' | ||
- | ==== Is this reliable/ | + | I could just buy a proper 32 bit board, that would fix this problem entirely, but that's no fun :) |
+ | |||
+ | === Is this reliable/ | ||
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, | 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, | ||
- | //Note that if you're mounting your printer in an enclosure for printing ABS or whatever, | + | //If you're mounting your printer in an enclosure for printing ABS or whatever, |
- | 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' | + | As far as safety goes, 3D printers by nature aren't safe, especially cheap printers like the A8. Even without this modification, |
- | ==== Tools required | + | === Tools required === |
- | To change the crystal, you will need soldering iron, solder (lead or lead free is fine) and solder wick. 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. |
- | Doing this modification requires updating | + | 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. |
- | ==== Crystal selection ==== | + | 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 " |
+ | |||
+ | ==== Crystal selection | ||
+ | |||
+ | === Choosing a new crystal | ||
The Anet V1.0 board requires a " | The Anet V1.0 board requires a " | ||
Line 52: | Line 67: | ||
| 20MHz | +25% | 0% | Maximum clock frequency officially supported by the Mega1284P. | | | 20MHz | +25% | 0% | Maximum clock frequency officially supported by the Mega1284P. | | ||
| **24MHz** | **+50%** | **+20%** | **What I successfully used on my own board.**\\ Can be salvaged from some USB devices (eg, high speed hubs) | | | **24MHz** | **+50%** | **+20%** | **What I successfully used on my own board.**\\ Can be salvaged from some USB devices (eg, high speed hubs) | | ||
- | | 25MHz | +56.25% | +25% | Slightly faster, might be OK.\\ Baud rate choices kinda suck (see note below)\\ Can be salvaged from devices with Ethernet (old motherboards, | + | | 25MHz | +56.25% | +25% | Slightly faster, might be OK.\\ Significant baud rate error (see below)\\ Can be salvaged from devices with Ethernet (old motherboards, |
- | | 27MHz | +68.8% | +35% | May be getting | + | | 27MHz | +68.8% | +35% | May be unstable.\\ significant |
- | Note that 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' | + | 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' |
^ MHz (below), baud (right) ^ 115200 ^ 230400 ^ 250000 ^ 460800 ^ 500000 ^ 921600 ^ 1000000 ^ 1500000 ^ | ^ MHz (below), baud (right) ^ 115200 ^ 230400 ^ 250000 ^ 460800 ^ 500000 ^ 921600 ^ 1000000 ^ 1500000 ^ | ||
| 16 | 2.1% | -3.5% | 0% | 8.5% | 0% | 8.5% | 0% | 33% | | | 16 | 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% | | | 20 | -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% | | + | | 24 | 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% | | | 25 | 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% | | | 27 | 1% | -2.3% | -3.6% | 4.6% | -3.6% | 8.4% | 12.5% | 12.5% | | ||
Line 66: | Line 81: | ||
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) | + | * UART divisor = crystal frequency |
- | * Actual baud rate = (Processor clock) | + | * Actual baud rate = crystal frequency |
+ | * Actual baud rate and desired baud rate should be +-5%, preferably +-2.5% | ||
+ | |||
+ | === Replacing the crystal === | ||
+ | |||
+ | Before replacing the crystal, I'd suggest doing the first step in " | ||
+ | |||
+ | Unplug your printer, disconnect all wiring, and remove the motherboard from your printer. | ||
+ | |||
+ | Desolder the existing crystal. Hot air and a pair of tweezers makes this very easy, as does using two soldering irons. But if you have just one iron, the best method is to apply two large blobs of solder to the joints at each end of the crystal, and move your iron back and forth between the two sides to try to get both sides simultaneously melted, very gently pulling up on the crystal when you do this. Eventually it will come loose, or you'll be able to get one end lifted up enough to clean under it with solder wick. | ||
+ | |||
+ | Clean up the crystal footprint pads on the PCB with solder wick, and apply a thin layer of fresh solder. Install the new crystal and solder both ends. | ||
+ | |||
+ | ==== Updating the bootloader ==== | ||
+ | |||
+ | Once the crystal is changed, put the control board back in your printer and connect ONLY the power input to the board; leave everything else disconnected for now. Connect your ISP programmer to the board. | ||
+ | |||
+ | === Downloading and compiling Optiboot === | ||
+ | |||
+ | You'll need to download and compile Optiboot first. More information can be found on the Optiboot github page: https:// | ||
+ | |||
+ | Use the following options to compile it for the Anet V1.0 board. Change the " | ||
+ | |||
+ | make AVR_FREQ=24000000L BAUD_RATE=57600 LED=A4 atmega1284p UART=0 | ||
+ | |||
+ | Save the .hex file for later. | ||
+ | |||
+ | === Backing up existing firmware === | ||
+ | |||
+ | Use AVRDUDE: | ||
+ | |||
+ | avrdude -p atmega1284p -c <your programmer> | ||
+ | |||
+ | === Flashing new firmware === | ||
+ | |||
+ | Use AVRDUDE: | ||
+ | |||
+ | avrdude -p atmega1284p -c <your programer> | ||
+ | |||
+ | Once the board is programmed, connect the board to your PC via its USB connection, and attempt to " | ||
+ | |||
+ | avrdude -c arduino -p m1284p -P COM1 -b 57600 -v | ||
+ | |||
+ | If everything goes well, you should see a screen that looks like this, indicating that the bootloader is up and running. | ||
+ | |||
+ | avrdude: AVR device initialized and ready to accept instructions | ||
+ | |||
+ | Reading | ################################################## | ||
+ | |||
+ | avrdude: Device signature = 0x1e9705 | ||
+ | avrdude: safemode: lfuse reads as 0 | ||
+ | avrdude: safemode: hfuse reads as 0 | ||
+ | avrdude: safemode: efuse reads as 0 | ||
+ | |||
+ | avrdude: safemode: lfuse reads as 0 | ||
+ | avrdude: safemode: hfuse reads as 0 | ||
+ | avrdude: safemode: efuse reads as 0 | ||
+ | avrdude: safemode: Fuses OK (E:00, H:00, L:00) | ||
+ | |||
+ | avrdude done. Thank you. | ||
+ | |||
+ | ==== Marlin changes ==== | ||
+ | |||
+ | 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 === | ||
+ | |||
+ | Find the following section of this file: | ||
+ | |||
+ | [env: | ||
+ | platform = atmelavr | ||
+ | framework = arduino | ||
+ | board = sanguino_atmega1284p | ||
+ | build_flags = ${common.build_flags} | ||
+ | upload_speed = 57600 | ||
+ | lib_deps = ${common.lib_deps} | ||
+ | |||
+ | Immediately after this section, add the following line. This tells the compiler what the new CPU frequency is. If you're using a crystal other than 24MHz, change the " | ||
+ | |||
+ | board_f_cpu = 24000000L | ||
+ | |||
+ | === Marlin/ | ||
+ | |||
+ | Find the following section: | ||
+ | |||
+ | #define DELAY_3_NOP DELAY_1_NOP; | ||
+ | #define DELAY_4_NOP DELAY_1_NOP; | ||
+ | #define DELAY_5_NOP DELAY_1_NOP; | ||
+ | |||
+ | Immediately after these lines, add the following: | ||
+ | |||
+ | #define DELAY_6_NOP DELAY_1_NOP; | ||
+ | #define DELAY_7_NOP DELAY_1_NOP; | ||
+ | #define DELAY_8_NOP DELAY_1_NOP; | ||
+ | #define DELAY_9_NOP DELAY_1_NOP; | ||
+ | |||
+ | Next find the following section: | ||
+ | |||
+ | #if CYCLES_PER_MICROSECOND == 16 | ||
+ | #define DELAY_1US DELAY_10_NOP; | ||
+ | #else | ||
+ | #define DELAY_1US DELAY_20_NOP | ||
+ | #endif | ||
+ | |||
+ | Add the two additional lines shown (the #elif line and the line after), with the " | ||
+ | |||
+ | #if CYCLES_PER_MICROSECOND == 16 | ||
+ | #define DELAY_1US DELAY_10_NOP; | ||
+ | #elif CYCLES_PER_MICROSECOND == 24 | ||
+ | #define DELAY_1US DELAY_20_NOP; | ||
+ | #else | ||
+ | #define DELAY_1US DELAY_20_NOP | ||
+ | #endif | ||
+ | |||
+ | === Marlin/ | ||
+ | |||
+ | 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. | ||
+ | |||
+ | Find the following three lines, these control how fast data is written to the LCD: | ||
+ | |||
+ | #define ST7920_DELAY_1 DELAY_0_NOP | ||
+ | #define ST7920_DELAY_2 DELAY_1_NOP | ||
+ | #define ST7920_DELAY_3 DELAY_2_NOP | ||
+ | |||
+ | Change them to the following values for 24MHz operation. If your display becomes glitchy or garbled, try adding 1 to the ST7920_DELAY_2 and ST7920_DELAY_3 settings. | ||
+ | |||
+ | #define ST7920_DELAY_1 DELAY_1_NOP | ||
+ | #define ST7920_DELAY_2 DELAY_3_NOP | ||
+ | #define ST7920_DELAY_3 DELAY_7_NOP | ||
+ | |||
+ | === Marlin/ | ||
+ | |||
+ | Marlin only comes with two lookup tables provided in this file, for operation at 16MHz and 20MHz. For other clock frequencies, | ||
+ | |||
+ | Here is a replacement for the file which has the 24MHz table added: https:// | ||
+ | |||
+ | To generate a table for a different frequency, Marlin provides a Python script in the buildroot/ | ||
- | ==== Directions ==== | + | python createSpeedLookupTable.py --cpu-freq 25 > new_table.h |
- | === Bootloader installation === | + | 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", |
- | === Crystal replacement | + | ==== 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 :) |