Hello. I have custom made z Axis with CHP-36GP-555-ABHLL motor which is 220rpm, 34 pole encoder that equals 1836 transitions per 1 rotation. And I have problem with setting pid for that motor. In code I found Zmaxrpm 12,6 and if I increase that value my motor is not spining faster. While in motor and encoder test motor is spining full throttle and is spining nice but while doing gcode motor is choppy. How to set faster feed rate for z-axis?
Thanks for the videos! Those are super helpful to communicate what is going on.
My first instinct is that that what we’re seeing is the feedrate being set in the gcode. If the gcode like is something like
G01 Z100 F200 then the motor will spin at the speed required to move the z-axis 200mm/minute regardless of how fast the motor can spin at max speed.
The jerky movement you are seeing is absolutely a PID control thing. Because this motor is so different from the stock motor you will need to tune the PID values. I would start by reducing the P and I terms.
Thanks for reply. I know that I can set in gcode but I believe z Axis is hard coded for Zmaxrpm 12,6 in source code, but when I enter value of 100, 200, 2000 it seems to have no effect. Also I tried tuning PID but also without succes values can be big as 200 for KP or small as 0,000000002 movement is choppy all the time. I tried to connect this motor as Left and used pid tuning tool but those values where also choppy. My last hope is to increase speed of that motor…
Hmmm let me take a look. Where is it hard coded?
Settings.cpp line #83
sysSettings.maxZRPM = 12.60; // float maxZRPM;
Hmm that does seem to be the right place. I’m seeing
sys.feedrate = constrain(sys.feedrate, 1, sysSettings.maxZRPM * abs(zAxis.getPitch())); in GCode.cpp.
The other side of that constraint is the sys.feedrate which comes the gcode you send to the machine. Are you using the jog up and down buttons in Web Control or some other program? Those will specify a move speed also which could be the constraint.
Yes mostly while testing I was using up and down buttons in webcontrol but also used bcdragon gcode in which there is no feedrate on z Axis movements. So in my case there should be 8mm pitch * 220 rpm for full speed? Is this value based on encoder steps for getting rotation speed? In original Maslow settings there is 12,6 * 3,17 if I remember correctly.
That seems correct to me
Yes, it will be. Great point! That could also be the limiting factor. When you see slow motion do you see the correct distance of motion? ie if we tell it to move up 20mm does it actually move 20mm albeit more slowly than we want?
+/- correct distance is travelled cause of that jerky moves. It’s really close.
Got it, so if it’s close then I don’t think the encoder steps is the right issue. How many steps per mm of encoder resolution do you have? It could be that the jerky motion is being caused by not enough encoder resolution.
What do you see if you run the gcode file:
G21 G90 G01 Z30 F5000
Is the motion still slow?
Right now I am away from machine, will check that gcode tomorrow morning. For 1mm it’s 230 encoder steps, so should be enough for pretty decent resolution, I think
Sounds like a plan!
I agree, that should be plenty of resolution.
I tried gcode with f5000 but there is no change. Spinning slow like before.
Do you feel comfortable adding some Serial.println() lines to the firmware? That way we could look for where the constraint is being applied.
If you can guide me a little bit where should I put them, sure. But as soon as I can visit my workshop, on Friday. Thanks for response and have a great week!
I’m not sure which firmware version you are using so I’m going to use mine as the example. They should all be pretty much the same.
What we’re trying to do is figure out how the speed is being limited.
Let’s print out what the feedrate read from the gcode is. To do that let’s add a print statement after line 778 in the file GCode.cpp so that it looks like
sys.feedrate = sys.inchesToMMConversion*extractGcodeValue(readString, 'F', sys.feedrate/sys.inchesToMMConversion); Serial.println("Feedrate read from gcode: "); Serial.println(sys.feedrate);
Then let’s print it out again after the feedrate is limited on line 793 in the same file. Something like:
sys.feedrate = constrain(sys.feedrate, 1, sysSettings.maxFeed); //constrain the maximum feedrate, 35ipm = 900 mmpm Serial.println("Feedrate after global limiting:"); Serial.println(sys.feedrate);
That will let us see if the feedrate is being limited globally.
Then finally let’s check to see if just the z-axis is being limited by adding a print statement after line 955 in the same file to see if it is being limited for just the z-axis. Something like:
sys.feedrate = constrain(sys.feedrate, 1, sysSettings.maxZRPM * abs(zAxis.getPitch())); Serial.println("Feedrate for just z:"); Serial.println(sys.feedrate);
That should give us some insight into where things are slowing down.
One more thought I had is that are you sure the pitch of your z-axis is right? If it thinks there is a super coarse threaded rod in there it will move more slowly because the number of rotations to move one mm is less. Probably a long shot, but I thought I would put that out there.
So I am sure that pitch is 8mm, and I entered those print lines but, last println just for z is in other line not 955 cause my whole gcode.cpp is 893 lines long. I am using 1.26 firmware . When I upload that new compiled firmware to Arduino should I make any steps in webcontrol?
After running that gcode from above
G01 z30 f5000 I get this:
Feedrate after global limiting:
And that’s it.
My global feedrate is set to 800.
But nothing about z Axis, even when I control that axis with up and down buttons I get only print line with global feedrate.
Where are you getting the firmware from? I think that I need to look at the same file you are using to be helpful
I was just cruising the firmware and found this interesting in the cnc_ctrl_v1.ino file at line 76
sys.feedrate = sysSettings.maxFeed / 2.0
if it is useful to your discussion, there it is. If not… good luck.
I believe that I downloaded it from GitHub, but I am not 100% sure. Where would you like me to upload it?
Thanks Orob I will look at it.