Category Archives: STM32 Development

SW4STM32 – Short Review

System Workshop for STM32 or ac6wb or SW4STM32 is an Eclipse based, free IDE supported by ST. I started using this a while ago and the great thing about this is that CubeMX generate start-up code, project and everything for this. It makes it ideal for doing initial testing and to get off ground fast.

One word about CubeMX is that you can download different versions of their library and some simply do not contain all files as Project are generated. So the projects don’t compile. You just have to find a version that works for you. Except for that it is great.

As for SW4STM32 the best I can say is that it works – it is ok. A decent editor, debugger is decent and it’s a all-in-one that allow you to write code, compile, debug, download it etc. It is all you need and it’s free and supported from CubeMX and ST.

Sometimes as I download SW4STM32 lock up and I basically have to stop it and start again. It is annoying, but I can live with that. Using SW4STM32 is an option and as CubeMX integrate middleware including FreeRTOS you really get off ground with your projects fast with a standard CMSIS based project.

Another annoying issue is that messages as you can’t connect to SWD can be confusing. I can often have a it of connection issues before I get started, while CoIDE always was straight up. But, this is mostly me being more used to CoIDE than SW4STM32.

As an embedded C/C++ developer I usually have 1 comment – where is the C++ support? SW4STM32 have a button that change your project to C++. And this is GCC toolchain, so it will support C++, but CubeMX generate C so you need to convert that manually. I have not bothered digging into that because my usage have been electronics testing so far.

The example above is for MC3X60 running the motor Trapzoidal. What I did was to grab a FreeRTOS task and just run in a loop with a delay between the steps. Took me around 5 minutes to have the motor running.

The main limitation in SW4STM32 is STM32 – it only support STM32 out of the Box.

The project organization is a bit dictated from CubeMX. I live with that for now, but I would recommend that you organize your own projects and even support multiple IDE’s or build tools. Don’t let an IDE rule your life.

What IDE should I use?

I am a big fan of things that just work, which is why I have stuck to Coocox and CoIDE for years. But, as it now looks like this tool is dead I basically need to move on.

Coocox had a very good concept and was one of the few Eclipse based IDE’s I liked, so it is sad to see them go. But, I understand they could not make money from their business model and in the end gave up. Their site is now down and I am stuck with version 1.7.8.

Looking at alternatives I find the following:

SW4STM32 is free and supported by CubeMX. I will discuss CubeMX a bit later.

Em::Bitz is free and have reached version 1.1. This originate from Code::Blocks and was previously Em::Blocks that now is forked into Em::Bitz. The drivers supported here are only the old drivers, but you can dowload and set up new ones as well.

TrueStudio is a commercial IDE, but it has a fully free version for STM32 as well. It is also supported from CubeMX and is Eclipse based.

I will be evaluating these options over the next days and share my findings with you. The one I am curious on is EmBitz. This is unlike the others based on Code::Blocks and written in C++. I mention this because performance do matter and I hate tools that forces me to care about Java versions installed on my computer. Why should I as a user need to care about what my tools are programmed in? But, using a Java based tool you often need to do that. The other issue is that C++ developers tend to have a better gasp of what is needed for Embedded C/C++ development. With one exception – CoIDE will be missed. Their concept was good.

3-4-phase – Motor Controllers

I have a load of motor controllers that I want to continue on, but to focus on the more advanced ones.

MC4X60V50A

This is an early draft of rev 1.1 of the MC4X controller. Notice the heavy wiring at right to support 50A + all components top-side so I can add heat-sink on the PCB. All transistors have pad’s and being cooled at bottom. Two temp sensors added between MOSFET’s.. INA194 as Current Sensors, CAP’s on the PCB etc.

The results from the previous 1.0 version was actually so promissing that I am looking forward to this one. But, it is still work in progress.

MC3P60V50A

This has been in the pipe a few weeks. It is a dedicated 3-phase controller. It is 15mm more narrow than MC4X60V50 and uses DRV8301. I want to do an upgrade before I ship for this – some of the small capacitors are 0603 and need to support 60V – that will not work + I need a better place to mount the main capacitor.

Comparing MC3P and MC4X I must admit that I get a lot of functionality for those 15mm extra. MC3P is a bit smaller, but MC4X can do the same and more. I still want to do MC3P because I want to play with DRV8301. ANother change is that I consider putting wires on top so I can use a 100x25mm heat-sink on PCB-bottom.

Another concern is that I on this planned thick PCB lanes on power – simply creating a thick solder path. I am considering upgrading that to wires like I did on MC4X.

MC3X60V3A

This is the smaller of the 60V design. First test failed at 35V, but I have been advised to make a change on the DC/DC that I want to try out.

MC3P28V3A

This is the smallest based in DRV10983. It works, but I am not impressed over DRV10983 speed regulation. I will find more time to play with the I2C interface on this, but I need to see a better controller if I am to continue with it.

CAN Interface

I finally got revision 1.1 of these boards yesterday, so I can get on with this adapter. The main error on 1.1 was lack of crystal and I realized I needed the crystal for USB as I tested.

I like CubeMX, but I fail to undestand “designers” that want to create a “HAL” and only do low level, MCU specific interface. In this example I would have liked a function to select bitrate, but are left with setting up loads of timing details.

Even more annoying was that the generated project for STM32F105RB do not want to compile due to lack of files. This is where auto-generation and I usually separate.

 

CubeMX FreeRTOS Config

The config system in CubeMX allows you to configure and generate code for all components you have included, including FreeRTOS and libraries. This page show the config for FreeRTOS and it allows you to create a list of Tasks as well as message queues.

The folders on top are

  • Config Parameters
  • Include Parameters
  • User Constants
  • Task & Queues (shown here)
  • Timers and Semaphores
  • FreeRTOS Heap Usage

The reason why I like this is because I don’t know FreeRTOS and within a few clicks I am using it and on my way into functionality. FreeRTOS is also included in ESP32 IDE supporting multiple cores and have been around for years.

STM32CubeMX

This shows the STM32CubeMX for my 3 x RS-X PLC Module. I find this tool to be quite usefully as it allow you to set up the clock, configure each function and wire the MCU. It also generate a nice PDF document with all details as well as a starting project with all init code as well as FreeRTOS should you want it.

The generated code opens in System Workbench for STM32 and the only complain is that they only support C. But, you should be able to get C++ with a bit of manual work.

It all works well with a low cost ST-Link, so you are on your way blinking a status led within minutes.

System Workbench for STM32 is far behind CoIDE and CooCox, but I still use CoIDE 1.7.8 and as CooCox seems to be down (?) I need to move on. My main concern is lack of C++ support which sadly is very common in many embedded IDE’s. Returning to STM32CumeMX, this tools is free from ST and a big time saver. It download latest drivers and give you working examples on how to initialize the MCU. It also warns you about wiring conflicts and does the job of setting up the complex clock.

PLC Assembled – 1st test

Been a lot of motor controllers lately so I finally decided to assemble part of my PLC system. What you see here is the motherboard with a simple RS-X module connected. Not all components are assembled yet, but processor is alive. This board have 3 x fully galvanic isolated RS485 circuits and a 2 x 10Mbps backbone. It was selected because it’s a good, simple starting point for SW development.

The STM32F405RG is excellent for Plain. With it’s 1Mb Flash and 196Kb SRAM it is an excellent test bench. I need to make a similar module for CAN, but that can wait.

I must admit it is a bit of nostalgia to work with something that looks like one of the computers I assembled in the 80ts.

I only ordered one module because I want to play with the mechanical design a bit before I start adding modules. I notice far more issues with a physical module than with a 3D module.

The MCU is currently ticking on 8Mhz using the internal RC, so it will be interesting to see if I got this right and are able to tick the MCU at 168Mhz with 3 x 180Mhz DC/DC converters on the same module.

X-Mas Tree Decorations – Part 1

Every year around christmas I tell myself that next year I will have electronic christmas decorations, and as next year arrive it’s forgotten until it’s to late. A combination of STM32F030 and ULN2003 is excellent for a very small x-mas tree PCB with blinking LEDS and home made tree lights. In fact I have done this circuit before as a PWM driver with a single ULN2003, so what I will do is to make multiple PCB’s with LED strings connected through a RS-X (12V + RS485). These can then be wired in the x-mas tree and controlled by RS485 connection and 12V LED driver.

STM32F030F4 is excellent for this purpose, it cost 0.4 USD from AliExpress and all I need are sufficient to cover 20-40 of these. A 5A LED Driver should be more than sufficient. We make a harness with connectors up the tree where each decoration connect to this is a star network.

Application can be constant or random patterns as a start to make it simple. In fact I could make a small ESP32 control system with RS485 at bottom so I get the entire c-mas tree on Wifi or bluetooth. This could be a lot of fun.

The cost of this will be 2-4.- USD per PCB, around 10.- for the control system and a bit for the wiring. I probably end up spending around 100.- USD for a very attractive x-mas tree light system.

I can probably use up to 200mA per ULN2003 and a quick calc is that a single LED uses around 5mA, so in short – I will run out of space and LED’s before I run out of power. But, we should limit each decoration to ca 250mA max – I will probably need far less.

MC4X60V goes 50A

I decided to remove some of the PCB lanes and replace them with high current wires to support 50A currents. I had to extend the board ca 1.5mm at right, but to compensate I also remove the connectors because I need high current support all the way. I like having connectors for <10A solutions and playing in the lab, so will see what I can do. This will also free up 2-3mm that I desperately need at left.

At the end it simply made no sense to continue with 15A limit as I realized I would be using the same components and same space for a 50A design. And yes – this is a 50A design. The power wires are 3mm in diameter that actually is something like 64A while the 2mm wire for each channel is ca 41A. But, in addition to this you also have heat-sink at bottom as I connect the PCB itself to the heat-sink. I am confident that I will get sufficient out of this board.

Updated 4X Motor Controller

This is just a simple block diagram over MC4X design to illustrate it’s components and summarize the planned changes.

  • More communication ports CAN and RS485. I hope to save some space and add more communication ports to support redundancy etc.
  • New PSU based on TPS54x60 providing 14-60VIN or 10-16V in. Support 10-12V for Gate driver, 5V for Hall sensor and 3.3V for MCU.
  • Added 2 temperature sensors on board located between MOSFET’s.
  • New INA194 base current sensors.
  • New SOP Advance MOSFET footprint will support both SOP-8 and SOP Advance allowing a wide range of MOSFET’s to be used.
  • 4 separate channels with IR2103 as Gate driver.
  • 4 separate high side current sensors.
  • 4 separate BEMF sensors,
  • Separate Hall Sensor port/Encoder port for additional positioning feed.
  • Separate end point connectors for positioning calibration.
  • Replace 2.57 pitch connectors with smaller 1.27 pitch
  • Move main caps on board
  • Change size to fit heat sink 100x40mm
  • Stick to 15A design as objective, maybe increase to 20A depending on what PCB can manage
  • Added pull-downs on PWM driver to avoid that gates are floating.
  • Use JST Micro as channel connectors.
  • New SWD Connector.

As for now I am still testing rev 1.0, so things are not written in stone. As for the new 3P controller I have put that on hold. I decided I wanted to do rev 1.1 of MC4X first. I do after all also have 3X coming in any day now.

I still have plenty of DRV10983 chips and boards so I will be playing around with that as well – we got plenty of motor fun coming up.

I have ordered separate test circuits for INA194 and this part is the only one that concerns me because of noise. I need to see if I can get a INA210 working on the existing design to test noise and noise filters.