# Z oscillations - how to fix/tune

**URL:** <https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465>\
**Category:** Uncategorized\
**Created:** [December 7, 2021, 9:47pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465 "2021-12-07T21:47:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 7, 2021, 9:47pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/1 "2021-12-07T21:47:27Z")

</div>

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

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:

> **[Maslow z axis oscillation](https://www.youtube.com/shorts/fdcrdb_D6xM?=youtu.be)**

Possible issues I can think of:

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

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [December 8, 2021, 4:56pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/2 "2021-12-08T16:56:11Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Spenc](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/spenc/32/21650_2.png) [@Spenc](https://forums.maslowcnc.com/u/Spenc)\
**Post date:** [December 8, 2021, 5:55pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/3 "2021-12-08T17:55:52Z")

</div>

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

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:

```auto
        {
            "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"
        }

```

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 8, 2021, 7:50pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/4 "2021-12-08T19:50:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [December 9, 2021, 4:09am UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/5 "2021-12-09T04:09:38Z")

</div>

> [@Orob](#):
>
> Does the mega need to reboot to change those values?

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

> [@Orob](#):
>
> kpPosZ, kiPosZ, and kdPosZ are all set to 0

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.

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 9, 2021, 5:53pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/6 "2021-12-09T17:53:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [December 10, 2021, 1:37am UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/7 "2021-12-10T01:37:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 10, 2021, 5:47pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/8 "2021-12-10T17:47:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dag83](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dag83/32/2603_2.png) [@Dag83](https://forums.maslowcnc.com/u/Dag83)\
**Post date:** [December 11, 2021, 7:44pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/9 "2021-12-11T19:44:58Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 12, 2021, 2:27am UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/10 "2021-12-12T02:27:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 27, 2021, 11:50pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/11 "2021-12-27T23:50:46Z")

</div>

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 :

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/1/0/1085d60f8cd92f8c0d81dbe6ca3cab0a5af1e5bd.jpeg)

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/3/3/33de08e6a8ddee6c2e5a69e2f533d2e1ebfe659c.png)

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.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [December 28, 2021, 3:44am UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/12 "2021-12-28T03:44:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [December 30, 2021, 6:05am UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/13 "2021-12-30T06:05:26Z")

</div>

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.

## Conclusion:

Encoder is fine.

# Tuning the PID.

## Setup:

- 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

## Action:

pressed z up and z down

## Result:

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:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/6/f/6fa7d1c21f41a7a94597a93d8f6d43b3f3f536c5.png)  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/3/2/32ae99365b79a6a0c165ba93d170bb0cac0fac49.png)

or us the reset button here:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/a/e/ae04929e962f12b913f37bfee1c9bbf8add24852.png)  
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

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/1/5/15586933206a77c7c5e073dcb441ab04dc38417e.png)

motor setup in motor.cpp

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/d/a/dab62fbce1b2b8d9066f51417f61b7bf547a734d.png)

stopping motor movement in motor.cpp

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/7/6/76d34289055be101c829e7ab754a06042cd29da7.png)

setting motion in motor.cpp

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/a/3/a303919d70160d23b9791f64c8d6c8cc3c877ace.png)

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:  

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…

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/3X/d/9/d9ef509c1c649b515a0ff1ade01a782753ab751b.png)  
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.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [December 30, 2021, 6:24pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/14 "2021-12-30T18:24:20Z")

</div>

> [@Orob](#):
>
> 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.

> [@Orob](#):
>
> 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.

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.

> [@Orob](#):
>
> LE9201 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…

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.

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [January 1, 2022, 6:34pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/15 "2022-01-01T18:34:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bar/32/10_2.png) [@bar](https://forums.maslowcnc.com/u/bar)\
**Post date:** [January 1, 2022, 7:12pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/16 "2022-01-01T19:12:58Z")

</div>

> [@Orob](#):
>
> Are there significant differences in how the z axis motor moves compared to the left and right motors?

No they should be the same.

> [@Orob](#):
>
> Do you think it is the z axis channel / chip on my board

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).

---

<div class="post-metadata">

**Author:** ![jonatpridesleap](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jonatpridesleap/32/6639_2.png) [@jonatpridesleap](https://forums.maslowcnc.com/u/jonatpridesleap)\
**Post date:** [January 1, 2022, 9:30pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/17 "2022-01-01T21:30:44Z")

</div>

> [@bar](#):
>
> As for where to get a new chip, let me know if you can find any.

……… 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.

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [January 2, 2022, 7:03pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/18 "2022-01-02T19:03:56Z")

</div>

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](https://create.arduino.cc/projecthub/ryanchan/how-to-use-the-l298n-motor-driver-b124c5) I have sitting around and make it a combined L298 and TLE9201 board with the L298 running just the z channel.

---

<div class="post-metadata">

**Author:** ![jonatpridesleap](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/jonatpridesleap/32/6639_2.png) [@jonatpridesleap](https://forums.maslowcnc.com/u/jonatpridesleap)\
**Post date:** [January 2, 2022, 7:07pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/19 "2022-01-02T19:07:17Z")

</div>

> [@Orob](#):
>
> make it a combined L298 and TLE9201 board with the L298 running just the z channel.

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

---

<div class="post-metadata">

**Author:** ![Orob](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/orob/32/16344_2.png) [@Orob](https://forums.maslowcnc.com/u/Orob)\
**Post date:** [January 2, 2022, 7:19pm UTC](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465/20 "2022-01-02T19:19:39Z")

</div>

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

[Next page](https://forums.maslowcnc.com/t/z-oscillations-how-to-fix-tune/17465.md?page=2)
