STM8 Microcontrollers – the Final Chapters

Hardware

Capacitive Touch Overview

Electronics and embedded-systems advancing fast. Designers and users are moving toward electronic solutions over mechanical ones. Touch screens, touchpads and touch switches are getting popular like never before and are replacing traditional mechanical switches, knobs, etc. ST like many other microcontroller manufacturers have provided resources for implementing capacitive touch buttons. However, the algorithm for implementing reliable capacitive touch sensors is a bit complicated especially when it comes to an 8-bit microcontroller. For this reason, ST has provided capacitive touch libraries for its STM8 and STM32 product line. These libraries along with SPL enable us to quickly and effectively add capacitive touch functionality in our designs.

Capacitive Touch

In STM8s, RC acquisition principle is used to implement capacitive touch sensors. No special hardware is required for implementing RC-based capacitive touch buttons/sliders/wheels. Just timers and GPIOs are all that are needed to get the job done. RC acquisition method detects a human touch on a capacitive touch sensor (acquisition pin/pins) by measuring small variations of the touch electrode’s capacitance. Capacitance exists between acquisition electrodes and ground. The touch electrode capacitance is periodically charged and discharged through a fixed resistor called load resistor by altering the logic state of the load I/O. A touch electrode’s capacitance depends on its area, relative dielectric constant of the insulator in-between, the relative permittivity of air and the distance between the two electrodes. Additionally, an active shield is used to get rid of parasitic capacitance between touch electrode(s) and ground. Parasitic capacitances originate due to environmental effects and other foreign objects. An active shield surrounds touch electrode(s) and maintain same in-phase potential. This leads to zero potential difference between the electrode(s) and shield, and thereby no parasitic capacitance builds up.

ST’s application note AN2927 details capacitive touch sensing.

Continue Reading ...

Related Posts

7 comments

  • Hello,
    How can i change the font size so i can support for example [92][12] ? Saw some libraries on the net but i am not sure if they are compatible with this code… or am i doing something wrong ? I tried manipulating the current one with some cycles within ” OLED_print_char ” also chaning 0x06 to 0x0C with a font library also tried creating fonts but i did not get the expected result. Can you give me some advice please ?
    Thank you for your time!

    • The coordinates of the OLED displays are mapped as multiples of 8-bits or 8 dots in both x and y directions. So just by changing x-coordinate values won’t result in larger fonts…. You must also take care of the y-coordinate too…. Take the example of the bitmap function:

      void OLED_draw_bitmap(unsigned char xb, unsigned char yb, unsigned char xe, unsigned char ye, unsigned char *bmp_img)
      {
      unsigned int s = 0x0000;
      unsigned char x_pos = 0x00;
      unsigned char y_pos = 0x00;

      for(y_pos = yb; y_pos <= ye; y_pos++)
      {
      OLED_gotoxy(xb, y_pos);
      for(x_pos = xb; x_pos < xe; x_pos++)
      {
      OLED_write(bmp_img[s], DAT);
      s++;
      }
      }
      }

      It takes care of the y-coordinate part once the x-coordinate points are filled up….

  • Hi great tutorial!
    Can you post code for interfacing external eeprom using i2c for stm8s003f3??

  • Pingback: .NET i jiné ...

  • Pingback: STM8 Microcontrollers – gStore

  • Outstanding bro. Carry on. Wish your good luck.

Leave a Reply

Your email address will not be published. Required fields are marked *