How to set up Marlin to use a heated chamber? I have an infrared lamp I'd like to use to heat my chamber. Right now I don't have plans to install a cooling fan, but I will if I need to. This question pertains to Marlin (2.0, preferably) in combination with an MKS Gen L v1.0 board.

In the documentation for the thermal settings it specifies you can set a heater pin to be used to heat up the chamber. It says this variable is called the CHAMBER_HEATER_PIN but in Marlin 2.0's Configuration_adv.h file there is something called a HEATER_CHAMBER_PIN that has been commented out.

Secondly the Configuration.h file:  there is something called an AUTO_POWER_CHAMBER_FAN. Is this meant for a fan used for cooling, or a fan used for cleaning out the chamber of particles? In either case, I probably don't want to have this fan always on, but only use it to cool the temperature the heater has been on too long.

So really there should be only 2-3 changes I need to make right: 


I need to specify an already present digital pin for


the chamber heater
the chamber cooler (fan)

Turn thermal runway active. 
It needs to use the Marlin Chamber feature so that the readout temperature appears as "C:" in the arduino logs. This allows compatibility with octoprint
Lastly I need to set an analog pin for the chamber thermistor


These are the things I can't fully figure out on my own. 
A detailed set of instructions or code snippets for a similar setup would be helpful
Here is what I found to be the easiest solution. Please use this image for reference. I recommend doing these instructions once from source, since a lot of things can go wrong,  then once everything works, go back and integrate them into your existing Marlin codebase. 


Get some 5V relays to run the infrared lamps. These relays take in a 5V digital signal from an arduino pin. When the arduino activates these pins, the lamps will turn on. Get a cardboard box, line it with aluminum foil, and attach a lamp to the top of it using a lamp switch. One wire for the lightbulb goes to NO on the relay, the other goes to D-. One wire from 120V power goes to COM, the other also goes to D-. The yellow "jumper" on the relay boards I posted goes between HIGH and the middle pin. These are pins on the relay, not the MKS GEN board.
On the MKS GEN board, we will be using the X-MAX endstop as the digital pin to run the chamber. Wire the 5V pin on X-MAX to the D+ of the relay. Wire the GND pin to D- of the relay with the two other wires there. Wire pin D2 on the MKS GEN Board to IN on the relay. Bold means the pin is on the MKS GEN board. 
Clone the Marlin-2.0 repo: git clone -b bugfix-2.0.x https://github.com/MarlinFirmware/Marlin.git
In Configuration.h, change TEMP_SENSOR_CHAMBER to 1 or 11 (depends on your thermistor, might be other values.) Since we will be using the board's second extruder thermistor as the thermistor in this example, change TEMP_SENSOR_1 to 0 for now.


#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_BED 1
#define TEMP_SENSOR_CHAMBER 1



In the file src/pins/ramps/pins_RAMPS.h, add this line:
#define TEMP_CHAMBER_PIN 15. Note that this is the thermistor
slot usually used for a second extruder. If you're already using
this thermistor for the second extruder and want to use a different
analog pin, see this question. You'll need some resistors.
Also, around line 95 in pins_RAMPS.h, change X_MAX_PIN to use an unused pin. The number 4 is good. If you don't do this, your Chamber's digital Pin will be always "on" by default. You want it off by default, then activated by the Marlin code.
In Configuration_adv.h, change //#define HEATED_CHAMBER_PIN 44 to #define HEATER_CHAMBER_PIN 2 to use the X_MAX endstop's digital pin. 
Upload... 
Go into OctoPrint settings. Click Axes and Volume. Next to a checkbox for heated bed, there is a checkbox for heated chamber! Click that, and your chamber is active. 
If some part is wrong (e.g. lamp doesn't go on because wire came loose on relay), debug that and keep working. Check the octoprint log to make sure the C value is shown.
Once everything works, generalize these solutions to your set-up (e.g. using multiple extruders).