Maslow Home Maslow Community Garden Newsletter

Z oscillations - how to fix/tune

I have:
*metal Maslow 100rpm motor
*9201 shield
*Mega controller 51.29 firmware

When the sled moves at all, the z axis oscillates. I have tried various combinations of high and low numbers in the pid fields for z axis positions and nothing has seemed to change it. I’ve continued to cut with it like that and after some time the z axis chip has overheated and thermally ‘checked out’ and I can turn the z axis shaft but hand to keep it moving, but that has risks with it. Can anyone help me talk through how best to try and fix this. My only other option is to buy a new motor from makermade. Bar helped me out with a cable so I can replace the motor, but I’d like to fix this. If it is the shield, I should have a spare arriving hopefully soon, but I’m not sure exactly when.

Here is my issue in video:

Possible issues I can think of:

  • Pid not ok for motor encoder ppr
    *Tle9201 firmware issue
    *100rpm motor encoder has fewer ppr

Thanks for the video, that really clarifies what is going on.

I think you are spot on with what is happening with the PID number being off. My guess is that with the 100 rpm motor the output shaft rotates more with each move of the motor so what might be a very small oscillation (even too small to see) with a higher rpm motor becomes quite big.

I think that tuning the PID values is the right thing to do. PID tuning can be a bit frustrating and sometimes the “right” values are more a product of trial and error than skill. How are you changing the PID values?

The steps I would do next are to:

  1. Set the PID values all to 0. This will make it so the z-axis never moves and will verify that we are actually having an impact when we are tuning the values. No point in wasting time adjusting them if they aren’t having an impact for some reason.

  2. Increase the “P” value gradually until we start to get movement. Generally we want to increase this one until we start to see some oscillation again, then we want to back off a little.

  3. Add a little bit of the “I” value which will help to further reduce the oscillations.

I’m here if you have questions along the way :slight_smile:

This is interesting. I am currently set up with:
*Metal Maslow 100rpm motor
*5206 shield
*Mega with 51.28

I looked at my web control json that I recently backed up, and all of my z axis pid settings are still at their default values. I haven’t had any issues with these oscillations at all on webcontrol, however I did have similar issues when I first tried setting up with makerverse before switching to webcontrol. I’d be curious to know if it may possibly be related to the 9201shield/firmware. Here is what I have currently:

            "default": 1300,
            "desc": "The proportional constant for the position Z-Axis PID controller\ndefault setting: 1300",
            "key": "KpPosZ",
            "section": "Advanced Settings",
            "title": "Kp Position Z-Axis",
            "type": "string",
            "value": "1300"
            "default": 0,
            "desc": "The integral constant for the position Z-Axis PID controller\ndefault setting: 0",
            "key": "KiPosZ",
            "section": "Advanced Settings",
            "title": "Ki Position Z-Axis",
            "type": "string",
            "value": "0"
            "default": 34,
            "desc": "The derivative constant for the position Z-Axis PID controller\ndefault setting: 34",
            "key": "KdPosZ",
            "section": "Advanced Settings",
            "title": "Kd Position Z-Axis",
            "type": "string",
            "value": "34"
1 Like

First of all, thanks @bar and @spenc for taking time to think about this with me. I should add that in the video, the webcontrol values for kpPosZ, kiPosZ, and kdPosZ are all set to 0 and that doesn’t seem to make any difference, which leads to my first question: Does the mega need to reboot to change those values?

It is possible that since I’m running 51.29 and the 1.5b eastbay shield numbering, it may be detecting the wrong shield which would make it crazy that it works at all… I’ll check that and report back.

I initially had issues with the motor in makerverse running with a Due, but after some PID adjustments (I posted for the 100 rpm motor), it worked ok though it wasn’t ever as solid as the original motor I had, but no longer have. The motor would oscillate terribly but stopped after some time and I never figured out why. It is possible the encoder is not quite right.

1 Like

The settings do need to be pushed from the computer to the mega, but it shouldn’t require a reboot from the mega. I can see a situation where they could change on the software side, but not be updating on the mega which seems to be what we are seeing here. When

We shouldn’t be seeing any movement from the z-axis motor at all.

Unfortunately I’m pretty out of touch with the inner workings of webcontrol so I can’t say exactly how or when the settings should be sent to the mega.

is there a basic utility that was used to do the initial tuning? Maybe I need to write something because changing the setting and then testing it is getting cumbersome with most of the time spent clicking and wheeling scroll bars to get to the right spot.

I added one to Ground Control I believe under advanced options, but unfortunately it only did the XY motors.

Were you able to get it to stop moving when the values are zero?

garage has been less than 20 degrees the last week and parking the car under the maslow folded up - saves scraping windows in the morning but access is difficult… hopefully tonight or tomorrow.

1 Like

Is your z-axis cable zip-tied to the power cable of the router?
That has been the cause of some wierd z-axis movements back in ancient history, when i was still active on the forum :slight_smile:

It is separated so the power feeds over top of frame and z axis feeds under frame

1 Like

I was trying to do this with webcontrol and got frustrated going back and forth between menus to test the values and remembered one of the things I liked about makerverse (since i have both loaded on my raspberry pi, I can swap between them pretty easy and since the mega holds its position, it doesn’t matter which one I choose to use): it has this cool property list called settings on the left in main screen that you can click on and it will fly out :

mousing over each one of the labels shows the storage command $29-$35 for the ones of interest. once they were all set to zero, I told it to move 1 mm and it drove to the lower end stop. I was expecting it not to move.

How do I test if the encoder is functioning or is even a quadrature encoder? I read another post earlier today that someone had to reverse the power and the hall sensor power connections to get a motor to work. I’m not sure if this is one of those motors though if it were a cable problem, it would be significantly simpler to fix since I have short cable extension.

1 Like

one thing with webcontrol, you can have multiple browsers (including from
multiple devices) or browser windows open pointed at the same device, so you can
have the multiple screens up at the same time rather than having to navigate
between them.

David Lang

good point on the multiple browser tabs…

so I have the sled sitting on my kitchen table next to my laptop with the shield/mega and raspberry pi all connected (minus the chain motors) trying to figure out if it is a wiring problem in the shield / TLE9201 chip or the motor. All indications from mega wiring through to the shield output pins are that everything matches up. Firmware function still needs to be verified though I thought it worked with my other shield fine, but I may be mistaken since I’ve tested 6 different shields and two motors.

I tested the encoder. After removing the router, a caliper was placed between two easy to measure pieces, set both software z position and caliper to zero and moved the gantry up and down by hand (cranking the motor pulley) and the micrometer span measurement matches the z position indicated by the software.


Encoder is fine.

Tuning the PID.


  • All PID values set at 0 for z axis for velocity and position as shown in screen shot in my previous post.
  • movement set to 10 mm


pressed z up and z down


no movement up or down.

Speculative Conclusion:

must have needed a reboot of mega because last time after setting PID values to 0, it just went down and didn’t stop. In makerverse, close and open the connection here to reboot the mega after each change:

or us the reset button here:

after some messing with it, the reset button works just fine. I accidentally hit the set home button, so once I reconnect the sled I’ll have to use webcontrol and reset the chains, but the calibration should still be valid.

I checked firmware assignments for motors 1, 2, and 3. All function the same with similar pin layouts. the difference is the gearing in the motors, not the communication.

pin assignments in system.cpp

motor setup in motor.cpp

stopping motor movement in motor.cpp

setting motion in motor.cpp

my read of the tle9201GS datasheet says the disable pin (#11) is low for enable and high for disabled and for the z axis tlc chip (MP2) is connected to mega pin 8 as digital IO. PWM input to the tle is pin 12 and appears to be connected to mega pwm pin 9 as pwm analog output for the z axis movement speed. (maybe the motor speed is wrong?).

back to PID:

step 1: set p for both (z pos and z vel ) higher and higher until it moves…

  • 10, 10 - nothing

  • 100, 100 - nothing

  • 1000, 1000 - nothing (this is wrong… double check connections — power not connected to shield. it will never work)

  • 0, 0, 126 max rpm - nothing

  • 10,10, 126 - stuttered movement up and down. very slow. 10 mm ask moves about 4 mm

  • 10, 10, 80 - same but only moves about 3 mm

  • 100, 100, 80 - same stuttered movement, but moves about 9 mm

  • 100, 100, 40 - higher frequency stutter. moves about 8 mm

  • 100, 100, 20 -

  • 100, 100, 5 - just moves slower about 8 mm but still stutters back and forth the whole way during the movement.
    z axis pwm is pin 9 so its pwm frequency for the tle 9201 is max of 20 kHz as per the data sheet
    values to choose from shown in the firmware comments:

    I’ve tried 2,3,4 at 100,100,20 and it doesn’t seem to matter.

set pwm value from 2 (
The expectation is that the motor will turn on and run to its setpoint and then start oscillating, not oscillate all the way to it.

going to set rpm to 100 and try bumping the P values more. after a an hour of several different values. I had it working slow but smooth until I reset it and and went back to the stuttering. I’m thinking I damaged the z chip on the board or it is the motor. I need to get another shield to compare with it.

I had it at 150, 2, 100 for the p values at a frequency of #6, but things got weird and it didn’t work for a while until I changed the z axis proportion value from 1 to 0, but that doesn’t make any sense.

today’s conclusions:

this is crazy. based on the fact that the motor moves the correct direction and changing the numbers makes it better or worse, it is a tuning issue, but I still think there is more to it than that… a simple oscillation around the setpoint position would be one thing but the velocity appears to be oscillating as well, so the direction of movement changes when the position is trying to tune, so the one change confounds the other. Changing 2 sets of PID values at the same time is a bad idea. the TLE9201 is rated at 6Amps. I doubt it is pulling that much, but if the motor is bad and the chip is hitting max amps, it will freewheel and then turn back on, so that could be the stuttering…

could the chip be short circuit detecting and that is why the motor stutters? I don’t have a scope to check this, just a multimeter.

I think I can help with what is going on here. When the z axis is moving to a position (say +10mm) it doesn’t simply change the target position to +10mm, it gradually moves the set-point from where it is to that location at the speed set by the feedrate. This means that the behavior you are seeing actually makes sense, it’s oscillating around it’s set-point, but the set-point is slowly moving towards the target position.

If the PID loop is osculating and slamming the motor from full speed one direction to full speed the other direction I could see it drawing a lot of current. Even if you aren’t seeing the motor move it could be slamming the voltage from + to - really hard if the tuning is aggressive. It might be worth looking at what values the PID loop is commanding for the motor speed.

I used makerverse settings to set the new value, save it, then close the port, repoen the port, then move the z axis and record the distance or the behavior . So after about 5 hours of PID setting changes for kp z velocity and Kp z distance, slowly incrementing from when it would buzz to when it would make jerky movements, I finally got fed up and moved the cable to channel 1 and then channel 2 and the motor works perfectly at the stock settings for those two channels.

Motor appears to be good.

Do you think it is the z axis channel / chip on my board (TLE9201) or the pin 9 interrupt it is using? A scope would sure be handy about now.

Are there significant differences in how the z axis motor moves compared to the left and right motors?

Anybody got a TLE9201 chip? Mouser and digikey are out of stock.

1 Like

No they should be the same.

My bet is that it’s the chip since we haven’t seen this behavior be wide spread. As for where to get a new chip, let me know if you can find any. I’ve had OK luck with getting small quantities from weird suppliers in china using octopart, but there’s really no guarantee that they are genuine and the prices are high (I’ve been paying like $8 for what should be a $2 chip).

……… any driver IC is going to be hard to get right now. Digikey is currently backordering chips to 2050 which means they just dont know when their shipments are going to land.

1 Like

I don’t think getting a new chip would do me much good with the equipment I have. I tried to pull the z channel chip and was going to swap it with the left one. My soldering setup wasn’t sufficient to take it off without damaging other parts. I was sitting here thinking how I could use what I have to fix the one channel… I could use one of these I have sitting around and make it a combined L298 and TLE9201 board with the L298 running just the z channel.

1 Like

Well, its come to this then. Franken-shields.

so it becomes a challenge to see if it can be done…

1 Like