Sailfish P-Stop for Replicator 2/2X
READ ALL OF THIS BEFORE PROCEEDING
- The Mightyboard is the most expensive component in your bot, and potentially the most fragile. If you're not comfortable with soldering new components to the "brain" of your bot, then do not proceed. The board is static sensitive, so take precautions.
- Sailfish 7.5 r1129 is REQUIRED OR YOU WILL DO DAMAGE TO YOUR BOT. While working on this, a few firmware bugs were discovered. One was that current firmware (both MBI and Sailfish) accidentally sets the ENDSTOPS_2 inputs to OUTPUTS. This means that if you start doing things like grounding the input for a logic 0, you're actually shorting an output and will damage the ATMEGA 1280. incidentally, this means that hooking up endstops to this header on stock MBI firmware (its intended use) would also do damage, so don't do that.
- Proceed at your own risk. You've been warned. If you break your bot, burn your house down, or injure yourself or others, I take no responsibility. The P-stop is NOT AN EMERGENCY STOP and it could fail to pause an action for any number of reasons, so again be careful. Also remember that the P-Stop needs to drain the motion queue, so the pause might not occur for quite a while after triggering the P-stop.
This information is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
The Rev G Mightyboard in the Rep 2 & 2X has an unpopulated header labeled "ENDSTOPS_2" This header provides the connections for the X_STEPPER_MIN, Y_STEPPER_MIN, and Z_STEPPER_MAX endstops, which are not used on the Replicator 2 and 2X. The ATMEGA pins are labeled J2, J1, and J0 respectively. For the purpose of P-Stop, X_STEPPER_MIN has been repurposed as the input trigger. I requested the pinout for this connector from MBI, but they told me that they could not provide the information as the board is proprietary. Then they told me I could get the information with my multimeter, so thats what I did.
- J2 = X_STEPPER_MIN (Repurposed for P-STOP)
- J1 = Y_STEPPER_MIN
- J0 = Z_STEPPER_MAX
I have only really tested J2 and the P-stop inputs, as well as the GND and 5V pins nearby. The rest were checked with a meter but since they don't have any exposed functionality in Sailfish, they haven't been tested.
These pins on the ATMEGA 1280 have the ability to trigger an interrupt on change. On Replicator 1's these pins are connected to PORTL, which do not have this interrupt feature. This means that the P-Stop implementation differs on the Replicator 1 vs. Replicator 2/2X. On the Replicator 1, the firmware must regularly check the P-Stop to see if it has been triggered. On the Replicator 2/2X, when the pin change happens, an interrupt is triggered, so there is no reason to poll like on the Replicator 1. This results in a difference in behavior. On the Replicator 1, if the P-Stop is active when a print starts, the bot will go into pause. In the latest development builds of Sailfish, Dan has added a initial check for P-Stop at the beginning of the print, so that Replicator 2/2X's will behave the same as Replicator 1.
Also, the Replicator 2/2X appears to have a filtering capacitor between each input (J0, J1, and J2) and ground. I measured the J2 capacitor with my meter and got 40nF. This might also cause a change in behavior. You can't just rely on "floating" to mean a LOGIC 0. Floating means floating, and this capacitor and other factors might contribute to biasing the floating input towards its last value. I found that disconnecting the pull-up from the input and letting it float did not trigger the P-stop at all (or at least for 5 minutes before I got tired of waiting). Anything that you connect to this input must explicitly pull-up or pull-down the input at all times and not let it float, as the behavior you get from a floating input is unpredictable.
Modifications to the Mightyboard
You'll need to remove your Mightyboard, which means carefully disconnecting a bunch of connectors and screw terminals. I labeled some of the wires (the thermocouple wires and extruder stepper wires) so I could easily reassemble. Then you need to free the board from the standoffs. Again, use care. Makerbot's instructions for removing the board state:
The Mightyboard is attached to the bottom of your Replicator 2 by four metal supports. Gently pull the board off each support individually. Start with the two at the lower edge of the board, then tilt the lower edge of the board up so that the power switch and the power and USB ports can slide out of their holes in the back panel when you remove the board from the last two supports.
I chose a Molex# 70246-1404 header to populate the blank space on the Mightyboard. It has a narrower standoff base that clears the capacitors that are soldered to the board nearby. Pin one is marked with an arrow, and the Mightyboard denotes Pin 1 with a square pad. This header appears like it is compatible with an IDC and ribbon cable, but I chose a Molex# 22-55-2142 housing, which accepts individual crimp pins. (Don't forget the pins too, Molex# 16-02-0096) This way I could populate only the few wires I needed.
The Mightyboard might have had an overzealous solder mask coating as I didn't get the solder to flow as well as I'd like, but I was eventually able to get a good enough solder job. A temperature controlled iron, patience and care are recommended while you do this, as you are again modifying a very expensive component of your Makerbot. I had a block of static foam that I used to rest the board while I was working, and some Kapton tape to hold the header in while I was working. Make sure you don't have any solder bridges or you could have some really big problems later.
Connectors and Resistors
I'm not going to publish an exact circuit here, because you really should understand and know what you're doing here rather than just blindly execute someone else's instructions. (Also, I'm not an electrical engineer, so do you really want to be copying my mistakes?)
I used the Replicator 1 endstop wire color coding. This means RED is the sense pin, and WHITE is 5V+. That leaves the black and green as ground wires. This might be confusing for some people, as people assume RED=5v.
I used a 10k resistor pull-up from J2 to 5v. Also I used a 1.3k resistor in series on the ground line. The thinking is as follows: If you use stock MBI firmware or an old version of sailfish, J2 will be configured as an OUTPUT, and be outputting 5v likely. The 1.3k resistor inline back to ground will keep the current from being more than about 4mA when the switch is active.
When J2 is properly configured as an input, and the switch is closed, the 1.3k resistor will pull down the 10k pull-up voltage to about 1/2v. In my testing, this is sufficient to trigger the interrupt (I originally used a 4.7k resistor, but I wanted something that pulled the voltage below 1.0v. A 1.3k resistor does pass more current, but I think 4mA is sufficient, and its only a "safety" current limiter in the case that there is a misconfiguration)
What to connect to your ENDSTOPS_2 header?
Now that you have a header and a connector, what can you connect there?
I bought a Yellow Mushroom Button and a 22mm 1 Switch Control Station on eBay. The button didn't quite fit right even though they were both made for 22mm diameter, but a little filing of the indexing tabs and everything was together.
I installed the resistors in the control station and sacrificed an old USB cable for the wire.
There may be other cool things to be connecting to this input in the future. I know people are looking at filament monitoring devices, jam detectors, etc.
As always, thanks to Dan and Jetty for their hard work on Sailfish. Special thanks to Dan for several private test builds as we figured out what works and ironed out the bugs.