STM32 and Arduino

STM32 is a family of 32bit microcontrollers manufactured by STMicroelectronics and based on the ARM Cortex M core.

The STM32 family is divided into different lines of microcontrollers (L0-1-4, F0-1-2…) depending on their features and the use they are designed for:

stm32-16

These microcontroller are widely used in the industrial world… for example both Pebble watches and Fitbit bracelets are based on STM32 MCUs.

If you’re interested in quadricopters or drones, you probably have heard or used F1, F3, F4 flight control boards. The board name (“F…”) indicated indeed the STM32 microcontroller they are based on.

Thanks to the work made by the stm32duino community and to the support of ST itself, starting from the past June STM32 microcontrollers can be easily used with the Arduino IDE and it’s also possible to take advantage of most of the libraries available for Arduino.

I decided to buy a minimal development board based on the STM32F103C8T6 microcontroller (these boards are sometimes known as blue pills); let’s see how to use it with Arduino.

Bootloader

Many boards are sold unprogrammed: the first thing to do is therefore to program a bootloader, that is a small program which will allow to upload the “real” program via USB port.

To flash the bootloader, you need an USB -> serial adapter, connected to your dev board as it follows:

  • RX -> A9
  • TX -> A10
  • VCC -> 5V
  • GND -> GND

stm32-18 stm32-19

You have also to enable the programming mode, moving the first jumper (labeled BOOT0) to position 1:

stm32-17

Now you need a software to flash the file with the bootloader into the chip. If you’re under Windows, you can download the Flash Loader from ST’s official website: after having registered (for free) you’ll receive the download link via email.

The bootloader is developed and maintained by Roger Clark and it’s available in his Github repository. For STMF1 boards there are several binary files, depending on the PIN the onboard led is connected to. My board uses P13, so I downloaded the file generic_boot20_pb13.bin.

Run the Demonstrator GUI program and select the serial port your adapter is connected to:

stm32-03

If all the connections are ok, the software should be able to detect the microcontroller:

stm32-04

Now you can select the specific MCU your board uses:

stm32-05

then select the file with the bootloader and program it. To be sure, you can ask the software to perform also a global erase of the memory:

stm32-06

The program will flash the chip and, when complete, will confirm the operation with a message:

stm32-08

If you now move back the BOOT0 jumper to the original position, you should see the led blink: this means that the bootloader is running and can’t find a program to execute… now it’s time to configure the IDE.

Arduino IDE

Open your IDE and select File – Preferences. Type the following address in the Additional Boards Manager URLs field:

https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json

stm32-00

Now open the Boards Manager:

stm32-01

Search STM32F1 and install the corresponding Cores package:

stm32-02

You’re almost ready to compile and run your first program…

Drivers

Connect the dev board to your PC using an USB cable and verify how it is identified.

It may happen that Windows cannot correctly identify the board and displays it as Maple 003, is this case you have to install the correct drivers:

stm32-09

Download the following files from Clark’s repository:

  • install_STM_COM_drivers.bat
  • install_drivers.bat
  • wdi-simple.exe

Run the two .bat:

stm32-10

now Windows should identify the board correctly:

stm32-11

Sometimes Windows cannot see the additional serial port of the board. To solve the problem, you can try to program on the board a simple sketch that uses the Serial object. Open for example the blink sketch and change it as it follows:

stm32-12

Program the sketch choosing BluePill F103C8 as board and STM32duino bootloader as upload method.

Once the sketch is programmed and executed, Windows should detect and install the new COM port:

stm32-14

You’re done, now the board is fully integrated with the Arduino IDE:

stm32-15

Building a single pixel scanner

scanner1-600

Kerry Wong published a new build:

A flat bed scanner typically uses three rows of CCD sensors (RGB) to capture images placed directly on top of the glass bed. When the CCD array scans from one end of the image to the other, the digitized color image is formed. So with a similar approach, we could use just one photosensitive device to capture the entire image one pixel at a time via raster scanning. Now that I have an HP 7044A X-Y recorder I could use it’s X/Y servo mechanism with a suitable sensor to build a single pixel scanner.
The simplest sensor would be just a photodiode or a CdS photocell. For capturing grayscale images, either of these sensors could be used. To capture color images though, we would need a sensor that is capable of discerning the RGB components of each pixel. For that I used an inexpensive TCS34725 based color sensor module.

More details at Kerry D. Wong blog.

Check out the video after the break.

UDOO-X86 Part 2: Roaring performance // Review

In Part 1 of this video I looked at the UDOO-X86 from the electronics Maker perspective. In Part 2 I’ll be looking at the CPU and graphics performance of the board on Linux as well as RemixOS. UDOO-X86 Phoronix Tests Continue reading UDOO-X86 Part 2: Roaring performance // Review

The post UDOO-X86 Part 2: Roaring performance // Review appeared first on MickMake.

Arduino data logger update

s-teriminalminiloggerthecavepearlproject-600

An update on Edward Mallon’s Arduino data logger project we covered previously:

If you need a logger with a cheap durable housing, it’s still hard to beat the Dupont-jumper build released in 2016. But sometimes I need more of a bare-bones unit for bookshelf test runs while I shake down a new sensor. I can whip up a breadboard combo in about twenty minutes, but they can stop working if I bump one of the wires by accident. I’ve lost SD cards from this half way through a long term test, and I’ve also run into issues with noise & resistance from those tiny breadboard contact points.
To address this problem I’ve come up with a new configuration that uses a screw-terminal expansion shield originally intended for the Arduino Nano. This requires a modest bit of soldering, and after some practice, between 1-1.5 hours to finish depending on how many “extras” you embed.

Read more details at his blog here.

TB timer – Timed camera cable release

pics-TB-Timer-v1.00-Prototype-Labeled-600

Steve Smith has published a new build:

It’s taken some research but I have built a prototype with my trusty ARDX Arduino Uno kit
Currently, the device changes mode with a press of the mode button which will later be incorporated in a suitable rotary encoder. I modified the prototype’s rotary encoder to remove the detents and therefore, have continuous motion rather than be stepped. When stepped, the value hops by two at a time. The ‘B’ and ‘T’ modes both operate as expected and at the moment, the rotary encoder changes a value in ‘TB’ mode and is displayed on the OLED display. the outputs are opto-isolated so will appear as switches to the camera. Although I’ll be using the cable release with a Canon DSLR, it should be very easy to make it work with other DSLR makes.

Project info at projectavr.com.

Build your very own drink mixing robot

Yu Jiang Tham designed and built his own bartender robot named Bar Mixvah, that is available on Github:

I built a robot that mixes drinks named Bar Mixvah.  It utilizes an Arduino microcontroller switching a series of pumps via transistors on the physical layer, and the MEAN stack (MongoDB, Express.js, Angular.js, Node.js) and jQuery for the frontend and backend.  In this post, I’ll teach you how I made it.  You can follow along and build one just like it!

Check out Yu Jiang’s 3-part blog post here: Part 1, Part 2, Part 3.

Pool playing robot

pics-FIHN8TZJ282UHWM-600

BVarv  wrote an instructable detailing the build of his pool playing robot project with Arduino:

I redesign the prototype with servos, belts and gears at the points of rotation to add programmable motion.
While doing so, I stumble across an easy win. It turns out that the “parked under the table” orientations, and the “perpendicular to the table” orientations are regular stops for pool playing robots. Adding two tabs to a layer of the table pedestal and placing two switches on the motion platform is a simple way to reliably detect those positions.

Project instructables here.

Check out the video after the break.

HP 7044A X-Y recorder teardown, Lorenz Attractor

pics-7704A-600

Kerry Wong did a teardown of a vintage HP 7044A x-y recorder and programmed an Arduino Due to draw the Lorenz Atrractor using this recorder:

To test the recorder, I wrote a simple program using Arduino Due that generates a Lorenz attractor. The min/max boundaries for each axis were obtained prior and they are used to map the curve to the first quadrant since 7044A can only plot signals within a single quadrant at a time. Arduino Due is convenient because it has two 12bit DAC outputs which can be used to drive the X and Y channel.
Unlike using an oscilloscope, the recorder cannot record data that changes faster than a few Hertz. To slow down the output, you can either decrease the time interval (I chose 0.001) or add in additional delays. I used serial output to slow things down a bit, this is convenient as I could use the data when debugging the program as well.

More details at Kerry Wong’s blog.

Check out the video after the break.

 

 

Calibrating Thermistors on a 3.3v Arduino

si7051_5sensortest-600

Edward Mallon writes, “I’ve managed to get cheap thermistors calibrated to about to +/- 0.2C with 3.3v Arduinos. Instead of playing whack-a-mole with the various sources of error, I simply rolled them into some synthetic Steinheart-Hart constants, and I was able to get the therm’s output onto the reference line from a si7051. The cool thing about ti is that the thermistor, and the reference sensor cost less than a single high precision thermistor would have. Not sure if this approach would work beyond 40 degrees of range, but that’s good enough for my purposes.”

More details at Edward Mallon’s blog.

Via the comments.