Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Lighting a LED Matrix on a keyboard with FreeRTOS Task/Timer

Posted by groger57 on June 14, 2017

Hello: I have a keyboard that has both buttons to scan, and LED's to light. No issues with the keyboard scan, that is working OK, There are 20 LED's, but at most only 6 would be ON at any time. I'm presently using a timer at a rate of 15ms to avoid flicker, but as the number of LED's ON approaches 6, the flicker is more apparent.

Hoping to get some advice on what the best way to do this. My control loop is set to "PWM" the on time such that it doesn't exceed the maximum power for the LED. In that loop, which is within the call of the timer task, I am using vTaskDelay(x) where x is the time it's on before I switch of that LED in the double indexed for loop. Presently, that's set to 5ms

It seems that if I had 6 LED's set to be ON, and the delay time ON of each is 5ms, and that total delay is 30ms, which is longer than the timer task rate of 15ms. Is this correct, and if so, how can that be? If this sin't the best way to do it, can someone please provide an outline of a better method that would provide better light uniformity (ideally, less flicker)

Thanks for your help !


Lighting a LED Matrix on a keyboard with FreeRTOS Task/Timer

Posted by richard_damon on June 14, 2017

If you cycle 6 LEDs on for 5ms each, that will take 30ms for the full cycle, which since LEDs don't have persistance, may well show a flickering. You really need to be switching the LEDs on and off much faster. If I were to do something like this, (needing the control to be in software), I would find an auxilary hardware timer and configure it faster, like maybe a 1 ms period. I would then inside the ISR for that timer turn off the current LED, and select the next one in a 6 element array (And there should be a value you can put in that array to mean 'NO LED'). This operation should be quick so appropriate for an ISR, and doing the work in the ISR saves a lot of time since you don't need the scheduler to switch the task in and out. By always cycling through the six slots, the brightness won't change based on the number of LEDs being lit. With a 6ms cycle period, you should not be able to see the flicker.


Lighting a LED Matrix on a keyboard with FreeRTOS Task/Timer

Posted by groger57 on June 14, 2017

That's a great suggestion, and makes perfect sense. I have a few timers on the STM32F4, so it won't be trouble to find an unused one.

Thanks!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists