Skip to content
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

Motor Spin after M17 command #3

Open
ehtnevets opened this issue Mar 15, 2020 · 23 comments
Open

Motor Spin after M17 command #3

ehtnevets opened this issue Mar 15, 2020 · 23 comments

Comments

@ehtnevets
Copy link

After auto-disable timeout, sending M17 (enable) will cause motor to jump to almost the end of travel of an axis. Is there work around?

Thanks

@sae74
Copy link

sae74 commented Apr 30, 2020

I have exactly the same problem in rotation after shutdown

@ehtnevets
Copy link
Author

I'm ordering the MKS closed loop board. I'll let you know if MKS brand exhibits the same problem, in 2-3 weeks. Shipment has been really slow from China to U.S.

@sae74
Copy link

sae74 commented May 1, 2020

I will wait for feedback from you.
Thank!

@ehtnevets
Copy link
Author

I ordered MKS from AliExpress. It hasn't arrived after more 2 months. I disputed this with AE but seller (MKS) keeps extending protection program. AE only allows dispute if the protection program is expiring in a day. The computer generated response from AE keeps saying my dispute is invalid. So, I call my bank to charge back. I gave up MKS.

Anyway, I gave up with this closed loop stuff as it doesn't have the advanced smoothing feature like Trinamic drivers. It's loud and vibrates my print bed. Lowering the current seems to help but sacrifices max speed. Even after I found all the disable motor-off feature in Marlin and Klipper firmwares to avoid the jump from re-enabling, I think this closed loop solution gives worse bottom line result.

To top it off, the magnet always gets loose. I used all different type of glues, cement, superglue, epoxy, etc. They don't help. Especially, the ones I used in the extruders with linear/pressure advance feature (linear advance causes the motor to spin back and forth very fast and for short distances, aka violent jerking).

So, in the end I realized that closed loop motor this cheap ain't cut it. If you want to go closed loop, get one with $100s/axis. Plus, if your non-closed loop stepper is skipping steps, there is other fundamental issue that needs to be addressed. But for sure not going with closed loop.

Back to Trinamic.

@sae74
Copy link

sae74 commented May 21, 2020

Thank. But I need a device not for a 3D printer.
It’s very important for me to keep track of the number of steps.

@ehtnevets
Copy link
Author

Perhaps, you should use the more expensive version (about 3x more). They use more expensive components even down to the passive ones like bigger capacitor, tighter tolerance.

When it comes to closed loop control, I re-learned (I started a company that designed and manufactured robots for semiconductor industry) that you get what you pay for.

You can always keep track your steps with the software. The software is the one doing the stepping anyway.

@ehtnevets
Copy link
Author

And if your usage include moving the motor with a lot of high accel and decel, the magnet could be another problem.

@sae74
Copy link

sae74 commented May 22, 2020

I need to control the steps for a water pump system. Need high accuracy +/- 0.005 ml liquid

@ehtnevets
Copy link
Author

I finally got my MKS boards but decided that the motion smoothness is more important when it comes 3D printing and decided not to bother with it.

I have 1 board set with OLED and 4 just board set that I want to sell. If you are in US, I can sell them to you at cost + shipping. Cheaper than you find on eBay.

@sae74
Copy link

sae74 commented Jun 16, 2020

Thank.
But I am in a different country.
If you know what Chernobyl is, or you watched the Chernobyl series, then this is about my country, Ukraine.

@ehtnevets
Copy link
Author

Ukraine. Remind me of my a friend who told a story about Chernobyl cleanup when he was in the Army there.

@Quas7
Copy link

Quas7 commented Sep 10, 2020

I experience the same issue for my FDM extruder after powerdown and enabling again. It always stripped my filament as it retracted with max speed x100m of filament. ;)

Simple solution was to disconnect the enable-pin from the cable-connector and bridge the enable signal on the stepper PCB to GND (active low) with a dupont wire.
This way, the stepper driver stays of course always active but there is also no "reset to 0" at the start of the print.

@Quas7
Copy link

Quas7 commented Sep 10, 2020

I flashed today the latest firmware out of this repo to adjust the PID values a bit and now the enabling/disabling of the stepper driver does not result in any erratic spinning anymore.

I guess, the issue got solved by the devs before uploading the code here.

@sae74
Copy link

sae74 commented Sep 11, 2020

How did you upload the firmware?
Where did you connect the programmer?

@Quas7
Copy link

Quas7 commented Sep 11, 2020

Took the pinout from here: https://github.com/bigtreetech/BIGTREETECH-S42B-V1.0/blob/master/Item-Pinmap.PDF
image
Read carefully the pins as there are two rows of pins (OLED and aux. connector) and one column of pin descriptions depicted

SWCK, SDO, GND are required - you can also disconnect the board from the supply and plug in the 3v3 from the programmer.
Make sure, the board (more precise the motor) is not "enabled" during flashing as this seems to result in issues (seems to be EMI as my OLED also shows artefacts from time to time).
I used a st-link v2 clone but any STM32 programmer will do, I think.

changed in main.c the D value for the PID loop to improve a tiny bit the extrusion performance:
int16_t kp=30;
int16_t ki=10;
int16_t kd=200; //was 250
Compiled binary for the lazy: S42B_fw_P30_I10_D200.zip
As the extrusion is already close to perfect there is not much sense to test other PID settings in my case.

For later reference I downloaded the binary from the S42B before uploading the edited one.
I attach it here, if someone wants to dig into it for some reason. ;)
Warning! contains reset-to-zero-bug after re-enabling the driver: s42b_org_as_delivered.zip

@AbeFM
Copy link

AbeFM commented Sep 30, 2020

Read carefully the pins as there are two rows of pins (OLED and aux. connector) and one column of pin descriptions depicted

SWCK, SDO, GND are required - you can also disconnect the board from the supply and plug in the 3v3 from the programmer.
Make sure, the board is not "enabled" during flashing as this seems to result in issues (seems to be EMI as my OLED also shows artefacts from time to time).
I used a st-link v2 clone but any STM32 programmer will do, I think.

I hooked up those 3, plus 3.3V, pin for pin over to my generic STLink2 dongle. The dongle mounts in Windows, but beyond that, I can't get anything to talk. Should it show up as a com port? Do I need a driver for the motor controller board (S42B) itself?

Do you upload firmware with the SerialPort Assistant, Arduino, VS, or what?

I have a feeling I have a bad board, but trying to see if I can get it talking. It holds position, calibrates, works with the screen - but won't register steps from printer. I even recompiled to get the longer pulse widths, still a no go.

Thanks - sorry for the off topic post - perhaps having the process more explicitly laid out will help others in the future.

@Quas7
Copy link

Quas7 commented Sep 30, 2020

depending on the dongle you have, it should show up as a generic USB device "STM32 STlink" or as a "ST-Link Debug" (STLink v3) with an additional COM-port.
If you have a Baite dongle it shows up as a com port via "STM32 STLink".

Do not connect the 3V3 parallel to powering the board itself. There can only be one supply voltage and you could damage either supply (most likely the dongle, if it is a cheap clone).

For coding, I work with platform.io in as a plugin from the market inside visual studio code (https://code.visualstudio.com/).
See here for installation: https://platformio.org/install/ide?install=vscode

You can upload the binary via visual studio itself if you configured your dongle correctly in the platformio.ini via upload_protocol.
Youtube explains it in more detail here for instance: https://www.youtube.com/watch?v=dany7ae_0ks&ab_channel=MakeUseOf

good luck.

@AbeFM
Copy link

AbeFM commented Sep 30, 2020 via email

@AbeFM
Copy link

AbeFM commented Sep 30, 2020

Ah, ok. So I didn't have 5V run to the driver's socket, so the little adapter board wasn't sending said +5v to the S42B. I checked that I could talk to another SM32 board (one of those Arduino Nano looking deals). Your pinout was helpful.

Now with that jumpered, I was able to flash your firmware onto it. Everything works including printer commanded moves. I just need to remove the jumper and Say It With Solder and I may actually be able to print stuff again. Thanks for all the help!!!!

Does that have the bug fixed with the jumping when "enabled" is un-asserted?

@AbeFM
Copy link

AbeFM commented Oct 2, 2020

Still sufferings inconsistent connections. Sometimes it doesn't work without being plugged into printer, sometimes it doesn't work IF it's plugged into the printer, I'm getting a replacement programmer but I suspect it's the board. Aside from that, I need to change my PID values, and had some questions for @Quas7 :

Make sure, the board is not "enabled" during flashing as this seems to result in issues (seems to be EMI as my OLED also shows artefacts from time to time).

Can you explain what you mean here - you mean the enable pin from the printer being asserted? So the bad state is dependant on the firmware settings? I've had the board unplugged from the motor and oled when programming.

I don't think I have the same issue as you, mine gets the first line (initializing oled) then resetting, so it's just flashing that message at ~2 Hz.

changed in main.c the D value for the PID loop to improve a tiny bit the extrusion performance:
int16_t kp=30;
int16_t ki=10;
int16_t kd=200; //was 250

Have you used this for any movement axis? I was getting run away oscillations on my CR-10 and wondering what good starting numbers might be.

Warning! contains reset-to-zero-bug after re-enabling the driver: [s42b_org_as_delivered.zip]

Can you explain what that error is so I can verify it's removed from my firmware?

@Quas7
Copy link

Quas7 commented Oct 2, 2020

@AbeFM
I had also many connection problems in the beginning but quickly noticed, that this happens, if the board was powering the motor (driving the PWM stage).
Disconnecting the motor did not help in my trials likely as the PWM chip will still try with maximum motor voltage to get current pushed into a non existing motor. These voltage peaks seem to still interfere with the programming communication.
Just to be clear, I would not go that far to say that this is a design flaw of the PCB as on such a small board this might be really hard to prevent. BTW, the PWM frequency seems to be 187kHz according to Jans calculations.

You can set the "enabled active high or low" via the menu to switch the driver stage off during programming.
Your OLED issue seems to be a corrupted uploaded firmware and the STM controller just reboots because of that.

My PID settings are only for my extruders and naturally they feature a quite heavy dampening that prevent oszillations.
If you want to do a heuristic calibration, I would recommend the Ziegler-Nichols methode for PID systems as a starting point (https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method).
You will need to generate a stable oszillation with a high P and I=D=0 and then measure the oszillation frequeny with a smarthone app like "vibration analysis" (android).
The rest is then following the recipe on wikipedia and I would start with the derived values for "classic PID".

The "reset to zero bug after re-enabling" is fixed in this repo. But units currently sold (I have 3 of them bought over 3 month) seem to have an older firmware.
If you enable them for printing and disable the driver after printing is finished all is fine. But as soon as you start hte next print and re-enable the driver it will try to get to its staring position "0" that was memorized at the first power-up before the first print.
For axis movments this means, it will very violently snap back to the position it booted up (keep your fingers away from the bed!).
For extruders it just instantly stripps the filament by trying to reach "0" via retracting something like 100m of filament (depending on print size of the previous job).

@AbeFM
Copy link

AbeFM commented Oct 5, 2020

Ah, thanks again for a good answer. I'm unfortunately reasonably versed in PIDs, but have never had a case I COULD just tune like that. I guess the problem is you're reading the pulley, not the stage, probably making things worse. Anyway, I'll try it when I managed to get it flashed - even if I didn't need to I've always wanted to use the phone accelerometer for something useful.

Ah, ok, thanks for the answer: Making sure it's not enabled. Which pretty much means "does motor freewheel", if it's holding it, you'll know.

It would be awesome if (along the lines of "it's not a design issue) they let you flip a DIP switch to get into reliable programming mode. :-)

@swanepoeljan
Copy link

It would be awesome if (along the lines of "it's not a design issue) they let you flip a DIP switch to get into reliable programming mode. :-)

If they just broke-out the BOOT0 pin of the MCU to the DIP switch (or some extra jumper) we could have used the internal system bootloader to easily flash new firmware with only a normal USB to Serial bridge...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants