Category Archives: STM32 Development

Low Cost Programmable Load

I need a load for testing and fancy a programmable load. My first idea was to use a resistor array and a relay operated switch board as illustrated below.


Next as I looked into more intelligent techniques I also realize how easy it is to make one using a DAC and power transistors. The concept is illustrated below.

I borrowed this illustration from the net, so we can use a MCU with DAC+ADC for the job and add a HMI, transistor array and heat-sinks – should be very doable.

MC4X15A – Motor Driver Testing

I am so far happy with the MC4X15A PWM channel with the exception of the current sensor. I have 3 more channels to solder up, so I will do the next without the low pass filter for comparison. I did not like the scope pictures, but will be interesting to see what I can do in software.

This picture illustrate some of the challenges involved in scoping. I am using a 2nd SWD adapter to get hold of the 4 pins so I can scope them while testing. As mentioned while I meade this I intend to destroy a few boards to learn the driver limits. I accidentally burned transistors with a shortcut, so will be interesting to see the limit as I add heatsink.

I am also running the MCU at 8Mhz yet. It will be interesting to see what happens as I increase frequency and things get more sensitive as I have a lot of noise at moment. The HEXFET’s have a 30V limit, so if the PSU noise is an issue I will replace the DC/DC with a 78M12. One thing that works well is the supercap. I am surprised of long it keeps the MCU ticking after power-cut and it should do wonders in absorbing spikes and protecting the 3.3V.

One of the next things I will do is to solder up a PWM channel on a separate board and burn it. This test is a bit tricky as I don’t have a Lab PSU to support the test yet.

INA210 Tagging

I wanted to share this picture of a INA210 through a microscope. The size of this component is ca the same as a 0603 Component with 6 pins. It is small, but soldering it is not the issue – this bugger have 6 pins and where is PIN 1? I assume it is top left on the current picture, but smallest component I ever have soldered and unclear tagging – yeah – how fun.

 I was a bit worried about soldering these for hand, but that seems to be ok with a hot air nozle as long as I can see between the legs and avoid short-cuts. This is a SC70 package it is 2/3 of SC23, and to be honest a 6-pin SC70 – the diodes did not feel so bad as they had 5 pins, but this was a struggle. I think I should consider an alternative solution, but lets see how well this Works first.

ESP32/STM32/Raspberry PI – all in one dev kit

Starting at left is a ESP32 Breakout board, then one of my own STM32F405RG breakout boards, a 5″ HDMI, Wireless keyboard and Raspberry PI 3 with my 5 port Hat – and your right it’s a different Hat with screw terminals, so I do have 2 x 5 port Hat’s working.

 What I will do here is to wire up SPI between ESP32 & STM32 for testing, and I can add CAN breakout boards etc getting the boards to communicate. The only drawback here is that I can only use one SWD at the time, but I will get around that.

Raspberry PI Wiring

This shows a Raspberry PI 3 with a Communication Hat, Display and mini keyboard. This is basically all the hardware I need for a very advanced CAN Adapter & Analyzer. The main reasons I am skeptical is the wiring needed on this solution. Using a HDMI display is very powerfully, but you need a large project box for this. The total size and cost of the adapter adds up. I seriously which someone would create a more box-able display solution for Raspberry PI – one that take into account the Hat option.

Raspberry PI – 3 x RS485 & 2 x CAN Hat

This is a 5 port communication Hat mounted on a Raspberry PI 3. It contains 3 x RS485 and 2 x CAN ports. The design is not new for readers of this blog, but it is actually the first time I assemble rev 1.1 – just before I am about to order rev 1.2.

The colorfully display is because I am using 1206 led’s and saving old parts – all components on this was re-used from rev 1.0 boards. What amused me a bit is that as I mounted the MCU and switched Power on the old test program still worked. I have yet not broken a STM32 by soldering it on/off boards – quite impressive actually.

Functionally this Hat is ok, but mechanically I ordered a few Hat’s before I checked the drilling holes exactly, so rev 1.2 will correct this. I will also replace 0804 and 1206 with 0603 components + 2 leds per port is a bit overkill. I think if I reduce to 1 per port and mount them on the side that is better. Also cleaning up the line driver and replacing the 3P connector with a 4P for RS-X 12V + differential signal. I might have to make this a 2+2 port for that purpose.

 I also want to do an experiment. Both CAN and RS485 are differential signaling, so I wonder if I can get RS485 to work with a CAN Tranceiver and what quality it would have? The issue is that if I can do this I can more or less make the 2 CAN ports switchable between CAN & RS485. It is worth a try!

Galvanic RS485/CAN

Since we talk about galvanic RS485 & CAN Adapter’s I guess it is time to visit this project as well. The universal adapter below was something I started last time I needed CAN. This adds W5500 and ESP12-E + NRF in addition to CAN & RS485.

I never made a revision of this Board, but it served a purpose to test CH340G, STM32F405RG and ADM2582E together. The Board above with the added coil was after my struggle to get STM32 ticking at 168Mhz.

I never tested ADM3053, so that is what I will do next. I see no point sending for a new PCB including parts of this design before I have completed this test.

As for the adapter above – this has in many ways been a big success because I have corrected and re-used a lot of the design I did here, but I will not finish this adapter as such. ESP32 is so much better than the ESP12 or ESP8266 based options. I do however have things left to test on this Board.

Why not Raspberry PI as CAN Adapter?

This is the rev 1.2 of my 5 port Hat with 3 x RS485 and 2 x CAN. I never ordered this PCB because it is only mechanical changes from Rev 1.1. But, using this or a galvanic version with Raspberry PI is an option for my CAN Adaptor plans.

The advantages with this is that Raspberry PI have an excellent HMI option. It would also enable a PLC style adapter where you add on what you need – but it would be a much larger solution as well.

The size difference from a packed, single board solution is not dramatic and it offer other options as you get a proper display, keyboard and a full Linix computer to back it up.

Not so mini CAN Adapter

This is the same drawing as the previous post, but I added the TF Card option. Basically this is a small mini-computer Complete With display, keyboard (in the display), Wifi, Storage etc. Just for the record it actually got more “disk” and RAM than my first IBM Compatible PC.

I have never done a TF-card Interface, but I have some breakout boards laying around. As mention you can actually buy this on the NET known as “CAN32” for ca 39.-USD. It comes as a specialized breakout Board for ESP32. But, the good things is that I can easily assemble this on a vero Board to get started – and since someone else have made firmware for this we can use their project and modify it as a starting point.

What I want to achieve here is a CAN Tesrter, Analyzer & Adapter – all in one. I need CAN connectivity and I need to see what happens on several CAN Networks simultaneously. As mentioned earlier I will use a STM32 to deal with CAN and make this galvanically isolated later, but this is something I can wire up and start with while waiting for PCB’s.

Assuming the TF Board Works out I should also add this to the larger Board. I also think I want to Mount the display on ESP32 and if I have Space add the 16 analogue IO lines from STM32 as a separate port.

This design start to make a bit sence because we now use ESP32 for Wifi, HMI, Storage, while we leave CAN and IO to STM32.

The last part of this project is boxing it. In fact, we could use Bluetooth to connect to our phones/tablets as HMI rather than adding a UART based HMI as well. With Wifi I can obviously connect my laptop as HMI, but the reason I explore other options is because my laptop usually is occupied otherwise and I need the extra screen. Fiddling around swapping screens and turning Smart Phones orTablets on/off is not always the most convenient choice, so having a physical display on the adapter is a priority IMO.

It’s only one flaw here – I am making all this for CAN while I myself am a heavy user of RS485/RS-X. The STM32 I use here have 5(6) UART’s, and if I commit on using STM32F405RG I have 2 x 10Mbps RS485 capable ports that will be very handy for sniffing on my PLC system later. The only thing is that I can’t use galvanic isolation at that speed, but I can live with that.  Woops – wrong! Checking the datasheet of ADM2582E it supports data rate to 16Mbps!

Puh – I better stop writing before I add more into this – my only concern here is what speed I can get between ESP32 and STM32 on UART or SPI. I am hoping on 40ich Mbps on SPI, but that is yet a unknown that I need to investigate. I think ESP32 is capable of this, but it’s more if I am capable of using it – lets see.