Problems running on a bare STM32

Post Reply
User avatar
Mouse
Posts: 138
Joined: Wed Sep 25, 2019 8:17 am
Location: Wales
Been thanked: 7 times
Contact:

Problems running on a bare STM32

Post by Mouse »

Not sure if I've missed a trick but I'm trying to get the code to run on a bare STM32 module.

I've tried both the Bluepill and an authentic STM32 Nucleo with the larger 64 pin chip.
Looking through the forums it would appear I only should only need to supply power to the STM32 module & ESP8266 + a direction signal and enter some custom commands to get PWM on the output.

I can access the web console and view all the parameters on it.
The STM32 Nucleo is recognised as hwver Rev1
The bluepill is recognised as hwver Bluepill

The custom commands I used are
start 2
Response: inverter started)
set fslipspnt 10
Response: set OK
Response: set ampnom 10
set OK

But there's no output on any of the 6 PWM channels as a result.

I also looked into the Error Memory and seen a whole host of faults such as over current, over voltage, Precharge errors and more in it which is frustrating as others appear to have a open loop motor working with what looks like nothing more than a STM32 module connected to the inverter with some level shift logic.
P4050828.JPG
P4050829.JPG
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Problems running on a bare STM32

Post by Isaac96 »

Precharge error trips when udc does not reach 'udcsw' within a certain amount of time. Type 'get udc' and set your udcsw to whatever that is. Overcurrent is coming from the lack of sensors. If you just want pwm I believe you can simply feed the current sensor inputs with 1.65v.
This wiki page should be helpful; it contains the schematics for the rev2 inverter kit, which ought to be similar wiring-wise.
https://openinverter.org/wiki/Schematic ... structions
Good luck!

EDIT Also you'll want a voltage sensor (or at least something to emulate it). A voltage divider should work to fool the stm32 for now. Wiki page has some info. For now you can set udcmax above whatever the stm32 thinks udc is. That should get rid of overvoltage.
yaroslav
Posts: 176
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol
Has thanked: 14 times
Been thanked: 5 times

Re: Problems running on a bare STM32

Post by yaroslav »

Hi
You also need to apply +5V to the PB12 pin via a 10K resistor this is used to block the timer due to hardware protection
User avatar
Mouse
Posts: 138
Joined: Wed Sep 25, 2019 8:17 am
Location: Wales
Been thanked: 7 times
Contact:

Re: Problems running on a bare STM32

Post by Mouse »

Thanks Isaac96 & yaroslav I got there in the end.
I was heading in the right direction but didn't quite make it. Another problem was caused by connecting the supply to the ESP8266 from the Bluepill 3V3 voltage regulator which resulted in high levels of noise on all the analogue inputs.

The biggest failure in my part was to assume things like direction input defaulted to OFF when unconnected. And of course I should have read much more more of the Schematics and Instructions and related error + parameter wiki pages before starting.

Eventually I had to spoof the following inputs and then tweek some of the gains and derating limits so the spoofed signals didn't halt the output before I got PWM output.
STM32_Min.png
It all looks so straightforward when watching Youtube.
yaroslav
Posts: 176
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol
Has thanked: 14 times
Been thanked: 5 times

Re: Problems running on a bare STM32

Post by yaroslav »

You need to connect the same voltage to pin start
User avatar
Mouse
Posts: 138
Joined: Wed Sep 25, 2019 8:17 am
Location: Wales
Been thanked: 7 times
Contact:

Re: Problems running on a bare STM32

Post by Mouse »

Still can't get the motor to spin.
Yaris inverter and a Mitsubishi Outlander rear motor.
The manual start spun the motor but trying to get it to go with the resolver connected is not yielding any results.
The spoofed currents are set to 1.65V and are hovering around 0A on the spot values. However is giving a DERATE - CURRENTLIMIT error when the start input is set which I think is the problem but I've run out of ideas to try.

Code: Select all

{
  "boost": 1700,
  "fweak": 90,
  "fconst": 180,
  "udcnom": 330,
  "fslipmin": 1,
  "fslipmax": 3,
  "fslipconstmax": 5,
  "polepairs": 10,
  "respolepairs": 10,
  "encmode": 4,
  "fmin": 1,
  "fmax": 200,
  "numimp": 60,
  "dirchrpm": 100,
  "dirmode": 1,
  "syncofs": 1000,
  "snsm": 13,
  "pwmfrq": 1,
  "pwmpol": 0,
  "deadtime": 63,
  "ocurlim": 10000,
  "minpulse": 1000,
  "il1gain": 4.68,
  "il2gain": 4.68,
  "udcgain": 6.15,
  "udcofs": 0,
  "udclim": 540,
  "snshs": 0,
  "bmslimhigh": 50,
  "bmslimlow": -1,
  "udcmin": 200,
  "udcmax": 520,
  "iacmax": 5000,
  "idcmax": 5000,
  "idcmin": -5000,
  "throtmax": 100,
  "throtmin": -100,
  "ifltrise": 10,
  "ifltfall": 3,
  "chargemode": 0,
  "chargecur": 0,
  "chargekp": 80,
  "chargeflt": 8,
  "chargemax": 90,
  "potmin": 0,
  "potmax": 4095,
  "pot2min": 4095,
  "pot2max": 4095,
  "potmode": 0,
  "throtramp": 100,
  "throtramprpm": 20000,
  "ampmin": 10,
  "slipstart": 50,
  "brknompedal": -50,
  "regenramp": 100,
  "brknom": 30,
  "brkmax": -30,
  "brkrampstr": 10,
  "brkout": -50,
  "idlespeed": -100,
  "idlethrotlim": 50,
  "idlemode": 0,
  "speedkp": 0.25,
  "speedflt": 5,
  "cruisemode": 0,
  "udcsw": 330,
  "udcswbuck": 540,
  "tripmode": 0,
  "pwmfunc": 0,
  "pwmgain": 100,
  "pwmofs": 0,
  "canspeed": 0,
  "canperiod": 0,
  "fslipspnt": 0,
  "ampnom": 0
}
plot1.png
plot2.png
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Problems running on a bare STM32

Post by Isaac96 »

Johannes said that fmin should be set to 0.5 and fslipmin to 1.5 or so. When I tried that my motor began to spin more or less properly.
I was getting the same CURRENTLIMIT but it sorta went away by itself eventually, it didn't seem to cause issues.
-Isaac
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 10 times

Re: Problems running on a bare STM32

Post by kiwifiat »

Looks like you are running induction motor firmware. You should be running FOC firmware. Also polepairs and respolepairs are almost certainly wrong. The outlander motor is an IPM. Take a look at the resolver and count the bumps, that is the number of polepairs. For instance the Leaf motor is a 4 pole pair motor meaning there are 4 magnetic north poles and 4 magnet south poles and the resolver has four sinusoidal bumps on it.

There is no way the motor will run properly if the you have those parameters incorrectly set.
Mouse wrote: Sun Apr 19, 2020 9:56 pm Still can't get the motor to spin.
Yaris inverter and a Mitsubishi Outlander rear motor.
The manual start spun the motor but trying to get it to go with the resolver connected is not yielding any results.
The spoofed currents are set to 1.65V and are hovering around 0A on the spot values. However is giving a DERATE - CURRENTLIMIT error when the start input is set which I think is the problem but I've run out of ideas to try.

Code: Select all

{
  "boost": 1700,
  "fweak": 90,
  "fconst": 180,
  "udcnom": 330,
  "fslipmin": 1,
  "fslipmax": 3,
  "fslipconstmax": 5,
  "polepairs": 10,
  "respolepairs": 10,
  "encmode": 4,
  "fmin": 1,
  "fmax": 200,
  "numimp": 60,
  "dirchrpm": 100,
  "dirmode": 1,
  "syncofs": 1000,
  "snsm": 13,
  "pwmfrq": 1,
  "pwmpol": 0,
  "deadtime": 63,
  "ocurlim": 10000,
  "minpulse": 1000,
  "il1gain": 4.68,
  "il2gain": 4.68,
  "udcgain": 6.15,
  "udcofs": 0,
  "udclim": 540,
  "snshs": 0,
  "bmslimhigh": 50,
  "bmslimlow": -1,
  "udcmin": 200,
  "udcmax": 520,
  "iacmax": 5000,
  "idcmax": 5000,
  "idcmin": -5000,
  "throtmax": 100,
  "throtmin": -100,
  "ifltrise": 10,
  "ifltfall": 3,
  "chargemode": 0,
  "chargecur": 0,
  "chargekp": 80,
  "chargeflt": 8,
  "chargemax": 90,
  "potmin": 0,
  "potmax": 4095,
  "pot2min": 4095,
  "pot2max": 4095,
  "potmode": 0,
  "throtramp": 100,
  "throtramprpm": 20000,
  "ampmin": 10,
  "slipstart": 50,
  "brknompedal": -50,
  "regenramp": 100,
  "brknom": 30,
  "brkmax": -30,
  "brkrampstr": 10,
  "brkout": -50,
  "idlespeed": -100,
  "idlethrotlim": 50,
  "idlemode": 0,
  "speedkp": 0.25,
  "speedflt": 5,
  "cruisemode": 0,
  "udcsw": 330,
  "udcswbuck": 540,
  "tripmode": 0,
  "pwmfunc": 0,
  "pwmgain": 100,
  "pwmofs": 0,
  "canspeed": 0,
  "canperiod": 0,
  "fslipspnt": 0,
  "ampnom": 0
}
plot1.png

plot2.png
arber333
Posts: 3295
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 81 times
Been thanked: 242 times
Contact:

Re: Problems running on a bare STM32

Post by arber333 »

It seems Outlander rear motor is 10 pole motor. That means you need to set it to 5 pole pairs. Also you need to set 5 resolver pole pairs.
Otherwise you need to use FOC code yes...
User avatar
Mouse
Posts: 138
Joined: Wed Sep 25, 2019 8:17 am
Location: Wales
Been thanked: 7 times
Contact:

Re: Problems running on a bare STM32

Post by Mouse »

Thanks arber333 for the advice and posting your parameters over on the Mitsubishi thread.
Still no luck, but the shaft is turning slowly now.

I'm now running the FOC software on a Bluepill and compared the parameters to the very similar ones arber333 posted in the Mitsubishi thread.
I've set Voltage and Current inputs to 1.6V to simulate inputs and checked the reading are around 0A and therefore derating values are not being exceeded.
Resolver connections are,
35.7R Black, White, Exciter
85.0R Green, Red, Output
77.2R Yelow, Blue, Output
I've got what I think are good resolver signals which peak at 1.5V pp on both channels and are 90Deg out of phase.
I'm running off 24V and using a diesel glow plug as a current limiter which effectively limits to about 10A or so.
I've swapped the resolver inputs and motor connections as suggested but had no success.
The inverter starts and shows no errors as per the last post which is leaving me a loss for further fault finding apart from repeating my tracks which is not showing me anything new.

So far all I can get happen are...
Giving a START and direction signal starts the inverter and resolver excitation, then increasing the throttle demand gets the motor shaft to spin at about 1Hz but no faster or slower. It will also not stop when removing the throttle demand.
I've tried increasing syncofs in increments of 1000 as described in 'Using FOC Software' but at the end of it the motor only spins at about 1Hz under throttle control.

The only anomaly I can find is the spot value for 'turns' does not increase linearly with shaft rotations and often in increments of many of 10s and almost at random at times when the shaft is spinning at about 1Hz. Then when turning the shaft by hand the spot value for 'angle' goes through 0-360deg however as one channel of the resolver output nears 0V 'turns' increases rapidly and sometimes in increments of 1000 or more per screen update. So I'm left wondering if this might be the area at fault but the signal looks free of noise on a quick scope check.
User avatar
johu
Site Admin
Posts: 5874
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 172 times
Been thanked: 1089 times
Contact:

Re: Problems running on a bare STM32

Post by johu »

Are you trying to run FOC software without current sensors?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Mouse
Posts: 138
Joined: Wed Sep 25, 2019 8:17 am
Location: Wales
Been thanked: 7 times
Contact:

Re: Problems running on a bare STM32

Post by Mouse »

johu wrote: Tue Apr 21, 2020 7:36 pm Are you trying to run FOC software without current sensors?
errr, yes.
Just to test, not as a final solution.
I'm guessing this might be a problem?
User avatar
johu
Site Admin
Posts: 5874
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 172 times
Been thanked: 1089 times
Contact:

Re: Problems running on a bare STM32

Post by johu »

Yes current sensors are part of the control loop (as opposed to the _sine software). Nothing meaningful will happen without them.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply