Multivibrator – back to basics

Multivibrator circuit is one of the first projects you start learning electronics. It is a beautiful circuit widely used for educational purposes and even in end projects as waveform generators. Lots of hobbyists grab a microcontroller/Arduino to blink LEDs. But using basic circuits like multivibrator may be cheaper, faster, and even fun. [Ray] decided to go through multivibrator theory and explain its working in detail step by step. The circuit itself consists of two transistors, two capacitors, and four resistors. When powered, the circuit generates a square wave signal that can be used to flash LEDs or clock other circuits. You will get an intuition on what causes multivibrator to develop generate. Formulas allow calculating resistor and capacitor values for a particular frequency. If you are a starter in electronics, build one on a breadboard and do some experiments, why not start with Christmas lights.

Continue reading

Driving Graphical LCD with STM32F103ZET6

STM32F103ZET6 board comes with 3.2 inches graphical LCD which features an ILI9320 controller. Equipped LCD is capable of displaying 252144 colors when driven in 18-bit mode. We are going to run it in 16-bit mode, so we are limiting it to 65K colors. LCD driver is based on the existing code found on the internet, originally developed for the STM3210E board. Only minor modifications were needed, like assigning the proper control pins.

Continue reading

Connecting STM32 USART to standard I/O streams in GCC

In many situations, when working with STM32 microcontrollers, you will want to output text strings. There is no need to write specialized functions that output specially formatted strings as it is hard to keep up with various cases. It is convenient to use standard I/O streams and their library functions that allow sending formatted data streams. Arm GCC toolchain comes with the newlib C library from Redhat, so it isn’t specially designed for the embedded toolchain. To use stdio functions, we have to take care of several syscals so-called “stub functions.” These functions usually are provided by operating systems like you would write C programs in Windows or Linux. In our case, we aren’t using any OS, so to avoid error messages while compiling, we have to provide these function declarations where most of them are dummy implementations. It’s not something new pick one that you find on the internet. I noticed that it was written for STM32 Discovery. I named it newlib_stubs.c and placed it in the startup directory. Among system functions implementations like _write(), _fstat(), etc., there are also USARTs assigned to standard streams:

Continue reading

Interrupt based button read on STM32F103ZET6 board

In the previous example, we implemented a simple demo program that reads buttons by continually checking their status in the main program loop. This isn’t an efficient and convenient way to do that. Imagine your application has to do lots of tasks, and in between, you also need to check button status – mission becomes impossible unless you use interrupts. In this part, we briefly introduce to STM32F10x interrupt system and write example code where LEDs and buttons are serviced within interrupts. ARM Cortex-M3 microcontrollers have an advanced interrupt system that is pretty easily manageable. All interrupts are controlled inside Nested Vectored Interrupt Controller (NVIC), close to the Cortex core, to ensure low latency and robust performance. Main features of NVIC include:

Continue reading

Implementing buttons on STM32F103ZET6

Last time we have made a good starting point with setting up a project template for the STM32F103ZET6 development board using GNU tools. Using the same project template, we can move forward and start programming other elements. This time a quick note about adding a button library. This is a modest implementation that initializes port pins and then reads their status. The Development board is equipped with four user-programmable buttons named WAKEUP, TAMPER, USER1, and USER2. We will not care about the meaning of names; use them as general-purpose buttons for now.

Continue reading

Driving LEDs with LPC2148 microcontroller

The LPC2148 development board is a mighty board with an ATM7TDMI series microcontroller considered an old guy compared to Cortex ones. But still, these are widely used and are powerful. The Development board has some handy features installed. 12MHz crustal allowing to run the processor at full 60Mhz speed. Couple RS232 ports, VGA connector, PS/2 connector for keyboard or mouse, 20-pin JTAG, SD/MMC slot, USB B-type, 8 LEDs driven with a serial-in parallel-out shift register, 2×16 LCD, buzzer, audio jack with an amplifier, two programmable buttons, and 256Kb of I2C interfaced EEPROM. The microcontroller itself has 512KB of internal flash and 32+8KB of RAM. All ports are accessible, and any external hardware can be disconnected with jumpers. This is a great board for prototyping and end application.

Continue reading

LED blinky demo on STM32F103ZET6 development board

I found some time to play with the STM32F103ZET6 development board and decided to set up a simple project for it. The trickiest part of this is to set up a project environment that would serve as a template for the following developments. Many ARM developers chose the CodeSourcery Lite edition toolchain. It has full command line functionality – this is what we usually need. If you want some alternative – you can select gnu yagarto ARM toolchain, which is also great and free. No matter which tool you select, the code will work on both. Let’s stick to CodeSourcery. Just download it and install it on your PC. As we said Lite version supports only command-line tools – we need an interface for it. Eclipse IDE is one of the favorite choices, so that we will grab this one too. Yagarto website has an excellent tutorial on how to set up the Eclipse IDE in a step-by-step manner. We won’t go into details with this.

Continue reading

FreeRTOS on AVR with external RAM

AVR microcontrollers aren’t the best choice to run the FreeRTOS scheduler due to low on-chip RAM. Atmega128 has only 4K of RAM, so this limits the FreeRTOS functionality to very basic. This problem can be solved by adding extra RAM, which may be connected to an external memory interface. We have already built an external memory block of 8K previously to test it with FreeRTOS applications. Let’s continue with our previous code, which runs several simple tasks (button state reading, LCD output, and LED flash), and we can add more to it. We are going to set up an external RAM for storing heaps. This will allow the storage of large data buffers without worrying too much about heap and stack overlaps.

Continue reading

Transistor based class AB amplifier

In most small audio projects, hobbyists are using specialized audio amplifier chips. That’s really fine; you get high-quality amplification without scratching your head. Some probably don’t care how these things work. But don’t forget that amplifiers can be built out of discrete electronics components like bipolar transistors. Check out this great hack week project where Dino makes a class AB audio amplifier out of three bipolar transistors and other passive components. He slightly goes through the theory of operation and, of course, demonstrates its working in the following video.

Continue reading

Adding DAC to Arduino or any other microcontroller

Most of the 8-bit microcontrollers lack integrated DAC (Digital to Analog Converter) functionality. This is handy when you need to generate analog signals out of digital information. Adding DAC to any existing microcontroller is a piece of cake. But before you start, why not look at various options available. Embedded newbie provides a review of Arduino DAC solutions. Beginning with the R-2R ladder solution list goes through multiple ways of converting digital to analog. Depending on your needs and the speed required, a PWM DAC converter is nothing more than a digital signal passed through a low pass filter. This is how motor control works. It’s relatively slow, but serial that gives an advantage when small pin count microcontrollers are used. On the other hand, if signal speed is an issue, then parallel DAC – same R-2R ladder probably with an output buffer circuit. And lastly, there is always an option to use specialized DAC chips that can be interfaced through one of the available interfaces like SPI. These save space and MCU pins and still provide high resolution and speed.

Continue reading