I am new to the forum and have recently completed my first build. I’m using a MKS SBase (because I already had one from my first 3d printer) and I managed to get through all of this info to get a Joystick and MKS TFT 35 display setup and working in a single unit based on this one form the thread:
I purchased this joystick:
Note on this Joystick, the top turns left and right for the Z axis and the wires coming out of it are not what you expect, the two blue wires are for the button on top of the stick, the black is the Z signal cable and white/red are the +/- so the black wire goes to the Z pin, red goes to say ground and white goes to 5v.
I had some trouble getting this all working so I figured I would provide the details here in case it helps someone else in the future. There were limited available pins on the SBase that I could get to work, only 1.30 and 1.31 seemed to work for the x y z signals on the EXP1 and EXP2 ports and none on the J7 or J8 ports. In the end I compared the SKR pins mentioned in this thread somewhere and found the thermistor signal pins on the SBase work for the x y z signals as well. After that I found other info online that pointed me to P1.23 on the J8 connector that is the only available PWN capable pin that apparently is needed for the Joystick Enable pin as far as I understand. Here is my final config in Marlin:
#define JOY_X_PIN P0_23 // MKS SBase TH1+ (Heated Bed)
#define JOY_Y_PIN P0_24 // MKS SBase TH2+ (Extruder1)
#define JOY_Z_PIN P0_25 // MKS SBase TH3+ (Extruder2)
#define JOY_EN_PIN P1_23 // MKS SBase J8 Pin 3
That all worked fine and I found the following values for the dead zones on this joystick:
#define JOY_X_LIMITS { 0, 3235-100, 3235+100, 4095 }
#define JOY_Y_LIMITS { 0, 3110-100, 3110+100, 4095 } // min, deadzone start, deadzone end, max
#define JOY_Z_LIMITS { 0, 3068-100, 3068+100, 4095 }
And for those who may be confused by the deadzone numbers, when joystick debug is enabled you can run M119 to list the current joystick x y z and en values along with the endstop values. With the joystick in the default position the x y z readings will be at specific values that seem to float a bit. In the code above the first number “Min” is the lowest number you see when moving an axis as far as it will go one direction and the last number “Max” is the highest value in the opposite direction. That should be clear but what I didn’t realize was the the resting value would be a number somewhere in between and would move around a bit. I rebooted several times and ran M119 to get a range of values and then picked the average for each axis without moving the joystick around. This gave me the base value for each axis and then I added that number in to the code above for each axis with the first number being the average value minus 100 and the second being the average value plus 100 as shown above. Example: #define JOY_X_LIMITS { “min”, “average resting”-100, average resting+100, “max” }
Hope this helps others with the SBase or just in general trying to set this up and thanks to the creator of this code, it’s awesome to have this working and to see it integrated into Marlin, congrats!
Here are some modified diagrams based on the previous forum posts adjusted to my setup and the layouts of the MKS SBase for reference. I left out the LED and just went for an enable pin to ground on a single throw switch so just on/off: