Several questions about firmware

Post Reply
Ampchamp
Posts: 10
Joined: Tue Jan 15, 2019 1:53 pm
Location: Karlsruhe, Germany

Several questions about firmware

Post by Ampchamp »

Hello to all,

first of all - as this is my first post in the forum - a short introduction from my side:
I'm a 46-year old electrical engineer working at a German automotive supplier and want to build my own inverter, based on Jens' Design.

As I'm a hardware guy, I have some questions about the software, that might seem a little trivial to most of you.
So please forgive me two or three dumb questions ...

I number the questions, so everyone can retrace the answers and it's easier to add even more questions (and surely there will more... I know myself.)

But let's start with the topics:
1) Which compiler do you use? Is it a free one?
Which compiler settings have to be used, is there a config file?
Can everyone compile the project? Or is it restricted to Jens only?

2) If I have a completely erased (or empty) µC, how can I flash the bootloader?
Do I need a genuine ST programmer or is a standard JTAG interface sufficient?
What do you use?

3) As the KTY38/84 temperature sensors are discontinued, I'd like to implement some more temp sensor types, such as KTY81/82 or screwable NTCs.
Should I modify the "temp_meas.h/.cpp" files and publish them here?

4) In "Software Principle" you mentioned, that the logic of amplitufe limitation "kicks in 1/3 of the time when a full amplitude sine wave is modulated."
Isn't this a lot of "DC", when everything above 0,87 x Umax is hardly limited (clipped)?
Wouldn't it be better, to use a sinewave with added 3rd harmonic, for this would result in a smoother engine run and thus produces less noise and vibration?

5) In which software module is the sine wave defined? Is it in "stm32_sine.h" or in "sine_core.h/.cpp" (in both, I do find sine wave data)
So, if I want to try the sine wave with added 3rd harmonic, which file do I have to modify?

6) At "mainboardv1.1" it is mentioned that the input PC9 can be connected to the desaturation output of the IGBT drivers.
As the used SI8261 doesn't have this feature, is this function implemented in the software though or is this signal only triggering the failure signal PB12 on a hardware level?

So far for the moment, thanks for your replies!

CU, Fabian.
arber333
Posts: 3276
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 239 times
Contact:

Re: Several questions about firmware

Post by arber333 »

See this page if you dont want to compile yourself...
viewtopic.php?f=2&t=6

You can still get those sensors
https://www.ebay.co.uk/itm/1pcs-NEW-KTY ... SwB09YCEBX

But i agree with novelities. Johannes is it possible to implement digital sensor reading? Like DS18S20 sensor? We could have many sensors connected to a single bus. https://datasheets.maximintegrated.com/ ... S18S20.pdf
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Several questions about firmware

Post by nailgg »

Project is compiled with GNU Arm Embedded Toolchain. It's completely free and you can download it from here: https://developer.arm.com/tools-and-sof ... /downloads

Everybody can modify and compile the project for themselves. To compile it the Makefile already has everything configured, you just need to do "make get-deps" only once to download and compile the libopencm3 library (the STM32 Cortex-M3 library this project was developed on). You might need to modify the Makefile for the compiler binary file addresses if you're on Windows, by the way.

For your third question: You should both modify temp_meas.h with the ADC readings of your temperature sensor, and you will need to modify temp_meas.cpp as well for the tempmin, tempmax, step etc. values. If you can make sure with your temperature reading values, I guess Johannes would love adding it to the main branch.

For the 4rd/5th questions: the sine wave data is found in sine_core.h but you don't need to modify it to add the 3rd harmonic, as it's already added by the software (on the fly) with some simple math, in the CalcSVPWMOffset method (sine_core.cpp) :)
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Several questions about firmware

Post by johu »

Hi Fabian,

2. I use this one: https://www.olimex.com/Products/ARM/JTAG/ARM-USB-OCD-H/ . But there is apparently much cheaper ones (ST-Link) which work as well
4. No worries, no DC is injected. Only one phase is constant 0/1 while the other ones still produce sinusoidal output. So phase-to-phase there is no DC.
5. You shouldn't have stm32_sine.h so I assume you have some old version. Get the latest here: https://github.com/jsphuebner/stm32-sine

Cheers to Karlsruhe from Johannes (not Jens ;) )
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Several questions about firmware

Post by johu »

Oh, forgot to comment on 3: preferred way is to get a github account, fork the project to it, make a change (e.g. add a temp sensor) on a separate branch and then make a pull request in the original project. That way you are also officially accounted as a contributor.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Ampchamp
Posts: 10
Joined: Tue Jan 15, 2019 1:53 pm
Location: Karlsruhe, Germany

Re: Several questions about firmware

Post by Ampchamp »

Hi,

@Johannes: I'm very sorry for calling you Jens :shock:
I was so deep in technical thoughts, that my mind turned wrong with your name...

But thank you all for your replies!

to 1) and 2) I'll get the tools and try to get everything running.
Probably, I delay the compiling topics (and leave this to the specialists)

to 3) For good reasons, glass housed components are not allowed at automotive electronics.
So even if they're still available, I don't want to use them. And also, they are difficult to mount to the heatsink.
I prefer the KTY81/82 or the K45 NTC. So, I will calculate the values for "temp_meas.h/.cpp" with additional sensors (in combination with the 1k2 pullup) and try the way Johannes described with the new branch on github.

to 4) I think, I have to dive a little deeper into the code to understand, what happens there.
For a hardware guy, unfortunately this might last a little longer... But in case of doubt, I'll come back here.

to 5) You're correct, I had an old version. Thanks for the link, I've downloaded the new files.

But I have also a new question:
6) At "mainboardv1.1" it is mentioned that the input PC9 can be connected to the desaturation output of the IGBT drivers.
As the used SI8261 doesn't have this feature, is this function implemented in the software though or is this signal only triggering the failure signal PB12 on a hardware level?

CU, Fabian.
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Several questions about firmware

Post by johu »

Hi Fabian,

if the drivers don't implement desat detection the system relies on the current sensors for over current protection. It is implemented with a 4-way comparator (2 current channels, one negative limit, one positive). Threshold is programmable.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: Several questions about firmware

Post by dima »

Hi Fabian,

Which OS do you use to compile the source code? In Windows it is a little tricky.

For Windows you will need:

1) Python https://www.python.org/ftp/python/3.7.2 ... -amd64.exe
2) MSys2 https://sourceforge.mirrorservice.org/m ... 180531.exe
3) ARM Compiler https://armkeil.blob.core.windows.net/d ... -win32.exe
4) GCC Compiler http://sysprogs.com/files/gnutoolchains ... c4.8.1.exe

Code: Select all

make.exe clean
make.exe
You need to compile the libopencm3 library first (not generic but Johannes clone) and use that against the inverter source code. I have a PowerShell if interested https://github.com/dimecho/Huebner-Inve ... ource.ps1
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Several questions about firmware

Post by nailgg »

Installing the complete toolchain with debug, flash etc. support on Windows with a proper IDE needs some effort. I created a how-to for myself, might convert it to a wiki some day :)
aravinth
Posts: 14
Joined: Sun Sep 13, 2020 8:34 am
Been thanked: 1 time

Re: Several questions about firmware

Post by aravinth »

nailgg wrote: Sat Apr 27, 2019 1:50 pm Installing the complete toolchain with debug, flash etc. support on Windows with a proper IDE needs some effort. I created a how-to for myself, might convert it to a wiki some day :)
Hey Nailgg any progress on that how-to ??
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Several questions about firmware

Post by nailgg »

aravinth wrote: Fri Nov 06, 2020 4:56 am
nailgg wrote: Sat Apr 27, 2019 1:50 pm Installing the complete toolchain with debug, flash etc. support on Windows with a proper IDE needs some effort. I created a how-to for myself, might convert it to a wiki some day :)
Hey Nailgg any progress on that how-to ??
Sorry for the late reply, unfortunately no. I couldn't keep up with the code on GitHub because I have too much custom code changes for my car on my local fork. I haven't looked at the code for months and it has significant changes since I worked on it.
  • I was using Eclipse as the IDE with the plugin "GDB Hardware Debugging".
  • Use arm-none-eabi-gdb.exe as the compiler.
  • For debugging, I was using ARM-USB-TINY-H and OpenOCD.exe as an "external tool" under Eclipse. ST-Link v2 can also be used instead. Configuring the OpenOCD with the correct scripts is a bit tricky. After configuring it correctly, the GDB debugger must connect to OpenOCD through port 3333. This was how I ran the OpenOCD, the scripts might have been deprecated by now.

Code: Select all

C:\openocd\bin\openocd.exe -f c:\openocd\share\openocd\scripts\interface\stlink-v2.cfg -f C:\openocd\share\openocd\scripts\board\olimex_stm32_h103.cfg
  • To run the makefile I was using msys on Windows. One can run bash scripts on it under Windows. I was both compiling and flashing the code through Eclipse with custom "Make Targets". Two different targets (Build and Flash) was running different bash scripts, that runs the makefile with different parameters, through msys.
  • To compile the code, libopencm3 is needed. I was compiling the libopencm3 library myself and you needed Python for it back when I was working on it. Now there is the get-deps option.
I know the list doesn't cover the whole process with much detail, but could give you some hint. There are much easier options if you only need to compile the hex files. Just get a raspberry, or install a Linux distro under a virtual machine. I needed it for debugging the code.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Several questions about firmware

Post by jon volk »

Having tried numerous flavors in windows, Linux install with virtualbox was painless.

An overly thorough step by step can be found here. https://www.theodinproject.com/courses/ ... n-overview It will walk through setting up virtualbox and git. From there the readme file on Johannes project will get you the rest of the way to compiling the inverter software.
Formerly 92 E30 BMW Cabrio with Tesla power
Post Reply