Hello everyone,
it is some days I’m trying to move my first steps (lol) with simplefoc and a nema 17 stepper motor.
Hardware:
black stm32f407ve board
L298N driver
AS5600 (i2c)
AS5048A (spi)
Nema 17 50pp stepper motor
I first started with a nema 23 and an as5600 connected via 12c, I’ve able to make it work in closed loop but without much reactivity or smoothness. I’ve been told by @runger about the limitations imposed by the i2c bus and since I’m pointing to get something nice I opted for an AS5048A encoder connected via SPI. The nema23 motor was too big for my application so I ordered the nema17 I needed.
I started playing with it, working fine in open loop, but with a huge amount of noise that required the velocity LPF to be raised to 0.5 for it to work in closed loop.
Like the best noobie out there I glued the magnet directly on the stepper shaft to discover some time later that the magnet should be mounted on a non magnetic surface (RTFM)
I’ve also discovered the drivers repository containing additional libs for the AS5048A which included the diagnostic part.
Using the diagnostic output I discovered that the field was terribly low with the magnet mounted on the shaft (1700/2000 magnitude)
The magnet I’m using is a 8mm x 1mm N42 neodymium.
After mounting it on a plastic support and closer (almost touching) the sensor I’ve been able to reach 3700 of magnitude. Sensor AGC is still fired all the way up to 255 (and afaik high AGC = noise).
I had the suspect of a low magnetic field so the last week i ordered a bigger magnet which I should get tomorrow.
Actually the position noise is 0.2 electrical revolutions (50pp)
-0.476467
-0.476371
-0.476536
-0.476395
-0.476518
-0.476233
-0.476437
-0.476258
-0.476247
-0.476254
-0.476561
-0.476378
-0.476054
-0.476331
-0.476209
-0.476406
-0.476171
-0.476173
-0.476484
-0.476437
-0.476254
-0.476187
-0.476444
-0.476160
-0.476155
-0.476343
-0.476147
-0.476509
-0.476297
-0.476482
-0.476413
-0.476446
-0.476313
-0.476403
-0.476154
-0.476420
-0.476209
-0.476528
-0.476392
-0.476273
-0.476417
-0.476350
-0.476584
-0.476298
-0.476251
This is a list of motor.shaftAngle() outputs with the stepper disconnected from power.
Velocity noise stays into 0.03 rads/sec with the motor standing still and an LPF filter on velocity of 0.03
CW/CCW routine works.
Positive target produces positive voltage and vice versa.
Openloop works till 30 rads/sec then it starts chattering.
Tried various SPI frequencies, all of them apparently work.
Changing pwm frequency doesnt apparently produce effects, I have a scope but I still have to check if something changes.
Using pins PB0/PB1 PA0/PA1 for PWM.
I saw on the forum that there were some problems with stepper in the release version so I moved to the github version, calling the .git url from lib_deps of PIO in vscode.
There was a little but tricky problem with a struct, already reported in issues:
https://github.com/simplefoc/Arduino-FOC/issues/159
However I used the name which contains the assignments and not the copy and it is ok.
If i try to tune (thanks again @runger) the PID to make it work in velocity closed loop, by setting all the parameters to 0 then raising P by steps of 0.05 I see voltage and noise (sound) rising, but no movement happens.
Hints ?
Thank you!