Bench setup for stm32-sine development

User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Bench setup for stm32-sine development

Post by catphish »

I am currently sourcing parts to build a bench testing setup for stm32-sine (particularly the code targeting Tesla drive units). This is probably one of the least exciting hardware projects on this forum, but I thought I'd document it anyway.

The plan is to build a 1kW openinverter setup in my small home workshop, and use it to test changes to the stm32-sine code. I want to be able to validate openinverter releases before running them in my main vehicle, but also develop some changes of my own.

I've ordered some hardware and will start building once everything arrives:
* 16S (60V) 30AH lithium battery module
* Prius gen2 inverter (and of course the appropriate openinverter logic board)
* 1.1kW 230V 4 pole industrial motor
* 100 PPR optical encoder
Attachments
PXL_20211210_183022001.jpg
s-l1600b.jpg
s-l1600.jpg
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

Nice!

Any plans to add a second motor to provide load/regen capabilities? What are you doing for the encoder/resolver?

Edit - are you planning to use the Prius boost converter to step the voltage up?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Tue Dec 06, 2022 11:51 am Any plans to add a second motor to provide load/regen capabilities?
I haven't worked that out yet. I'm hoping I might be able to use a flywheel to simulate a load for both acceleration and regen.
Pete9008 wrote: Tue Dec 06, 2022 11:51 am What are you doing for the encoder/resolver?
I will use one of these: https://www.ebay.co.uk/itm/184451719957
It will be belt driven and if possible, I will set up the gearing to provide a reduction to cause it to output around 100 pulses per recolution.
Pete9008 wrote: Tue Dec 06, 2022 11:51 am Edit - are you planning to use the Prius boost converter to step the voltage up?
Yes, I'm hoping to run the 1100W 240VAC motor using a 60V battery. Hopefully this is within the capability of the converter.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

A flywheel should work, it's essentially what I do in the simulator using the car mass/inertia.

I'm a little worried how big it might need to be (I have a 2.2kW motor on my lathe and it can easily spin up a 20kg chuck, plus all the gearbox and motor inertia in well under a second). It's also a bit scary how much energy is stored - make sure it's well bolted on and that you don't get tangled up in it, I'd be building a safety cage around it!

Assume it will be a toothed belt to ensure that there is no encoder position drift with time?
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: Bench setup for stm32-sine development

Post by mjc506 »

If you can get hold of an rowing machine, you may be able to hook up to the fan/impeller to give you a decent load. Flywheels are scary...
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Bench setup for stm32-sine development

Post by arber333 »

mjc506 wrote: Thu Dec 08, 2022 6:05 pm If you can get hold of an rowing machine, you may be able to hook up to the fan/impeller to give you a decent load. Flywheels are scary...
I too think flywheel setup is a hazard when spinning. And at its speed it does not want to conform to changes well. You may be exerting a different effect from what you desire. You may be in danger of building weak supports...etc.

Instead of a flywheel you could take a simple drumm brake and use it... as a brake. You can then use its parking brake lever to vary force mechanicaly. Parts are available you would just need to asseemble your setup.

But I would suggest building a simple 2 motor drive setup, ether belt drive or lovejoy coupler whatever sutis best to your setup.
Then you can use your ACIM motor to develop STM32 drive. On the other side put the PMSM motor and wire it to a 3phase diode bridge. Magnets will allways fight movement unlike ACIM. No need for a complex inverter. You make DC after the bridge and put a load on it. Maybe 800W heater or another battery.
Or perhaps the same battery that you use for driving and you can measure output curent vs input current and calculate efficiency of your setup :).
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

arber333 wrote: Fri Dec 09, 2022 8:02 am I too think flywheel setup is a hazard when spinning. And at its speed it does not want to conform to changes well. You may be exerting a different effect from what you desire. You may be in danger of building weak supports...etc.
Unfortunately, one of the main reasons I want a flywheel is to be able to test regenerative braking as well as loaded acceleration. If I were going to use a dual motor setup, then the second motor would need to be powered, not just a load.

I definitely agree that safety is a concern, but hopefully I can build something secure. I don't know how much mass I'll need to achieve a useful result.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Thu Dec 08, 2022 5:32 pm A flywheel should work, it's essentially what I do in the simulator using the car mass/inertia.

I'm a little worried how big it might need to be (I have a 2.2kW motor on my lathe and it can easily spin up a 20kg chuck, plus all the gearbox and motor inertia in well under a second). It's also a bit scary how much energy is stored - make sure it's well bolted on and that you don't get tangled up in it, I'd be building a safety cage around it!
Yep, at 1kW I guess I'll be building up a decent amount of energy! I think the safest thing will be if I can direct mount a small flywheel onto the motor shaft, but will have to give some thought to securing the overall setup.
Pete9008 wrote: Thu Dec 08, 2022 5:32 pm Assume it will be a toothed belt to ensure that there is no encoder position drift with time?
Yes, I will 3D print some toothed pulleys and use a toothed rubber belt to drive the encoder and a fixed reduction. I did this successfully once before.
IMG_20170729_160031.jpg
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

Like the pulley set up, that should work well :)

The flywheel size needed shouldn't be too dificult to work out, have a look here for the equations https://www.roymech.co.uk/Useful_Ta ... heels.html

Seriously though don't take risks with it. My lathe is properly bolted together but I still don't like standing next to it when it is turning quickly with the big chuck on it!

Edit - fixed link!
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

This is the kind of setup I was imagining. The flywheel doesn't need to be huge, just enough to provide a meaningful difference between natural spindown, and regen braking.
Flywheel-energy-storage-system-with-an-induction-motor-adapted-from-73.png
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

Like the idea of a flywheel at each end, halves the size and stresses of/on each. Can your motor be used like that?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Fri Dec 09, 2022 9:04 pm Like the idea of a flywheel at each end, halves the size and stresses of/on each. Can your motor be used like that?
Unfortunately no. Like most industrial motors, the shaft at one end end of mine has a fan bonded to it, and is then covered with a grille. If you want to use both ends, you have to buy a special dual shaft motor that have a longer shaft so that the rear end of the shaft protrudes out beyond the fan and grille.

Hopefully I can make do with one flywheel. If I'm lucky, I can buy a purpose built flywheel with a keyed 12mm hole in the center. I'm not sure if that exists or not tough!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

No idea where to get flywheels suitable for fitting to a motor? Taper lock coupler and a small motorbike/mower flywheel machined to fit?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Fri Dec 09, 2022 9:24 pm No idea where to get flywheels suitable for fitting to a motor? Taper lock coupler and a small motorbike/mower flywheel machined to fit?
Yeah I think an automotive flywheel and an appropriate coupler / hub is much more likely to be feasible. I really lack the engineering background to know where to begin with it!
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Bench setup for stm32-sine development

Post by arber333 »

catphish wrote: Fri Dec 09, 2022 8:37 pm Unfortunately, one of the main reasons I want a flywheel is to be able to test regenerative braking as well as loaded acceleration. If I were going to use a dual motor setup, then the second motor would need to be powered, not just a load.

I definitely agree that safety is a concern, but hopefully I can build something secure. I don't know how much mass I'll need to achieve a useful result.
No! If you simply connect a PMSM motor to your ACIM shaft directly you can then load its 3phase ooutputs via diode bridge to a heater element.
If you want to release it you just disconnect the load and it will spin unloaded. No need to power the PMSM. You simply provide a suitable load.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

I'd work out what kind of size you need first then look for what's available. May be that you can manage with something fairly small (say a go cart wheel that might be easier to mount?).

My (very limited) engineering experience is telling me that I probably wouldn't want to stand next to it though ;)
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

catphish wrote: Fri Dec 09, 2022 9:17 pm If I'm lucky, I can buy a purpose built flywheel with a keyed 12mm hole in the center. I'm not sure if that exists or not tough!
12mm sounds very small for a 1kW motor, are you sure it's not larger?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Fri Dec 09, 2022 9:42 pm 12mm sounds very small for a 1kW motor, are you sure it's not larger?
Only as sure as this photo the seller took :)
Attachments
s-l1600.jpg
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

Can't argue with that! The diameter before the turned down section is more what I'm used to seeing.

Not sure I'd be happy putting anything more than a fairly small, well balanced flywheel on that though. I could see the vibration from any out of balance causing fatigue problems after a while.

Edit - wondering if that motor is designed to go into a gearbox which would limit the side loads/stress on the output shaft.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Bench setup for stm32-sine development

Post by catphish »

Pete9008 wrote: Fri Dec 09, 2022 9:48 pm Can't argue with that! The diameter before the turned down section is more what I'm used to seeing.

Not sure I'd be happy putting anything more than a fairly small, well balanced flywheel on that though. I could see the vibration from any out of balance causing fatigue problems after a while.

Edit - wondering if that motor is designed to go into a gearbox which would limit the side loads/stress on the output shaft.
That's a good point. It would definitely need to be well balanced to be secure. The alternatives are quite a bit more complicated though!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

Must admit to be a bit uneasy about hanging a flywheel on that shaft. Any chance of removing the fan and mounting it on the other end which is probably larger? The way you will be using I can't see cooling will be an issue.

Or reconsider the dual motor approach. An AC motor one side and a PM the other would allow testing of both sine and foc builds!
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: Bench setup for stm32-sine development

Post by mjc506 »

Running the flywheel off a couple of pulleys would reduce vibration on the motor shaft (may need to deal with side load from the belt) and would allow you to 'gear up' the flywheel to get away with a smaller mass. I'm not sure if a small flyheel turning fast is better or worse than a large flywheel turning slowly though! A small flywheel would be easier to 'contain' inside a cage though.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Bench setup for stm32-sine development

Post by arber333 »

Pete9008 wrote: Fri Dec 09, 2022 9:42 pm 12mm sounds very small for a 1kW motor, are you sure it's not larger?
I have seen twizzy motor variant push out 38kW on a 16mm splined shaft. It was designed for 18kW. As a matter of fact that car is still on the road.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

This http://robots.wa4dsy.net/ring-flywheel-calc might be useful. Looks like a modestly sized flywheel can store enough power to be worthwhile. The G calculation is a bit scary though, shows how critical balancing is!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Bench setup for stm32-sine development

Post by Pete9008 »

arber333 wrote: Sun Dec 11, 2022 10:45 am I have seen twizzy motor variant push out 38kW on a 16mm splined shaft. It was designed for 18kW. As a matter of fact that car is still on the road.
Not worried about torque loads, it should be fine for that. It is more the side loads and vibrational loads that a flywheel could put into it that concern me.
Post Reply