Installing the firmware

Previous step

Installing the firmware is fairly straight forward for anyone that has any experience with Arduino. Megatronics is basically a Arduino Mega 2560 and can be treated just like one.

or people unfamiliar with Arduino, the first step is to download the Arduino IDE on http://arduino.cc/. Simply follow the instructions on the site to download the latest version.

Download the firmware and open this firmware in Arduino. A program with 14 tabs should appear. If you use a megatronics V3, the firmware can be installed without any modification. A list for all the pin numbers on megatronics V2 is available upon request, Plan B was originally made with a V2.

[download firmware]

(Edit 16-12-2020: Firmware was updated to V0.07 to fix a problem that prevented the machine from printing files from the SD card)

The tabs that hold no relevant things to edit are:

  • Comments;
  • Heating;
  • Inputs;
  • Menu_structure;
  • Nozzle_commands;
  • Pause;
  • SD_write;

The remaining tabs hold settings to adjust motor directions, cartridge sizes, printer size, temperatures and other important information.

Alfa_V5_Megatronics_V3 (11):

The first part of the main window contains all of the pin numbers (commented) for all in and outputs. This can be used to check if everything is wired correctly, but can also be used to convert the pin numbers when you want to use another controller. Other than that, it contains no configurable values.

Alfa_V5_Megatronics_V3 (12):

The second part of the main window has some basic configurations.

  • X_print_speed (default = 60 [mm/s]): The speed at which the printer prints in normal printing mode. This value can’t be modified by itself, when changed, X_acceleration_distance in the printing tab also needs to change. Higher speeds will mean faster prints, but also less accuracy, risk of losing steps and potentially glitches. The speed of the micro controller is the main limiting factor here.
  • Travel_speed (default = 60 [mm/s]): The travel speed of the printer. Higher values mean faster travel, but increased risk of losing steps.
  • Single_nozzle_print_speed (default = 30 [mm/s]): The speed at which the printer prints ordinary G-code. A higher speed will decrease the accuracy and print quality significantly and increase the risk of losing steps.
  • Constant_movement_X_acceleration (default = 1000 [mm/s^2]):
  • Estimate_new_layer_time (default = 12000 [ms]): The time the printer estimates a new layer will cost. Is used to calculate the print time with.
  • Estimate_speed (default = 50 [mm/s]): The speed the printer uses to estimate printing time.
  • Printing_DPI (default = 96 [dots/per inch]): The DPI value of a cartridge (for the HP C6602, this is 96DPI)
  • Printing_double_direction_offset (default = 2 [steps]);
  • Printing_single_nozzle_print_nozzle (default = 0 [-]):

Buffer (21):

  • Buffer_size (default = 100 [-]): The buffer is where code read from the SD card is temporarily stored before printing. During normal movement and normal printing the buffer will not deplete, but when there are a lot on/off points close to each other, the buffer will start to deplete. A larger buffer will decrease the chance of the buffer completely draining, but will take a huge amount of RAM memory. Each buffer slot takes 12 Bytes of RAM, the AtMega2560 has 8kB.

Homing (31):

The first set of configurations are not really necessary when everything is the same. When a different amount of microsteps or different motors are used, these values need to be modified to match the microstepping current settings.

  • S_home_speed (default = 1000 [us]): The time of delay between each step of the stepper motor for the spreader axis.
  • S_home_backstep (default = 100 [steps]): The amount of steps the spreader will move forward after it found the endstop. The axis will move back to the endstop slowly after the backstep.
  • Y_extra_movement (default = 400 [steps]): The amount of steps the Y-axis moves forward extra to get out of the way of the spreader.
  • G_home_speed (default = 1000 [us]): The time of delay between each step of the stepper motor for the Gantry Both the X and the Y axis.
  • G_home_backstep (default = 50[steps]): The amount of steps the Gantry will move forward after it found the endstop. The axes will move back to the endstop slowly after the backstep.
  • F1_home_speed (default = 500[us]): The time of delay between each step of the stepper motor for the Feed 1 piston.
  • F1_home_backstep (default = 500 [steps]): The amount of steps the piston will move forward after it found the endstop. The piston will move back to the endstop slowly after the backstep.
  • F2_home_speed (default = 500[us]): The time of delay between each step of the stepper motor for the Feed 2 piston.
  • F2_home_backstep (default = 500 [steps]): The amount of steps the piston will move forward after it found the endstop. The piston will move back to the endstop slowly after the backstep.
  • B_home_speed (default = 500 [us]): The time of delay between each step of the stepper motor for the Build piston.
  • B_home_backstep (default = 500 [steps]): The amount of steps the piston will move forward after it found the endstop. The piston will move back to the endstop slowly after the backstep.
  • S_offset (default = -2000 [steps]): The amount of steps to the 0 point of the printer (in this case the corner closest to the endstop).
  • X_offset (default = -800 [steps]): The amount of steps to the 0 point of the printer (in this case the corner closest to the endstop).
  • Y_offset (default = -1000 [steps]): The amount of steps to the 0 point of the printer (in this case the corner closest to the endstop).
  • F1_offset (default = 0 [steps]): The amount of steps to the 0 point of the printer.
  • F2_offset (default = 0 [steps]): The amount of steps to the 0 point of the printer.
  • B_offset (default = 0 [steps]): The amount of steps to the 0 point of the printer.

Motor_commands (41):

  • Invert_X: Inverts the direction of the X-motor (1) or not (0).
  • Invert_Y: Inverts the direction of the Y-motor (1) or not (0).
  • Invert_S: Inverts the direction of the S-motor (1) or not (0).
  • Invert_F1: Inverts the direction of the F1-motor (1) or not (0).
  • Invert_F2: Inverts the direction of the F2-motor (1) or not (0).
  • Invert_B: Inverts the direction of the B-motor (1) or not (0).

Movements (51):

  • X_steps_per_mm (default = 20 [steps/mm]): The amount of steps needed to move the axis 1mm.
  • Y_steps_per_mm (default = 20 [steps/mm]): The amount of steps needed to move the axis 1mm.
  • S_steps_per_mm (default = 20 [steps/mm]): The amount of steps needed to move the axis 1mm.
  • Piston_steps_per_mm (default = 20 [steps/mm]): The amount of steps needed to move the axis 1mm.
  • G_max_speed (default = 150 [mm/s]): The maximum speed of the gantry.
  •  NL_spreader_feed_speed (default = 75 [mm/s]): The speed at which the spreader will move over anything that is not printed part.
  • NL_spreader_build_speed (default = 30 [mm/s]): The speed at which the spreader will move the  printed part.
  • NL_gantry_speed (default = 60 [mm/s]): The speed at which the gantry moves while the printer deposits a new layer.
  • NL_piston_speed (default = 1 [mm/s]): The speed at which the piston moves while the printer deposits a new layer.
  • NL_piston_overfeed (default = 1 [10um]): The distance the active feed piston moves up extra to accommodate any material loss.
  • NL_opposite_piston_down_distance (default = 50 [10um]): The distance the opposite piston moves down to catch any excess powder.
  • S_travel_distance (default = 260 [mm]): The distance the spreader has to move from the 0 point (NOT the homing point) to reach the end of it’s reach.
  • S_slowdown_F1_position (default = 0 [10um]): The distance from feed 1 to the build box, used to determine the default slowdown location.
  • S_slowdown_F2_position (default = 15000 [10um]): The distance from feed 2 to the build box, used to determine the default slowdown location.
  • S_slowdown_margin (default = 3000 [10um]): The extra distance from any printed the part the spreader will slow down to.

Printing (61):

  • X_acceleration_distance (default = 190 [10um]): The distance the X-axis will accelerate before it starts printing with the cartridge in sweeps. Is carefully balanced with speed and acceleration.
  • Printing_temperature (default = 60 [°C]): The temperature the printer is set at during printing.
  • Heat_cycle_time (default = 3600 [s]): The time the heat cycle will last after the print is complete.
  • Heat_cycle_temperature (default = 60 [°C]):The temperature of the heat cycle after the print is complete.

SD_read (71):

  • Nozzlecount (default = 12 [nozzles]): The amount of nozzles in the cartridge, 12 for the HP C6602.

All of these values may seem a bit much, but in most cases inverting some axes may be the only thing necessary. In the worst case some offsets need to be changed. When everything seems all right, the firmware can be uploaded to the Megatronics.

  • Got to Tools->Board->Arduino Mega 2560 or Mega ADK to set the right board to program.
  • Plug in the Megatronics to the computer and let the computer find the drivers. If this doesn’t happen automatically, go to the Arduino site for help.
  • Go to File->Upload (Ctrl + U)

If all went well, the LCD should now be displaying the opening screen. Press the keys to find out if the firmware works.

Next step

57 Comments

  1. I connected the circuit according to THE PCB and wiring diagram, and then downloaded the firmware to Megatronics V3 for printing. I found that the cartridge could not work. I measured the FPC terminal with oscilloscope and found no voltage change. Then I measured pin46,47,48 and 49, but still no level change.
    I read the firmware you wrote and found pin46,47,48,49, named AUX1,AUX2,AUX3, and AUX4 respectively. These pins are defined as output mode only in Alfa_v0_07_Megatronics_V3. How can I operate the cartridge?

    • It is a bit challenging to troubleshoot. The first thing is to make sure that the Megatronics V3 you use is exactly the same. It needs to have a ATmega2560 microcontroller, and the right pins need to be attached to the aux pins. You can write a small program to make pins 46 to 49 high without a printhead connected to it, to test if the pins do go high. If they do not, you might not have a V3 megatronics board.

      Plan B was designed around a very specific pin mapping. Printing needs to happen on the given pins. Simply changing the pin numbers will not work for the inkjet.

    • Not wihtout a lot of coding yourself. Ramps has 5 stepper motors and Plan B needs 6. If a Ramps was possible I would have liked to use one. Also the firmware is fairly hardcoded so changing from one controller to another is fairly difficult.

      • If we make the number of pistons 1, the number of engines can be 5. Do we need two of the chambers we fill with sand? Can’t the roller come back to the starting point after laying the sand?

        When we do it this way, it may be necessary to take the piston upwards step by step instead of lowering it.

        • That way would work fine, Oasis works with only 4 motors, but not on Plan B with the standard firmware. The way it is coded is basically hardcoded for a Plan B layout only, hence the “not without a lot of coding yourself”. If you want something like that, you can take the firmware and basic design of Plan B, and alter it to your own need, but by default the provided design will not work for you.

  2. sorry for the custom, I wrote it in Spanish before … I was telling you that if today there is any software that allows me to use the printer with a 7-cartridge Epson head?

  3. I need the spreader move go and back because I have only 1 feed. How can I edit the code?
    Or is it another way to edit it?

    Thank you

    PS Can I have your email for asking more information

    • I started digging a bit in the code.

      The function you are looking for is in the tab “Movements”, under de function “void New_layer”, here based on position 0 or position 1 (the side of the spreader) the movement will go either way. you’d have to modify it here so the position stays 0 and that the movement is changed so the spreader always returns to 1 side.

      This is about the help I can give you. Plan B has been a closed project for years for me, and so I no longer support it.

  4. Does the board need to have an SD card to upload the firmware?..I upload and it says its done uploading then the display shows a blank screen, it lights up but theres nothing. Im also not done connecting everything but Should I be able to see the menu at this point? only the display and keypad are connected. Some help Please. I have everything and im almost done I even got professional PCBs and I really want this to work.

    • Hi, I have a 3d systems motherboard, for projet 160, and I want make some experimentation for this motherboard, so someone know, where and how can I search info of this, or if you know if I can install another firmware?, I would like to make a open 3d printer controller for this kind of technology

      • I know of nothing. All Zcorp and 3D systems stuff is closed source. Also I cannot help with an inkjet controller for those machines. The current printheads they use are a generation or 2 newer than I can control right now. I am slowly inching towards an inkjet powder printer controller for the HP45 printhead, but that will be a while before it is finished.

  5. the homing direction of my y-axis is to the right, if you’re looking at the printer from the side that the megatronics is mounted on. Is it supposed to home in that direction?

  6. I am using mechanical endstops instead of opto endstops. How should I rewrite the code for mechanical? Should I just edit the code in the Homing tab?

    • Depends on how you hook up the endstops. If you hook up the endstops to the megatronics without a pullup or pulldown, you will need to use the internal pullup. In the main screen you will need to replace the pinmode ‘INPUT’ with ‘INPUT_PULLUP’. If you use external resistors you can do it any way you like without modifying the code. Just make sure that when the switch is pressed the signal becomes high. Inverting this is not a fun job.

      • So would I wire the Common terminal of the endstop to ground on the board and then the Normally Open terminal to signal on the board?

      • I also just fried my Megatronics, so I’m wondering if I can convert to using an Arduino Mega + RAMPS shield? Would the only things I’d have to do be changing the pin declarations in the firmware and adding an SD card reader to the RAMPS?

      • The board actually started working again, I think one of the endstops was shorting it because it’s working now without any endstops plugged in.

  7. I disconnected the MS 1 and MS 3 on the stepper motor drivers, ı made trails without cartidge. small printing problem is fixed.Piston directions are wrong in my setup, i will handle it with pluggıng reverse position. Also, feed pistons moved together for every layer with different rates and is this normal? could you tell me pisyon motor movements when printing?
    Actually, i have very big problem about polulu a4988 drivers. After finishing trails, i wanted to try with cartidge. Then, i turned on power supply and megatronics’ power light was on after 10 seconds, it went off. I disconneted all drivers respectively. When ı plugged one of them, megatronics closed again. I changed it with a new one but any motor did not work except one that has a new driver. Can all drivers be burned? Could you give me an idea about reason of that? Is about step motors or a4988 or short circuit?
    Also, sometimes there is burning smell, drivers become hot and step motors make noise when they are active.

    Current rates of step motors are 1.68A and i didnt make an adjustment with trimpot of polulu.Can it be reason?

    Thank you for your helps

    • Feed pistons both move for every layer. The side on which the spreader is should move up, the other side should move down. The build piston goes down on every layer.

      The Trim pots should be trimmed until the motors start skipping and then moved up again. If they are moved up all the way they will indeed get very hot (though they should not burn out before they get really hot). Stepper motors are noisy, even when they are not moving. Trimming the pots to give the motors the minimum required current should help make them more silent, but they will always make noise. The burning smell needs to be located. Any short should not be on the Megatronics, and there is nothing else there, so it will probably be very hot stepper drivers.

      The printer shutting down after 10 seconds sounds a bit like a power supply issue. What do you use to power the printer.

      • I use BRM 12 V 30 A power Supply. But just only megatronics shut down and its power light went off or was faint and LCD didn’t work, ı didn’t control the other circuit for printerhead

        • Removing the bone obvious from the list. Is the megatronics working without the motor drivers and if so, are the motor drivers the right way around. The thing you describe sounds like a short somewhere in the system and the faint light sounds like a polyfuse that has stopped the power.

  8. Hi
    When printing, the gantry and spreader moved together for 1-2 second. Then, Spreader stopped at the line of the gantry and gantry crashed the spreader.

    Please, help me.

    • I made a trail without spreader, Printerhead was out of printing area and the part that i want to print was so small. I think printer make everything in small scale. How can i fix it? I try to change the values in firmware. For example, i changed the S_travel_distance value to 400, but spreader just moved 1 cm more. Did ı make a mistake in slicer options? Do the slicer options affect Spreader movements or other step motor movements?
      Thank you

  9. If I were to redesign the Plan-B printer to not require a second supply chamber piston, would I have to make lots of edits to the firmware to remove a motor or two? Would it be a matter of removing that motor from a few lines of code or more in-depth edits?
    I was also wondering if using a different print head (from an Epson brand flatbed printer) will conflict with the firmware since you used an HP C6602A?

    • Redesigning to remove one of the two pistons would require some more in depth editing, but all of the editing will mostly be in one block of the code. The place where new layers are handled is stand alone. The whole new layer procedure needs to be modified to work with only one piston. Using a different head really depends on how similar it is and how it needs to be controlled. If you directly send pulses to it to fire nozzles, it might work. If you need a more difficult control signal, Plan B firmware cannot handle that.

  10. Hello, can you please send me version V2 of the firmware? Thanks a lot.I hope planB can print pictures,what is the proposal

  11. Hi, I’m trying to replace the controller board on my Creatr Leapfrog with a Megatronics v3 I bought and the only problem I have so far is that in my printer it’s the Y-axis which uses two stepper motors, the Z-axis only uses one.

    Is it possible to change this in the firmware?

    Thanks.

  12. I tried to compile the version 3 files and it gives me this compile errors:
    Arduino:1.5.5 (Windows 7), :”Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)”

    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp: In function ‘void spiSend(uint8_t)’:
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp:35: error: ‘SPI’ was not declared in this scope
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp: In function ‘uint8_t spiRec()’:
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp:44: error: ‘SPI’ was not declared in this scope
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp: In member function ‘uint8_t Sd2Card::init(uint8_t, uint8_t)’:
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp:251: error: ‘SPI’ was not declared in this scope
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp: In member function ‘uint8_t Sd2Card::setSckRate(uint8_t)’:
    D:\Ml\Arduino\libraries\SD\src\utility\Sd2Card.cpp:507: error: ‘SPI’ was not declared in this scope

    • The SPI library seems to be missing. If it is installed in the libraries folder, add this line below the #Include function:
      #include
      If this does not work, look if the SPI library is present in the libraries folder of arduino.

      • Thanks a lot .My problem is resolved. Can you please send me version 2 of the firmware? Are you in the study of color printing?

  13. I tried to compile the version 3 files and it gives me this compile errors:

    Arduino: 1.6.0 (Windows XP), Board: “Arduino Uno”

    Alfa_V0_05_Megatronics_V3.ino:142:20: error: ‘A15’ was not declared in this scope
    Alfa_V0_05_Megatronics_V3.ino: In function ‘void setup()’:
    Alfa_V0_05_Megatronics_V3.ino:341:3: error: ‘DDRL’ was not declared in this scope
    Nozzle_commands.ino: In function ‘void nozzle_trigger()’:
    Nozzle_commands.ino:24:7: error: ‘PORTL’ was not declared in this scope
    Nozzle_commands.ino: In function ‘void nozzle_single_trigger()’:
    Nozzle_commands.ino:46:7: error: ‘PORTL’ was not declared in this scope
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

Leave a Reply to Moath Sh Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.