-
Notifications
You must be signed in to change notification settings - Fork 70
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
not enough piece of code #8
Comments
What important piece is missing? Scaling down by SINE_MAX ? |
Hey -- did you make a PR from this issue? I suggest you edit the code, allow the fork, then submit the PR. AFTER you test the code. |
@martinbogo What is not working? |
Just to clarify, what I think is noted above. In the original code from misfittech, the dacCos is scaled two times. First by SINE_MAX and then by 3300 (full scale current in mA) code from misfit:
EDIT: I see an improvment by adding the /SINE_MAX scaling and started a pull request. |
Looking at the sineTable in sine.c I now wonder, why it is limited to 511 (~9bit) as there is a 12bit input from the A1333 encoder and the PWM to the A4950 also has a higher resolution. Misfittech also has much more resolution in the sineTable(s) but has also an ATMEL ARM which might be a bit beefier than the STM32F1 used here. Mechaduino is using 10bit. Comparing to bigtreetech S42B. |
@Quas7 The effective resolution is limited by timer max frequency 72Mhz. If it counts to 32767, it will be updated every 72Mhz/32767= ~2kHz. Slow. With 512, it is ~140kHz. So I tried 32767 and the motor was sluggish (not catching up with main loop) and noisy (too slow for the low pass filter). Then I tried 255 and it actually made a little less hissing than it was with 511 or 1023. Then I tried 127 and the high pitch noise disappeared completely! I am going to stick to that because I don't feel any performance difference. It feels as smooth as on 511 or 1023. "511 counter" peaks around -43dB@18kHz: "127 counter" peaks around -63dB@18kHz. Significantly under the red line from the previous maximum.. EDIT1: Original question was about the sine range, not timer range. I was talking about timer range. While sine range and timer range are related, there is no reason for sine wave not to be a bit greater range (unless we want to use int8) and then divided at the end when calculating vrefX and vrefY for the timer threshold. EDIT2: Perhaps adding dither, described by ST, would solve noisy harmonics(?) and allow to maintain the resolution of the final timer counting. |
@dzid26 thanks for the nice background informations. But I got a bit confused where you found the RC filter for the motion PWM signals. Or did you maybe mean the VREF signals as there is actually an RC low pass in the schematic? VREF Anyway, I agree that we would have to stay out of the audible spectrum with >25kHz for the stepper PWM. |
@Quas7 So the current control loop is really delegated to the A4954 chip. The chopping frequency of the chip is somewhere between 20-40kHz based on this This control scheme is a little different from what you would see in FOC controllers, where normally MCU controls the current according to sensed current (which here is not possible, as there is no op-amps nor a connection to measure shunt voltage). Surprisingly it works really well. I imagine that the only time the real current would be far from the requested current is at high speed - when BEMF prevents current flow. Unfortunately, we wouldn't know that this is occurring, so it's likely that in this case the current distribution between phases is not optimal. (Perhaps BEMF could be modeled to compensate for that). Otherwise, especially at low speed, the "current limit" method for shaping the current signal works nicely. |
Thanks again for the nice details of this concept! That explains, why I could net get my head around the datasheet. ;) Regarding the overcurrent. |
when copying the original code
an important piece of code was lost in the procedure
int32_t A4950_move(int32_t stepAngle, uint32_t mA)
in file A4950.c
The text was updated successfully, but these errors were encountered: