DIY Electric Car Forums banner

Another homebrew AC-controller

542743 Views 2283 Replies 99 Participants Last post by  nailgg
2
Hello everybody!

I have been reading here for a while and I'm simply impressed by the projects shown here.

So today I want to make my first humble contribution.

Short story:
1,5 years ago I came up with the idea of converting a regular ICE car electric (how unusual ;) ). I decided it would have to be an AC-motor since most of the complicated parts of spinning it are done in software plus it offers the best effiency. I also found out that standard ACIMs are really cheap and can be overpowered for short periods. Unfortunatly I also found out that controllers are really expensive.
Being an electrical engineer I decided to give it a try. My first inverter consisted of some BUZ50 mosfets and controlling circuitry around it. It basically worked but of course would only drive a 1:10 model of a car ;)
So I scaled up and have now got this:



It uses a 1200V 90A IGBT, IGBT drivers, a hardware PWM-module and a PC. It basically spins the motor at whichever frequency you set it to and it even uses the space-vector modulation scheme to achieve the highest possible amplitude. I know 90A isn't much but it's a start.



At the top you see the voltage with the little space vector "dent" and the current at the bottom.

There is one problem though: it is all open loop and it uses a PC. Also the PWM resolution is just 8 bits.
My plan is to put the controller program on a little µC which offers 16-bit pwms. For closing the control loop I want to start out with a speed sensor and thereby control the slip of the ACIM in some clever way that is still to be figured out. Since I have never seen any serious motor controller without current sensors and vector control I might have to implement that as well. There are closed loop sensors already on the IGBT-module but their output somehow didn't seem to linearly follow the amplitude of the current.
When all is finished I want to document it like the well known Open Source Motor Controller.

So... do you think this is a promising project worth continuing? And if yes, any suggestions?

Looking forward for replies :)
Johannes
----
State of the project
As of today there are probably around 100 vehicles making use of this project. There have been forks by "Jack Bauer", arber333 and others to use the technology in OEM inverters (Tesla, Ampera, i3, Leaf, ...)


  • Hardware
    • Logic (brain) board based on STM32F1
    • Simple 4A gate drivers
    • Melexis current sense boards
    • Isolated voltage sense board
  • Software
    • Bootloader for firmware upgrade without programming hardware
    • Firmware with mature support for asynchronous motors and experimental support for synchronous motors
    • Web interface using ESP8266 Wifi chip supporting Parametrization, plotting and firmware upgrade
The "vanilla" kit and documentation can be found here: http://johanneshuebner.com/quickcms/index.html%3Fen_inverter-kit,10.html
Web shop here: https://openinverter.org/shop
Forum here: https://openinverter.org/forum

Tesla Boards here: http://evbmw.com/index.php/evbmw-webshop, Source:https://github.com/damienmaguire
Inverter Source code here: https://github.com/tumanako



Please let me know what else should be mentioned here.
See less See more
441 - 460 of 2284 Posts
It is true that torque is generated at 0rpm and as John points out that would yield a division by zero using the p/speed formular.
I think it is the other way around. Power = Torque * RPM. So with zero RPM, power is zero regardless how much torque is present. The torque at the start is typically at or near the maximum with induction motors but power is zero until it starts to rotate.

If there was power there at zero speed, then the torque would be infinite and stuff would break real fast ;)
I think it is the other way around. Power = Torque * RPM. So with zero RPM, power is zero regardless how much torque is present. The torque at the start is typically at or near the maximum with induction motors but power is zero until it starts to rotate.

If there was power there at zero speed, then the torque would be infinite and stuff would break real fast ;)
Yes, I rearranged that to torque=power/speed. But that doesn't really work when there is no speed and no power ;)

Torque is also proportional to id - the torque generating current. I had done another experiment but that turned out wacky as well. Torque*speed hardly ever matched the power.

I can try calculating the scaling factor (Nm per Amp) from the nameplate current, torque and power factor.

c = t_n/(I_n*pf_n)
Then t=c*id
2
I made a new sensor board:





The improvements to the old one are:
- More accurate footprints for the current sensors
- 3 Types of current sensors supported: Tamura L01Z (up to 600A, the one I used up to now), Tamura L06P (up to 800A), LEM HTFS (up to 1200A)
- Differential bus voltage measurement
- Vcc decoupling with LC lowpass to filter noise from the 5V buck regulator

The silkscreen has one error: the labels for R9 and R12 are interchanged.

I will ship new orders with the new board.

I need some opinions on the default current sensor:
800A L06P or 400A L01Z or 600A L01Z?

The LEM HTFS is a bit harder to source right now so I'm not considering it a default option.
See less See more
They are all very cheap, and the holes are so small, I would use the largest one available.

Even at 800amp continuous rating the diameter of that hole is only 22mm. That's not much of conductor pulling a continuous 800amps, unless it's a water-cooled copper bus tube.
Hi,

You might be interested in the work, Arlin is doing on a Leaf controller here:
http://endless-sphere.com/forums/viewtopic.php?f=30&t=35387&start=1675#p940054
Not all of the conductor needs to go through sensor
That sounds like a bad idea.. You would not manage to split it evenly, so every cable would have to be individually calibrated. Plus if you don't pull apart individual wires but start soldering something in parallel to divert some current, it will be very dependent on the temperature and drift in time.

I think that 800A LEM is not meant to be used for 800A RMS current, no? You should keep some overhead for peaks (btw, you guys are really getting 800A RMS on your cables?)
I'm running 80A rms and have to set the current limit to 160A. 113A is the sine peak and the remaining 47A must be some spikes.

So judging by that example, the 800A sensor (1200A peak) should only be used up to 600A rms.

There are current sensors for the kA region but no 5V models. In that case an additional +-/15V power supply is needed with -15V tied to the main boards ground and the output divided down to fit the sensor boards input range of 0-5V

That said I want to emphasize again, that slip control does not need current sensors. They are only used for the over current protection.

If the current sensors turn out to be a problem, there are other ways to do over current protection.
Well since I have such a huge potential amp draw to two motors in parallel I am planning on skipping the amp sensors and going to the OEM gate drivers. I have one pair on order to check fit, cause I may have to enlarge my inverter case now.

The OEM gate drivers will have built in short circuit protection.

Now I need to find a HEX voltage step up board(level shifter) for the 6 gate signals.
Need to go from 3.3V to 5V (FOUND THE 5V to 15V converter, now just need the 3.3V to 5V which should be more common)
"The control pins must be pulled low with a buffer that is capable of sinking 15mA in order to turn on the high speed opto coupler inside the VLA500 series driver. A CMOS buffer that actively pulls its output high is recommended for maintaining good common mode noise immunity in the off state. Open collector type drive is not recommended."


Need a 12V to 5V and 15V 6amp power supply also.

Is there a quick level shifter board available for just such an application.
Here is a 12 to 15V module:
http://www.ebay.com/itm/DC-DC-12V-t...548?pt=LH_DefaultDomain_0&hash=item3f31b02ae4

Try running the logic with 3.3V it often works as is. Otherwise put a SN74ACT244 (http://media.digikey.com/pdf/Data Sheets/Toshiba PDFs/TC74ACT240,244.pdf) on a prototype board.

How much current do you need on the 5V rail? The one on the main board provides 3A.
build notes (success finally)

been slow on this project, brand new to stm32. But I finally got it to build (and diff shows the output matches the released stm32_sine.bin.

ubuntu 14,


expanded https://launchpadlibrarian.net/177524816/gcc-arm-none-eabi-4_8-2014q2-20140609-linux.tar.bz2 to a private directory

gcc-arm cross compiler, CHECK



Added the bin dir therein to the path

followed:
https://github.com/libopencm3/libopencm3-examples

ran make on the top level directory,

libopencm3 headers and objects, CHECK


grabbed the original zip with the flash/etc utilities:
http://johanneshuebner.com/quickcms/index.html?en_downloads,14.html

expanded it into my arm tree

got sources, CHECK


scratched head for a long time. finally realized that the .cbp files were for a C/C++ ide called codeblocks, more digging,
settled on http://hivelocity.dl.sourceforge.ne...codeblocks-13.12-1_amd64.debian.stable.tar.xz

brought up codeblocks, tweaked the default compiler to point to my private
arm-none-eabi-gcc and added arm-none-eabi- to the front of the other tools

opened the project sinus.cbp

viewing source in IDE, CHECK


hit build, saw include errors
Modded the CFLAGS and CPPFLAGS lines in Makefile (added -I for libopencm3)

CFLAGS = -Os -Wall -Wextra -Iinclude -I/var/arm-eabi/proj/libopencm3-examples/libopencm3/include/ -fno-common -fno-builtin \
-mcpu=cortex-m3 -mthumb -std=gnu99 -ffunction-sections -fdata-sections
CPPFLAGS = -Os -Wall -Wextra -Iinclude -I. -I/var/arm-eabi/proj/libopencm3-examples/libopencm3/include/ -fno-common \
-ffunction-sections -fdata-sections -fno-builtin -fno-rtti -fno-exceptions -fno-unwind-tables -mcpu=cortex-m3 -mthumb


hit buid, saw linker problems, added -L flag to a libopen ld file directory:
LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -L/var/arm-eabi/proj/libopencm3-examples/libopencm3/lib/ -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections,-Map,linker.map


Hit Build, SUCCESS!


ran diff, no differences between original bin and newly compiled bin, CHECK


TODO: flash

scratched head some more, wondering how programmer connects.
opened the bootloader project in codeblocks firmware_loader.cbp

Saw UART3 referenced.

reviewed:
https://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103.pdf page 10.

hooked up the pl2303mdl to the EXT2 port on the olimex (useful for upgrades even if you don't build)

gussing this should work:
pl2303mdl pin, STM32-H103 EXT2 pin
GND, 6 GND
RX, 14 PB10/UART3.TX
TX, 15 P11/UART3.RX
VCC, 23 +5V USB

Maybe not the ideal setup, but if it works. I plug in the pl2303mdl and the olimex starts blinking anyway... will try actual flashing later.


Edit, wound up using sudo to flash for now. some various flashes, and the green light is back to steady fast flash, so apparent success :)
sudo ./updater /var/arm-eabi/proj/tumanako-inverter-fw-motorControl/src/sine/stm32_sine.bin /dev/ttyUSB0

Attachments

See less See more
oh a little shortcut for the web interface (ubuntu), instead of installing the whole LAMP stack, you can just use the internal server in php 5.4+

sudo apt-get install php5-cli

then cd into the "web interface" directory and run:

sudo php -Slocalhost:8000

then browse on the same machine to http://localhost:8000/

At some point I hope to look at actual control code :)
It would be great to get this project converted to be compatible to work with the LeafLabs Maple IDE: https://github.com/leaflabs/maple-ide
Why do you say that? Arduino (and presumably clones) are horrible for serious development, codeblocks is lightyears ahead for managing a multi-file project and knows how to find declarations and usage of variables for you (though netbeans or eclipse would also integrate the php side, leaning towards netbeans these days).

Plus a controller is kinda "mission critical", bare metal is the only way to go there, you don't want a lot of frills that could cause unexpected delays or bugs or hangs, or impede core development, better to offload bells and whistles to another $3 processor. But he does use a library that abstracts a lot of the IO and whatnot (libopencm3).

Personally I hope to find something like avrstudio for stm32 with a built in chip simulator (and separate assembler files for the occasional timing critical routine without all the gnu asm gobbledygook).
Why do you say that? Arduino (and presumably clones) are horrible for serious development, codeblocks is lightyears ahead for managing a multi-file project and knows how to find declarations and usage of variables for you (though netbeans or eclipse would also integrate the php side, leaning towards netbeans these days).

Plus a controller is kinda "mission critical", bare metal is the only way to go there, you don't want a lot of frills that could cause unexpected delays or bugs or hangs, or impede core development, better to offload bells and whistles to another $3 processor. But he does use a library that abstracts a lot of the IO and whatnot (libopencm3).

Personally I hope to find something like avrstudio for stm32 with a built in chip simulator (and separate assembler files for the occasional timing critical routine without all the gnu asm gobbledygook).
I agree here.
Personally I never do on-chip debugging because its pointless within the real time routines.
I develop the more complex routines on my PC and run them using stubs. You'll also notice that many routines don't access the hardware directly but return some values that are then passed on to the hardware.

E.g. I can call the sine function and print its results to a file to verify that its doing the right thing.

oh a little shortcut for the web interface (ubuntu), instead of installing the whole LAMP stack, you can just use the internal server in php 5.4+

sudo apt-get install php5-cli

then cd into the "web interface" directory and run:

sudo php -Slocalhost:8000

then browse on the same machine to http://localhost:8000/

At some point I hope to look at actual control code :)
Thats great! It'd be good to come up with some bootable disk image that does exactly that. Just kernel+libs+php. Should be reasonable small.
Thats great! It'd be good to come up with some bootable disk image that does exactly that. Just kernel+libs+php. Should be reasonable small.
Just thinking out loud on this fyi, At some point I was thinking of experimenting with connecting my $5 bluetooth adapter to the controller. It *might* work with php for sl4a, but almost certainly I can get to the command interface with an android phone terminal that way (and have lots of gui options). As a developer a laptop is nice, but as a user not so much (and even as a developer having a wireless connection is nice). But make sure you change the pin at least (and the baud). Though a boot disk could be a useful option too for many. Though it is working just fine for now :)

Edit, maybe this for android: https://play.google.com/store/apps/details?id=com.esminis.server.php&hl=en
update, I know it is silly, but I did get my hc-05 to connect directly to the olimex

first I had to change the baud (had to leave the default pin), but set the baud to 115200 using the pl2303mdl to connect to it with the key high (and 38400 baud) over minicom.

and issued
AT+NAME=MCONTROL
AT+UART=115200,0,0
which modifies it from factory defaults

then I plugged the hc-05 into the olimex instead of the pl2303mdl (and used 3.3v this time).

I then fiddled with hcitool scan and rfcomm and bluetooth config till it paired in ubuntu and I could issue commands. Ubuntu sort of got off the rails on needing a specific response when using a custom password.

Then modified the php config and could see the webpage connected to the olimex via bluetooth.

Then tried update over bluetooth using /dev/rfcomm0, seemed to work.

have not been able to have a conversation with the controller via android bluetooth terminal, might be a linefeed thing or something.
See less See more
This is definitely sounding good.
I'm having a constant struggle with the line feed. The \r character works best in most terminals but apparently not on your android.
Thanks, "android bluetooth terminal" was a braindead terminal with zero translation options, I tried "blueterm" and was seeing results right away, I went into options and changed the incoming LF character (0A, \n) to ODOA and everything lines up on the left now.

FYI, you have a stray \r in terminal.c line 68
term_send(usart, "Unknown command sequence\r");

\n seems to be ubiquitous otherwise.

most serial terminals need both 0D (/r, carriage return) and 0A (/n, new line) to display correctly, it is useful as a primitive form of cursor control, i.e. a status line that changes without scrolling the whole screen would just send /r.

Last note, I don't envision interacting directly with the motor controller in my final projects, but rather some user facing controller that can talk to the motor controller (i.e. via usart3) and the bms and the charger, but for development it is good stuff, I can tweak the motor controller with my phone! :)
441 - 460 of 2284 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top