Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] light 7 LED by timer of an AVR microcontroller

Status
Not open for further replies.

matin-kh

Member level 3
Joined
Nov 9, 2013
Messages
67
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
iran
Activity points
1,955
Hi everyone,
I have 7 LEDs in my board which I used them instead of 7segmnet. each of them are connected to an I/O port of AVR microcontroller. because of supply limitataion forexample for showing '8' all the LEDs could not be on all together and because of me supply source just one LED can be on at a moment. so I have to solve this problem by software. I have to use a timer which light just one LED at a moment.sth like below. my problem is the value of x, what can be the value of x which human eyes don't recognize that LEDs are blinking?
Best Regards
Matin

Untitled2.png
 

Attachments

  • Untitled2.png
    Untitled2.png
    6 KB · Views: 130

The code is like

Code:
PORTB = 0x01;
PORTB = 0x02;
PORTB = 0x04;
PORTB = 0x08;
PORTB = 0x10;
PORTB = 0x20;
PORTB = 0x40;
PORTB = 0x80;

Don't use any delays.
 
The code is like

Code:
PORTB = 0x01;
PORTB = 0x02;
PORTB = 0x04;
PORTB = 0x08;
PORTB = 0x10;
PORTB = 0x20;
PORTB = 0x40;
PORTB = 0x80;

Don't use any delays.

with this method, LEDS can being on? because LEDs need a time to start lighting but forexample with 8MHz frequency, the time for executing each line of code is too short and with this code LEDS have enough time to being on?
 

Hi,

LEDs are very fast in switching ON.
If muxing, then I'd use a interrupt controlled muxing. Interrupt at least 1kHz. Delay beween LEDs.

But really...I'd just lower the LED current by changing the current limiting resistor to safe from muxing.

Klaus
 
If needed add 2 ms delay between each instruction.
 
This is called dinamic segment-by-segment indication. You should switch between segments by using timer interrupt. That's simple. I can't undrestand what throubles do you have.
 

This is called dinamic segment-by-segment indication. You should switch between segments by using timer interrupt. That's simple. I can't undrestand what throubles do you have.

I know, If you see the picture which I attached in the first post, I want to khnow a reasonable value for 'x'.
Thanks
Matin
 

Since 50Hz we can't see any switching. So, basicaly, you have to device 20ms to 7 (segments amount). So, 3ms is enought.
 
Which AVR Microcontroller are you using and what is the Crystal frequency ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top