How to connect klipper to Makerbot Replicator 2X?

It’s possible to use the SET_LED_TEMPLATE command (along with associated display_template config sections) if you want to update LEDs asynchronously. You should be able to find some examples if you search for SET_LED_TEMPLATE.

-Kevin

1 Like

@koconnor Thank you. That looks like it will probably do what I am looking for. I will need to check out the examples and see what I can do with it.

@dockterj Thanks to the suggestion from @koconnor, I was able to create the code to control the LED color during preheat using the asynchronous display_template. Copy this code into the bottom of printer.cfg and it should work. This should be similar to the way the original MakerBot used the LED colors, but I imagine it is not exact.

######################################################################
# LED update code
######################################################################
# This approximates the behavior of the stock Replicator 2 preheat LED control
# The LED will be white (or any user defined color) on startup, or anytime the
# printer is at temperature. When the target temperature is changed, it will
# check what percentage of the target temperature the hotend is currently at,
# (relative to room temperature, 20C) and update the LED color to indicate what
# is happening. It starts out blue when it is cold, and stays blue until it
# crosses the specified transition percentage. Then it changes gradually from
# blue to red as it approaches the target temperature. Then goes back to the
# custom color once hot.

# Set LED control user parameters here
[gcode_macro _LED_COLOR_PARAMS]
# R,G,B User color to show when idle, or at temperature. Typically white, but can be customized
variable_idle_color_rgb:       1.0, 1.0, 1.0
# Ratio (between 0.0 and 1.0) at which to start transitioning from blue to red
variable_red_transition_start: 0.70
# Ratio (between 0.0 and 1.0) above which to consider it "at temperature"
variable_at_temp_threshold:    0.97
gcode:

# This will start monitoring a short delay after startup
[delayed_gcode led_update_init]
initial_duration: 5
gcode:
  SET_LED_TEMPLATE LED=led TEMPLATE=led_temperature_template

# This will be called asynchronously to update LED color frequently
[display_template led_temperature_template]
text:
  {% set vars = printer["gcode_macro _LED_COLOR_PARAMS"] %}
  {% set has_bed = True if ('heater_bed' in printer.configfile.config) else False %}
  {% set has_e1 = True if ('extruder1' in printer.configfile.config) else False %}
  # Calculate current percentage of target relative to room temperature (20 degrees).
  # A target of 20 or less is always considered 100% (also avoids divide by zero)
  {% set e0_ratio  = 1.0 if printer.extruder.target<=20
                     else (printer.extruder.temperature-20)/(printer.extruder.target-20) %}
  {% set e1_ratio  = 1.0 if (not has_e1 or printer.extruder1.target<=20)
                     else (printer.extruder1.temperature-20)/(printer.extruder1.target-20) %}
  {% set bed_ratio = 1.0 if (not has_bed or printer.heater_bed.target<=20)
                     else (printer.heater_bed.temperature-20)/(printer.heater_bed.target-20) %}
  # Limit range between 0 and 1
  {% set e0_ratio   = ( [0, e0_ratio,  1.0]|sort )[1] %}
  {% set e1_ratio   = ( [0, e1_ratio,  1.0]|sort )[1] %}
  {% set bed_ratio  = ( [0, bed_ratio, 1.0]|sort )[1] %}
  # Get minimum value and use that for the LED
  {% set heat_ratio = [ e0_ratio, e1_ratio, bed_ratio ]|min %}
  {% set heat_at_target = True if heat_ratio >= vars.at_temp_threshold %}
  # Debug logging (uncomment to enable)
  # {action_respond_info("LED [e0, e1, bed] = [%s, %s, %s] -> %s" % (e0_ratio, e1_ratio, bed_ratio, heat_ratio) )}
  # Calculate red and blue percentages. Anything below red transition will be solid blue.
  {% set red_percent = [ (heat_ratio-vars.red_transition_start)/(1-vars.red_transition_start), 0 ]|max %}
  {% set blue_percent = 1-red_percent %}
  {% if heat_at_target %}
    {vars.idle_color_rgb[0]}, {vars.idle_color_rgb[1]}, {vars.idle_color_rgb[2]}, 0
  {% else %}
    {red_percent}, 0.0, {blue_percent}, 0.0
  {% endif %}

This should also handle the second extruder and heated bed, but it is conditional on whether they exist, so no changes should be needed for any combination. The LED color will represent whichever heater is the furthest from the target temperature. If the heaters are heated sequentially, then it will transition fully for one, and then reset and transition fully for the next, and so on.

The idle color and transition thresholds can be customized in the _LED_COLOR_PARAMS macro.

Please try it out and give me feedback on what could make it better.

Thanks!

Anyone had a chance to try out the LED code yet?

@dockterj

Have been following your repo and have a doubt if you can help me.
I have a flashforge dreamer with a mightyboard Rev H, but the mcu its not an atmega, its an stm32f407.
How do I compile it? as an stm32f407 or as an atmega?

Thanks in advance.

If it has an stm32f407 you would need to build and flash for that. I don’t know how to actually flash that, I’ve never worked with that chipset. There is a marlin fork that looks like it has support, you should be able to get pin mappings from that. Let me know if you need more info.

moonglow/FlashForge_Marlin: Marlin firmware for FlashForge Dreamer/Dreamer NX/Inventor, Bosch Dremel 3D20 3D, PowerSpec Ultra 3D and Monoprice Inventor 1 (github.com)

@dockterj
Thanks for your quick answer.

I know that fork and I am using it for marlin, which works pretty well on the dreamer, but I have been using klipper over the last few years and I would prefer it over marlin.

I tried to compile as an stm32f407 and then encrypt the file with moonglow’s ff tool, but the file ends up being 29kb and I cannot connect from fluid or mainsail to it.
What am I doing wrong?

Thanks,
C

It sounds like you are doing the correct things. Probably have to wait and see if CrazyMonkey can help at this point.

1 Like

@CrazyMonkey,
Any ideas?

TIA

@dockterj

While @CrazyMonkey doesn’t have a chance to reply, I have been snooping in to the marlin platformio.ini configuration and the enviroment is also atmega2560.
I am going to try again with this enviroment and report back.

Hi all, I’ve been waiting for Klipper for the replicator 2x. There is a lot of noise on this thread and I’m frankly not sure if anyone has it fully working. Is this working correctly now and is there a concise set of installation instructions. Kiauh is a great idea.
Thank you!

Yeah, it’s working great on my Replicator 2. Not 100% sure if the 2X is the same, but I know people have been trying it. A little tricky to get it set up, and still only supported through @dockterj 's custom fork, but I’ve been running it for several months now, and it is way smoother than the stock firmware. Just look through this thread for tips on how to get it running.

1 Like

A big thank you to @dockterj and everyone else who has contributed to this thread. I was able to get Klipper running on my Replicator 2 with an early rev G Mightyboard. I am still working on tuning some of the more advanced settings like resonance compensation but so far the speeds and print quality are pretty amazing.

Thanks for the feedback. I haven’t been actively working on this for a while but am picking it back up. The repo has been synced with upstream so it is up to date. Check out Sgail7’s repo with some good information about the makerbots GitHub - Sgail7/Replicator-Revival-Project: Giving life back to the Makerbot Replicator 1, 1 Dual, 2, and 2X 3D Printers.

Also excellent KIAUH install instructions here Replicator-Revival-Project/Klipper at main · Sgail7/Replicator-Revival-Project (github.com)

I’d say that the current state of this project is passed beta testing. I want to implement the following before considering it production ready:
ADS1118 - track errors in each channel independently
sample scripts - set hold current correctly for heating and printing (see comment in G130)
finish tuning and put realistic values in for max_accel and max_velocities
generally clean up my poor python code

Bugs I’m investigating:
menu buttons on the LCD sometimes require a double click? Is this a bug?
Mainsail Misc. area has the LED listed but can only control one channel - Is this a config problem, a problem with my pca9632 changes or a bug in mainsail?

Things worth pushing upstream in the short term:
remove the need to specify dummy pins for software spi devices
support multiple buttons triggering the same action on the LCD display

As these old printers are getting donated/abandoned, I’ve got access to quite a variety of them at various places, (replicator, replicator 2, replicator 2x, ctc clone)

is there a good guide to understand what needs to be done differently with the different models to get them all converted to work with klipper? It’s not clear if I need to use the sgail7 codebase or the dockterj codebase (or one codebase for some, a different for the other), etc.

My repo is the only one you need for getting Klipper running. There are others that have good information collected and SGail7 has much better install instructions than I have put together. Please let me know what issues you run into getting Klipper installed, I’m happy to help.

I’ve not worked with the original Replicator - I believe it is supported with an example config from upstream (i.e. none of my changes are needed)
Rep2 and Rep2x will need my repo and there are separate configs in the config directory for each one to get started.
Let me know what kind of clones you have access to as I would like to get the correct settings for clones documented as well.

Hi, I have a FlashForge Dreamer (2 extruders). I could help in testing for this printer. I believe mine is a RevH core board and stm32f407 MCU.

I have built a working klipper image for the raspberry pi using @dockterj
Got the info from another thread about my printer and will try to make proper config file. But any help is appreciated.

I think the biggest challenge is that it appears you need to encrypt or sign the image in order to flash the mainboard? If you can get an image flashed to it I can help with pin mappings. Search for older messages in this post for some other people that have been working on this.