STM32F103 SPL Tutorial 8 – Interfacing Unipolar Stepper Motor

Stepper Motor

Stepper motor is an electromechanical device that converts electrical pulses into discrete mechanical movements. In this tutorial, I will explain how to control a unipolar stepper motor using STM32F103 microcontroller. If you don’t know the basic of the stepper motor, I suggest you to read this post. To interface a stepper motor from a microcontroller, we can’t directly drive it with GPIO pins because GPIO pins have maximum current that can sink or source from it. To overcome this problem, we can use driver circuit. The driver circuit for unipolar stepper motor can be built by using 4 transistors to drive large current to the 4 wires of a stepper motor. It also can be built with ULN2003 IC. This is the circuit for driving a unipolar stepper motor from STM32F103 by using ULN2003 IC.

Stepper driver

Continue reading “STM32F103 SPL Tutorial 8 – Interfacing Unipolar Stepper Motor”

STM32F103 SPL Tutorial 7 – Interfacing LCD16x2

LCD16x2

LCD16x2 is a popular display module and commonly used in various devices. In this tutorial, I will explain about how to use LCD16x2 with STM32F103 microcontroller. If you want to know the detail how LCD16x2 works, you can follow this tutorial. To interface the LCD with STM32F103, you need the library files (lcd16x2.h and lcd16x2.c). You can get the library files and from here.

STM32F103 LCD16x2

Continue reading “STM32F103 SPL Tutorial 7 – Interfacing LCD16x2”

STM32F103 SPL Tutorial 6 – I2C Interface

STM32F103 I2C

STM32F103 I2C (Inter-Integrated Circuit) or sometimes called TWI (Two Wire Interface) is a synchronous serial protocol that only needs 2 wires for communication. The wires are SCL for clock line and SDA for data line. With I2C, you can connect devices like temperature sensor, EEPROM, RTC, and etc (up to 112 devices) just using 2 wires (plus GND wire). For accessing these devices, I2C use 7-bit address. Theoretically, 7-bit address space allows 128 addresses, however some addresses are reserved for special purpose. Thus, only 112 addresses can be used.

I2C bus

Continue reading “STM32F103 SPL Tutorial 6 – I2C Interface”

STM32F103 SPL Tutorial 5 – SPI Interface

STM32F103 SPI

STM32F103 SPI (Serial Peripheral Interface) is a synchronous serial communication protocol. In this interface, in addition to transmit and receive lines, there is a third line that is used for clock line. Each slave device also has a chip select (enable) pin, that is used for activating the device. So to use SPI, we need 2 wires for data lines (MOSI, MISO), 1 wire for clock line, and 1 wire per device for chip select line. MOSI (Master Out Slave In) is used for data transfer from master device to slave device. MISO (Master In Slave Out) is used for data transfer from slave device to master device.

SPI bus

Continue reading “STM32F103 SPL Tutorial 5 – SPI Interface”

STM32F103 SPL Tutorial 4 – Create a Delay Function with System Timer

STM32F103 System Timer

STM32F103 System Timer or SysTick is a timer inside the CPU. SysTick is a basic countdown timer. SysTick can be polled by software or can be configured to generate an interrupt. To use SysTick, we must load a value to the reload value register. The width of reload value register is 24-bit, so it can counts from 0x00FFFFFF to 0. In this tutorial, I will explain how to use SysTick for creating a delay function. SysTick can be configured through the registers below.

SysTick register

Continue reading “STM32F103 SPL Tutorial 4 – Create a Delay Function with System Timer”