Joystick managed by Marlin

Hello, great article and great work. Thanks. I only have a problem with the Z axis. After using the M119 command, the values ​​jumps. Actually on each axis they jumps but the most on the Z axis is also another potentiometer

2 4.7kR potentiometers X and Y axis
1 potentiometer 1.5-3.6k in the Z axis

Because of this I cannot adjust the value

#define JOY_Z_LIMITS {90, 150-30, 150 + 30, 290}

Do you know what to do?

1 Like

This is my take on a handheld controller for my MPCNC.


I have used the lastest firmware, but wanted to be able to software invert the polarity of the axis, so I have included the code from jamies pull request.
Files for the housing can be found here: https://www.thingiverse.com/thing:4144229

9 Likes

Od Makarewicza do Orzechowskiego mówię wam: cześć i witam!

1 Like

Another Rambo success! I finished adding this to my machine today, many thanks to Jamie, Greg (for Rambo specific details) and of course Ryan :slight_smile:!

Process was relatively smooth minus me glossing the fact that you need a double throw switch to enable the… enable led to work :wink: I did run into some weirdness in that my analog pin3 didn’t seem to work right. My Y axis reading came out ranged 14-25-40 while the other axes were pretty close to Jamie’s published offsets. I switched Y to analog 6 after confirming wiring and resistance of the pot and it worked. Printed quick enclosure and off to the races!

I found a 2x5 header block in my parts bin along with a cat5 surface mount jack. Made an adapter cable that dangles out of the bottom of Ryan’s enclosure and ran a cable from the joystick to the plug. Painter’s tape holding it to the main stepper bundle will be replaced with a ziptie at some point.

20200217_122418

4 Likes

Forgot to mention, flashing firmware with PlatformIO was delightful!

1 Like

I like platformio.

I had a project that was using both an arduino and a raspberry pi. I put platformio on the pi and could remote flash the arduino.

Hello, great article!

How would I go about doing the same thing via the AUX2 port on the Ramps board, but with with 4 direction buttons instead. I need continuous jogging and the other solutions I’ve seen only jogs in increments.

I’m a total noob, so please be gentle :stuck_out_tongue:

Depending on how you use the joystick, it will jog the axis either in increments or continuously.

So how would I go about it using 4 direction buttons instead of a joystick to get the same effect?

So you want to just move X and Y?

You’d need a circuit that would make about 2.5V with not buttons pressed and then higher with one button pressed and lower with the other button pressed.

GND -- R1 -- R2 -- out -- R3 -- R1 -- 5V

           |-B1-|       |-B2-|

If you used 4 resistors of the same size (about 1k-10k) in series. You can wire buttons across the second and third resistors. The output is in the middle. With no buttons pressed, the voltage will be 2.5V. With B1 pressed, out will be 1.65V. With just B2 pressed, it will be 3.35V.

Repeat that for X and Y. You need completely separate buttons though. A D pad with a common pin for all 4 switches wouldn’t work this way.

1 Like

Many many thanks, I’ll give that a bash.

I did think the starting point would be 2.5V as if the wiper was in the the middle of the potentiometer, but didn’t know how to go about getting the other two extents. But you cleared that right up.

Planning on using 4 tact switches so this would work perfectly.

Hi. I almost have this working, however I’ve not quite got the fine tuning down yet. I have a bunch of questions. I’m running a Rambo like @tailslide , with dual end-stops. At moment I am only working with x and y. My z seems to have a broken wire.

I am able to get the values from m119 but when I change the firmware values it doesn’t quite respond as expected. For instance, the dead band at ± 100 was very sensitive… I’ve tried increasing this a bunch but it doesn’t seems to be adjusting as much as I’d like so as to avoid those small off axis moves when positioning. How wide can this be?

Also should it stop and start or be completely smooth? If I push the stick full tilt too quickly it goes then halts. If I push slowly, it will mostly go ok. But still halts once in a while in travel. I’ve had to increase the over all range values (max and min) from what was recommended by @jamiek as well so that I could move the stick more freely, i.e. so it is not limited close to center. My range of values from M119 appear to be 0 (min travel) to 16378? (max travel). I expected to be able to go full on stick and have it run at its max speed but it seems to just stop. Normal?

Precision. Not really a joystick problem but it kind of stinks the lcd only reports X & Y at 1mm increments. If I drive to a location. Reset zeros (G92 X0 Y0). And machine something. If I later need to rehome for any reason (after disabling steppers for something) , there is zero chance I could return to exact same location. Best I could do is within .5mm. Better to use the menus.

Finally, I have found that it does not seem to respect the end stops (machine limits?). I can crash the gantry pretty easily using joystick. Should that be the case or is something amiss? I’m runnning dual end stop firmware. It seems this version of Marlin (downloaded in the last few days from V1 for this feature) does not handle endstops the same as my older version (downloaded last summer). In past version, when I home with G28 X Y, the coordinates X Y coordinates would set to zero. Does not seem to do that anymore. Could be why I can crash. Is this the new normal?

Sorry for long post. Any input is appreciated. Thanks.

Seeing pretty much exactly the same thing. I am a developer by trade and tried applying some smoothing algorithms to deal with the start-stop issue which didn’t help… I think the problem might be something other than bad analog readings. Also saw the same thing with the endstops not being respected. Fortunately it seems to be a minor annoyance that doesn’t prevent me from finding it very useful. All in all I’ve still found it the most time saving upgrade I’ve done.

Also regarding finding the same spot I have mine hooked up to raspberry pi cnc.js so it’s easier to read off or set the coordinates although in practice I never seem to need to but might try it some day on a very long job.

1 Like

The design of the ranges is such that it won’t move within the dead band, and also outside the max range it will also stop. This was supposed to be a safety feature so if the thing came unplugged (and you were lucky with the floating voltages) it would stop instead of taking off at max speed. With an enable switch this is much less important and probably better to just use max speed beyond the limits too.

But given how it’s written now, the way I set the dead band is to push the joystick to the left and gently release, and note the value from M119. Then push right and gently release, and again note the M119 value. There is likely to be some backlash in the joystick mechanism so these “center” values won’t be the same. Do it several times if you want to get good confidence in the values. Then take these values and widen it a little and it should be within the dead band when its anywhere in the backlash area.

Then for the min and max, do the same thing but pushing the joystick to the maximum position, and then widen a little. But if you are already seeing 0 or 16383 then you can’t widen from that.

Also the M119 works even when enable is off, so you don’t have to worry about crashing while trying to get these readings.

As for crashing, the dual endstop firmware should have the soft stops set for xmin and ymin. If you haven’t homed then it wont let you move to -X or -Y from the point where it was powered on, or if you have homed then it wont let you move past zero. But if you disabled steppers and dragged the gantry in the +X or +Y and then started jogging, then it can crash because endstops are not monitored except when homing. And in any case it can crash at the +X or +Y ends.

1 Like

Mine seems to stop-start-stop-start even within the max band … was never able to track down exactly why I even changed the code to get rid of the max band behavior and still saw it (to a lesser extent). I don’t do any marlin development so would take a long time to figure out. Maybe it’s got some movement queue that runs empty? Or maybe I just need a new cable… although I still saw the same thing doing exponential smoothing over hundreds of samples.

I have seen “stuttering” motion when moving in (for example) +X when I switch direction slightly to +X with a little bit of diagonal +Y. In my mind I am blaming it on the cornering behavior but really I don’t know. (And it might not be the same thing you’re seeing either…)

I’m seeing that as well. Not sure if it’s related or not but it happens in a straight line semi randomly too. After a few hours of tinkering it didn’t seem like enough of an annoyance to bother with since it doesn’t keep me from working it’s just makes me realize I am a bit OCD :slight_smile:

2 Likes

Thanks for the inputs. I managed to get it smoothed out a bit. I opened the dead zone band a lot by following the advice from @jamiek. And opened up range to almost the full width, though it still halts occasionally if I push too fast even if not full travel.

  #define JOY_X_LIMITS { 100, 8030-600, 8030+600, 16000 } // min, deadzone start, deadzone end, max
  #define JOY_Y_LIMITS { 100, 8500-600, 8500+600, 16000 }

I also found a switch in Configuration_adv.h that gives me an extra decimal point on the LCD display for values with less than three digits. Uncomment the following line:

//#define LCD_DECIMAL_SMALL_XY

Still crashes into the end stops after a G28. These are what I think should be limiting that. Does this look right? Directly below this in the file is something about software endstops (M211), but I have not used those before. LCD menu never needed to.

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 200

Those are travel limits, yes, and you have to set your correct X/Y/Z size. Keep in mind that for Z typically 0 is the lowest point and the numbers get bigger, so I don’t know how it’ll react if you set zmin and zmax settings. It might prevent you from moving to -z.

The soft endstops after that will stop the machine after homing. But not by looking at the endstop switches. The dual endstop firmware enables min x and min y, but none of the rest.
I think there is a hard endstop setting elsewhere that will use the endstops all the time, but I have never used it.