PWM with STM8S

PWM is a great way to control brightness of LEDs, speed of motors, etc. Most microcontrollers including STM8S has built in ability to generate PWM signals. In this article I share simple code to generate PWM signal in STM8S microcontroller. However, I don’t write anything about PWM theory other than basic calculation to get required frequency and duty cycle. Calculation In STM8S, there are total 7 CAPCOM channels. 4 of them are associated with Timer 1 and 3 with Timer 2.

Bootloader-less Programming Arduino Pro Mini

Recently I was creating a configurable timer circuit based Arduino Pro Mini. The circuit has a momentary push button which user can press to turn ON the device. The device will turn OFF itself once the time is elapsed. On starting, Arduino has to turn on a relay to get permanent connection to power source, so it will get power when user released the push button. One issue I faced was that Arduino takes around 3 seconds to start executing the program because of the presence of the bootloader.

STM8S: Timer 2 with Overflow Interrupt

In previous post I showed how we can use Timer 2 as simple counter. In this post I am going to show how we can program to have interrupt when its value overflow. As simple experiment we will toggle an LED in each second within the interrupt handler (also called ISR, Interrupt Service Routine). Calculation As mentioned in previous post, default system clock frequency will be 2MHz and by default Timer 2 will also run with same frequency as system.

STM8S: Use Timer 2 as Simple Counter to Blink LED (without Interrupt)

Timers inside MCUs are very useful and essential peripherals for timing applications. In this article I will show Timer 2 in an STM8S (specifically STM8S103F3) can be used to blink an LED. Calculation STM8S has an internal oscillator with 16MHz frequency. By default it will be used as system clock source with prescaler 8, which means system clock frequency will be 16MHz/8 = 2MHz. By default Timer 2 will run with same frequency as system.

Program STM8S Development Board with ST-Link v2

I successfully programmed development board having STM8S103F3P6. It is quite simple to make it blink LED. To me it was second easiest after Arduino Uno to get started. I used SDCC as the C compiler, ST-Link v2 clone as programmer, and stm8flash to flash the binary file through ST-Link. STM8S103F3P6 minimal development board Required Softwares As I already mentioned, just two softwares are required to program STM8 microcontrollers in Linux machines: SDCC and stm8flash.

Program AVR Microcontroller with USBTinyISP and Eclipse IDE

In this post I will detail out how we can program an AVR microcontroller, specifically ATTiny13a, with USBTinyISP and Eclipse IDE in Linux environment. I am using Ubuntu 16.04 LTS. I hope it will work in other distributions with little or no modifications. ATTiny13a SSU mounted on adapter plate Components Required (Obviously) an AVR Microcontroller USBTinyISP 6 jumper wires to connect the programmer with microcontroller USB cable to connect the porgrammer to computer Setting Up IDE and Toolchain We need following softwares to be installed on our system.

One Channel Relay Module

Here is the schematic and details for creating one channel relay module. It would be capable of driving both DC and AC current when appropriate relay is used. We can connect output pin of most of microcontrollers including Arduino to control it. Components Required 817 Optocoupler 470Ω Resistor - 2 nos. 2N2222 Transistor 1N4148 Diode 5V Relay (SRD-05VDC-SL-C) Schematic One channel relay module schematic

Cheap Dual Voltage Regulator

Here is the schematic design to create a dual voltage regulator to power our Arduinos and other small circuits. Components Required AMS1117-5.0 or LMS1117-5.0 AMS1117-3.3 or LMS1117-3.3 Capacitor 47µF Capacitor 22µF - 2 nos. 1N5817 or any general purpose diode like 1N4001, 1N4002, 1N4003, etc would suffice Resistor 1KΩ LED The resistor and LED are optional and are just to indicate the circuit is connected to power source.

Resistor Color Codes

List of standard resistor color codes are given here. Color Value Multiplier Black 0 ×1 Brown 1 ×10 Red 2 ×100 Orange 3 ×1000 Yellow 4 ×10 000 Green 5 ×100 000 Blue 6 ×1000 000 Violet 7 ×10 000 000 Gray 8 ×100 000 000 White 9 ×1000 000 000 Gold - ×0.1 Silver - ×0.