-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PID adjustment via LCD #11
Comments
After finding out about this issue, I tested probably over a 100 combinations of PID. I could not get rid of the overshoot without affecting the accuracy. This was with 32 microsteps. The problem becomes visible in printing small circles when trying to damp the overshoot. Setting I to zero causes undershoot. Setting too high of P and/or D results in a lot of noise and vibration probably because the driver is A4950. I think the closed loop operation shouldn't be based on PID or at the very least the smallest stepper increment should be synchronized with the encoder position measurement. That is the smallest error from the encoder should limited to minimum the smallest stepper increment. Maybe line 89 of stm32f0xx_it.c should be rounded based on the stepangle setting. Also, the minimum input to the stepper should be the same as that used in the open loop mode based on what I'm seeing in that section of code. Otherwise, you get a non-zero input to the stepper between steps which may be causing a lot of unnecessary noise. Not sure if there's a guide to flash the stepper board. I didn't see any. If there's an easy way to flash it I can probably try changing the code myself. |
You will find the flashing instruction here: Please let us know, whether your controller design was an improvement. |
@hanif89 |
I haven't tried to set I at 0 yet. Didn't know I could do that. I've been playing with the PID values through the UART connection and using BTT's serial port assistant. On my CoreXY printer, I have my X and Y motors set at P30 I1 D300. Yes, there is the vibration noise for the first couple of layers, but then it pretty much goes away. I'll post some pics later when I get home to show the difference between the 2209s and A4950 closed loop setups. |
3rd vote for PID values setting from LCD. PID Values+ That would be a big help - or write a plain-text way to set values over serial: READ/SET kP/kI/KD/MC(motor current)/DR(direction)/EN(able) Either one would be a big help. Lastly: Yeah, the I-values are too big - the PID code needs to rescale that significantly. |
Regarding the checksums, I assume they are in place because the noise on the lines with a powered motor is way too high to guranatee stable communication. Note, programming the board with motor enabled fails as well in almost all cases either during prog or verify. The display programming option would be nice at least to modify the RAM values. |
Was also thinking another reason could be due to the fact that the MCU is using the internal RC oscillator which is not always the most accurate for sampling bits. I think it's anyway a good idea to have checksums, it's just not so nice if you have to manually calculate them. On my fork of this repo I completely rewrote the handling of the UART, modified the packet structure and included an 8bit CRC checksum. Then I also wrote a small C# program to communicate through the UART, in this case the program calculates the checksum automatically. If I find time over the next days I could maybe also adapt it to work with the original version... Another modification I made was rewriting the OLED menu and this time I included the option to adjust the PID gains in RAM (as Till also mentioned). Then there is also a Save option which stores the gains to flash memory. If anybody wanted to try it out, just keep in mind that it's still work in progress with limited testing being done so far. |
@swanepoeljan this is great! I directly pulled your fork to a branch. edit: And the very low hanging fruit - "tested it": compiles and runs... ;) |
@Quas7 Thanks for giving it a try! Its good to hear that at least it could also compile and run on your side. Haha... nice video ;-D Good idea to use it for tuning, think it should not be that hard to implement. So in the firmware I could just add an option to start streaming angle values at a constant rate. Then as a first step just capture and write the reported values back to a csv file for manual processing. Then maybe later perform the processing/calculating of gains in the terminal and even add a graph control to display the result directly in the terminal... |
That looks really promising! This "humming" sound for bad calibrated setups is like 3-4kHz by ear. |
Haven't tried it with the lever down yet, will also give that a try. Good idea to measure the humming through audio! The PID control loop runs at 10kHz, maybe when oscillating between two angles we get something close to a 5kHz tone... |
This was my thinking exactly, I was all hot to write a program like that but I got busy with other stuff and I wasn't super sure how to approach it. |
Sure, I just added it to the utils folder. Was done in C# using VS Studio Community Edition 2019. |
@swanepoeljan damn, now I have to check out how to C# as well. ;) |
:-) I am sure you will pick it up quickly. |
@swanepoeljan : thks for the gread job on the firmware. I have the same issues like kookaburra88 and this helps a lot with tuning the PID. |
@caesar1111 Glad to hear that it is helpful. As for the extra menu item, should be easy enough to add, I have some minor changes on my local repo that I planned to push to github over the weekend. I could then also add this option in there. During the last days I also added an optioned to the terminal program that allows it to work with the original BTT firmware. It is limited to the functions provided by original firmware but should at least also help with PID adjustment. Will also upload this version (both the exe and source) over the weekend. |
@caesar1111 Added the OLED frequency change option to the menu and quickly tested it, seems to work. It's now also updated on my repo. For the moment it does not save the value to flash so if you reset then it starts again with the default decimal value 0. If it helps to solve your issue then I can make the value also saveable in flash (like for the PID gains). Keeping my fingers crossed that it helps! |
@swanepoeljan Any chance you can upload the compiled firmware to your fork? I am very interested on trying it out myself, but I am unable to compile it because PlatformIO complains about missing dependencies (In particular they seem to point to "stm32f0xx_hal.h" but I don't know enough to venture into that territory...) |
I have added a bin folder with the compiled firmware. |
Thank you so much for that. I have however found the fix to the errors compiling the firmware in #38 and combined your changes with that and it worked. Now I am just trying to figure out a change on the behavior in what seems to be the number of micro-steps. In Marlin I have it configured as running with 32 microsteps, but if I set the same value on the board it only moves half of the distance. |
@swanepoeljan Any chance you can get your fork working with the V2.0 S42B from BTT, they haven't posted source which isn't surprising and it uses the STM32F1 MCU now |
Sounds very tempting and I actually have a V2.0 driver to even test it on! If I can just find the time... Regarding the V2 source code, have a look here. |
I have two V2 drivers on my printer for X and Y, they work quite well out of the box, so maybe they reworked the default settings (or my printer just matches them and I was lucky). |
Thanks for the link! I'm following you on github so I'll keep an eye out if you happen to get the 2.0 project going :) |
Hi There, do yo have any experience with configuration of pid in use with grbl? I actualy using Last version of fluid NC but I am experiencing some overshots in inner edging of engraved area, can somebody help please? |
Please provide firmware, which allows PID parameter modification via LCD screen. Without the option to adjust PID setting, running closed-loop mode (left cube, activated by DIP switch 3 on) provides much worse print quality than open-loop mode (right cube, activated by DIP switch 3 off).
My printer is Railcore II with direct drive extruder and heavy gantry. The overshoots at the cubes corners are visible. The default PID settings apparently result in too little dynamic of the closed-loop system.
Furthermore, please implement PID parameter identification. I'm thinking of issuing a chirp signal (sine wave with increasing frequency) trajectory to identify the motion system. Then optimize PID setting e.g. via Q-parametrization (https://www.google.com/url?sa=t&source=web&rct=j&url=http://web.mit.edu/6.245/www/images/ch7.pdf&ved=2ahUKEwjo6PPXpJvrAhWF-6QKHZ-tAUUQFjABegQIAhAC&usg=AOvVaw3tUTxwAj_G_qB2R07_86SD). If you need help implementing PID autotune, please let me know.
Also please see https://www.facebook.com/groups/505736576548648/?post_id=1015249378930696&comment_id=1015283328927301 for initial error report.
The text was updated successfully, but these errors were encountered: