Category Archives: STM32 Development

32 x Servo / IO Capability Map

This table is a all 32 channels on the 32 x Servo / IO Hat mapped out per channel. Explenation under the table.

Ch1 PC1 Analogue In
Digital In
Digital out
Servo
Software PWM
Ch2 PC2 Analogue In
Digital In
Digital Out
Servo
Software PWM
Ch3 PC3 Analogue In
Digital In
Digital Out
Servo
Software PWM
Ch4 PA0 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch5 PA1 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch6 PA2 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch7 PA3 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch8 PA4 Analogue In
Analogue Out
Digital In
Digital Out
Servo
Software PWM
Ch9 PA5 Analogue In
Analogue Out
Digital In
Digital Out
Servo
Software PWM
Ch10 PA6 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch11 PA7 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch12 PC4 Analogue In
Digital In
Digital Out
Servo
Software PWM
Ch13 PC5 Analogue In
Digital In
Digital Out
Servo
Software PWM
Ch14 PB0 Analogue In
PWM
Digital In
Digital out
Servo
Software PWM
Ch15 PB1 Analogue In
PWM
Digital In
Digital Out
Servo
Software PWM
Ch16 PB2 Digital In
Digital Out
Servo
Software PWM
Ch17 PB10 PWM
Digital In
Digital Out
Servo
Software PWM
Ch18 PB11 PWM
Digital In
Digital Out
Servo
Software PWM
Ch19 PC6 PWM
Digital In
Digital Out
Servo
Software PWM
Ch20 PC7 PWM
Digital In
Digital Out
Servo
Software PWM
Ch21 PC8 PWM
Digital In
Digital Out
Servo
Software PWM
Ch22 PC9 PWM
Digital In
Digital Out
Servo
Software PWM
Ch23 PA8 PWM
Digital In
Digital Out
Servo
Software PWM
Ch24 PA9 PWM
Digital In
Digital Out
Servo
Software PWM
Ch25 PA10 PWM
Digital In
Digital Out
Servo
Software PWM
Ch26 PA11 PWM
Digital In
Digital Out
Servo
Software PWM
Ch27 PA12 Digital In
Digital Out
Servo
Software PWM
Ch28 PB3 PWM
Digital In
Digital Out
Servo
Software PWM
Ch29 PB4 PWM
Digital In
Digital Out
Servo
Software PWM
Ch30 PB5 PWM
Digital In
Digital Out
Servo
Software PWM
Ch31 PB6 PWM
Digital In
Digital Out
Servo
Software PWM
Ch32 PB7 PWM
Digital In
Digital out
Servo
Software PWM

Analogue In means it has an ADC capability on the channel. This can sample at a very high frequency. It is 15 of these

PWM means we have a Hardware PWM signal with a very high frequency capability. It is 23 of these.

Analogue out means it connect to a DAC. It is 2 of these,

Digital In & Digital Out is on all 32 channels.

Servo is available on all 32 channels and is the default configuration.

Software PWM means we bit-bang the pin in software to create a PWM signal. Max frequency is ca 10KHz. Available on all 32 channels.

An updated version of this table can be found in Annotated Schematics (coming soon). Pin’s have all cababilities as per STM32F105RB capabilities, but more advanced features will need custom modified firmware to access.

STM32 with Visual Studio Code

Visual Studio Code is more an editor with debugger support than a full IDE, it takes a bit fiddling to set up and get right. Basically you don’t have any setup screens and have to edit your project in files with XML syntax. I am not sure if I will use this for everything, but VSCode has definitely come to stay – it simply is to handy to have around as code editor for various things alone.

VSCode itself is a framework that allow extensions to be added, and extensions exist for a lot of things. STM32 is currently supported through PlatformIO (www.platformio.org). Sadly the STM32 support is still a bit limited, so I have not been able to test to much and setting it up is a bit fiddly. PlatformIO IDE is not really free – they maintain a community version, but that seems to lack essential features to be of any real use.

One annoying issue with VSCode is that it’s folders are physical within a hierarchy – myself I arrange the project on top with a strict set of sub-folders. What IDE people use differs with developer so I like to hide this in sub-folders. That does however not prevent me from editing

All in All – Visual Code got my interest, but I am not sure about Platform IO yet – neither am I sure I actually could commit a full project to VSCode alone.

Ranging Sensor Breakout

You will find breakout’s for VL53L0X in numbers on net shops, they are still a bit price around 10ich USD – but the chip cost 2.6 USD so I expect them to drop down fast – competition & popularity is to high for them not to as soon as the vendors sort their logistics out.

Having a breakout is however not the same as having a working solution. The breakout above is one of the better I have seen being close to an actual, working sensor.

VL53L0X Ranging Sensor

This is VL53L0X from ST, a 4.4 x 2.4mm ranging sensor that can measure accurate distance up to 200mm (2 meters). This is a BGA with a I2C interface and have an ST interface library. Several breakout boards exist, but we need to be a bit clever here – I want the sensors mounted in all directions of a robot, so I need more than just a basic breakout board. Being a BGA I hesitate a little, but I think I can mamnage to solder these – if I can afford to buy them that is 🙂

The Belly of The Bug

If I ever want to know where my wife’s cat’s are hiding I only need to start this 12 servo monster – I instantly have a horde of cat audience…

I will mount the control system on the inside of the box, but I still have to sort out the battery & PSU. Knowing that my Lab PSU was failing I want to redo some of the power tests. What happened with the Arduino stack was that Arduino kept re-booting as the Servo’s started. I now believe this might be caused by the Lab PSU and that I can get away with less peaks than I calculated.

Another solution is to get a 7V (2 cell) battery and use that directly avoiding the need of a PSU handling 10A in peaks. The Servo PSU are separate from MCU PSU as well, so we can avoid that the Servo’s drag down the MCU anyway.

As mentioned earlier the legs here are actually 2.- USD pan&tilt camera holders misused for this purpose – I need to look for a different solution is these will break after some usage, but not before they have served their test purpose. For me this is about having a bit of fun while I am testing concepts related to Plain & distributed control systems :).

I initially planned on using Raspberry PI 3 or 2 here, but Zero W is perfect for this usage – a Minuture Linux computer with Wifi & Bluetooth all for 10.- USD.  I don’t need the bigger Linux computer for operating the robot – my STM32 does that much better, but RPI add’s the Wifi with security + it adds the AI capability – I can actually program the robot to remember map’s and how to get from A to B etc – meaning it becomes more than just a ROV (Remote Operated Vehicle).

My wife’s cat’s are trying to break into my lab…

Wireless 32xServo (IO) Controller

I maintain Zero mounting holes on all my Hat’s because it’s an easy & cheap way to assemble a wireless control system using the capabilities in Zero W. The picture above show Zero W on top of a 32xServo Hat. I have only populated 16 of them, but all 32 are available since the Hat fit’s nicely on the inside. The pic below show a Zero booting up with a 5″ TFT display. I tried booting the Zero W, but realized I need to update my image.

You can see the red dot from the 32xServo Hat mirroring in the display. The only practical issue here is that SWD is hard to get to – which isn’t a real issue as I just as easy can move the Zero to bottom of the stack for development – but, I did draft special SWD adapters for this purpose earlier that allow me access from the side (See 3D below).

This can be clicked on/off from the side while the Hat’s are inside a stack. The use of 1.27 pich headers is just about the right hight for this. The one thing this SWD adapter lack is a Boot and Reset button. I seldom need those, but I prefer to have them on the adapter – not waste space on the boards.

The 32xServo or 32xIO have the advantage that the signals are connected directly to the MCU. The new version (not shown here) have TVS diodes on each signal, but you can otherwise use the signals as per MCU capability for in/out. This makes this a very ideal wireless controller because you have 32 very capable channels + pointing at the obvious a Raspberry PI Zero W with camera port. I will re-assemble my 6 legged Robot with this on top later.

STM32 C/C++ IDE Review

I am constantly looking out for IDE’s to improve my productivity in Software, so I wanted to share with you my recent experiences in the area. This review focus on STM32 development.

  1. Visual Studio.

Having used Visual Studio since it came around as Visual C++ 1.0 some 20+ years ago it has always been my first choice if available. I have tried to replace it on Windows development several times because it used to be Windows only, but always ended up returning. These days, with Visual Studio being free and moving into Linux, Android, STM32 and Arduino to mention a few it’s not any discussion. I use Visual Studio because it is the best IDE out there.

The source code editor for C and C++ is great with a good editor and navigation. But, I could write source code in Notepad or Vi (actually have done) if it came to that – I can adapt to any editor.

The one thing that may me stick to Visual Studio is that “things work” – no fuzz or jumping around. Their debugger have always been the best talking as a Windows developer, but I have missed Visual Studio on Linux (Raspberry PI) and STM32.

These days this is not an issue – Linux support you get for free and STM32 is supported through the VisualGDB extension. For me this means I can develop Windows, Android, Linux and STM32 from within the same IDE.

The debugger in Visual Studio is important. You press F5 and your app start and you can single step, look at variables and do all the things you expect from a debugger – no fuzz because it works.

  1. Eclipse.

Eclipse have support for more or less every platform out there and is a good choice. I have recently started using Eclipse with “System Workbench for STM32”. This integrate with STM32CubeMX which makes it a good combination. CubeMX allows you to “wire” your chip and have driver code and setup generated. It is a bit fiddly to get started, but once you get it to work it really makes a difference.

As mentioned an Editor is an Editor. Eclipse is great for Java developers, but I write C/C++. So that is what you get – I have used Eclipse in many variations over the years and it’s great for what it is. I started to test this because friends who do not use Visual Studio talked about this for STM32 and it is decently good.

It can be a bit fiddly to get the ST-Link working at times + the debugger support seems to have room for improvement. I have not tested C++ on this yet, but so far I admit that this would be worth a try.

  1. CooCox IDE

This is also based on Eclipse and have for some time been my choice for STM32 development. They have a better grasp of embedded development with a good repository where you can pick up modules and a working help system. What I liked with CoIDE was that it was easy to get started and that St-Link always worked.

The reason I move away from this is because development seems to have stalled after version 1.7.8 which don’t support the new drivers from ST. I have tested their new Beta, but can’t get it to work properly.

Others…

Other options do exist. The commercial options have never really been an option + they tend to focus more on enabling bare minimum than being great.

Conclusion

For me it’s not really a choise. I have used Visual Studio for so many years and with Windows, Raspberry PI and STM32 so tightly integrated into the same environment it becomes to attractive. VisualGDB cost ca 80.- USD so this is not completely free, but it is worth it IMO.

I have not tried STM32CubeMX together with Visual Studio, but it should be straight forward – that said I only use CubeMX for testing. In real projects I set up my own HAL and organize code properly not outside the controll of any IDE – in fact I often maintain several IDE’s because different developers have different preferences.

16 x Servo Module – 1st draft

Just the first 3D draft of my Servo Module. I still have the Raspberry PI Zero W hanging on the back of this – we don’t need to populate that header, but had plenty of room for it so just left it there. on top left you see jumpers to select Servo and Servo Signal voltage. On right you see a classic 3 x 16 header for servo connectors with the photo coupler providing a complete isolated Servo module.

I have a few changes I need to do – firstly I want to investigate how to add a current sensor with full isolation – possible using a photo coupler.

Pocket PC Keyboard

Not the most interesting topi, but this keyboard fit into my hand and accidentally have a layout that seems to be good for a developer. I ordered one to try out – actually could be an idea to make plug the keyboard into Raspberry PI and make a Pocket PC – it just need a 7″ display on top and a RPI Zero W + a battery.