Society of Robots - Robot Forum
Software => Software => Topic started by: marccc on January 28, 2011, 05:33:05 AM
-
Hi, I have one problem with leds in one Atmel 90PWM3B (32 pins).
I have done one board with 22 leds in the above microcontroller. There are two tipes of leds.
1 I 20mA
VF 3.2
2 I 20mA
VF 2.2
This leds are connected from the pin to the ground (pin, 100ohms resistance, led, ground).
The problem is one led not shine enough, the other almost nothing.
I have done any test and I think the pull up resistor inside the micro is 50k,
I think it is too much higher.
If I plus 50K inside the micro and 100ohms outside the total resistance is too higher,
it should be 100ohms.
If I put the led directly without the 100homs resistance I haven't enough light.
The question is:
I can change the resistance the pull up for other more low or take out it?
I work with AVRISP mkII, Atmel 90PWM3B (32 pins), makefile ATmega8 modified.
What I have done:
- The leds work ok outside the circuit.
- If I connect the VREF to one pin the led shine correctly.
-I have read the Datasheet and I have tried to disconnect the pull ups with this sentence
MCUCR |= (1<<PUD); but it doesn’t work.
-I am working with a makefile modified and until today I have been able to program this without problems.
-
The pull up resistors are available for pins configured as inputs only they do not apply when you set the pins to output for driving LEDs etc.
Some more points to consider:
You are using 2 types of LED with different characteristics. If 20mA is Ifmax you are overdriving the second type with a 100R limit resistor, assuming a 5V supply.
The micro has an absolute maximum rating of 200mA on the supply pins. To stay comfortably below this you need to limit your 22 LEDs to 5-6mA each if they will all be driven on simultaneously. If this does not provide enough brightness then you should look at using an external driver not driving from the micro pins directly.
-
I have connect only two different leds with the exact resistance
1 led- 100ohms
2 led- 150ohms
The light is the same.
What I have done:
I have changed the microcontroller.
I have short circuit the protection circuit (Diode, LDO)
May be is a wrong programming. I ability and disability the outputs with the next sentences:
DDRB = 0b11111111; //configure ports for output
int funcion0(void)
{
PORT_ON(PORTB,0);
PORT_ON(PORTB,1);
delay_cycles(500);
PORT_OFF(PORTB,0);
PORT_OFF(PORTB,1);
delay_cycles(500);
return 0;
}
-
Why would you short any circuit protection? That sounds like a good way to break something.
Stick to one or two LEDs with series current limiting resistors. Those are there for a reason.
Your code looks ok, but it is impossible to really comment without seeing the complete project. I am wondering if you are using a much higher frequency crystal then that code was designed for... You say the LEDs come on but are dim when you upload your code to the micro?
Try something simpler like:
DDRB = 0b11111111; //configure ports for output
int funcion0(void)
{
PORT_ON(PORTB,0);
PORT_ON(PORTB,1);
delay_cycles(500);
//PORT_OFF(PORTB,0);
//PORT_OFF(PORTB,1);
//delay_cycles(500);
return 0;
}
If the LED's come on at correct brightness then your values for delay_cycles are too low and the LEDs are dim due to a 50% duty cycle. If they are still not coming on then you can check logic levels on the pins to test they are being set correctly.
Work through things carefully and methodically and you will soon have something working. :)
-
The led light doesn’t change. I have taken out all the delays from my program. It has been reducing until the next:
#include <avr/io.h> // include I/O definitions (port names, pin names, etc)
#include <avr/interrupt.h> // include interrupt support
#include "global.h" // include global settings
//define port functions; example: PORT_ON( PORTD, 6);
#define PORT_ON( port_letter, number ) port_letter |= (1<<number)
#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)
#define PORT_ALL_ON( port_letter, number ) port_letter |= (number)
#define PORT_ALL_OFF( port_letter, number ) port_letter &= ~(number)
#define FLIP_PORT( port_letter, number ) port_letter ^= (1<<number)
#define PORT_IS_ON( port_letter, number ) ( port_letter & (1<<number) )
#define PORT_IS_OFF( port_letter, number ) !( port_letter & (1<<number) )
void configure_ports(void)
{
// DDRC = 0xFF; //configure all C ports for input
DDRC = 0b11111111; //configure ports for output
DDRD = 0xE1; //configure all D ports for output
DDRB = 0b11111111; //configure ports for output
DDRE = 0b11111111; //configure ports for output
void delay_cycles(unsigned long int cycles)
{
while(cycles > 0)
cycles--;
}
int button_pressed(void)
{
return (bit_is_clear(PINE, 2));
//return ((PING) & (1<<PG5));//old version, went high when button pushed
}
int funcion0(void)
{
PORT_ON(PORTB,0);
PORT_ON(PORTB,1);
PORT_ON(PORTB,2);
PORT_ON(PORTB,3);
PORT_ON(PORTB,4);
PORT_ON(PORTB,5);
PORT_ON(PORTB,6);
PORT_ON(PORTB,7);
PORT_ON(PORTC,0);
PORT_ON(PORTC,1);
PORT_ON(PORTC,2);
PORT_ON(PORTC,3);
PORT_ON(PORTC,4);
PORT_ON(PORTC,5);
PORT_ON(PORTC,6);
PORT_ON(PORTC,7);
PORT_ON(PORTD,0);
PORT_ON(PORTD,1);
PORT_ON(PORTD,2);
PORT_ON(PORTD,3);
PORT_ON(PORTD,4);
PORT_ON(PORTD,5);
PORT_ON(PORTD,6);
PORT_ON(PORTD,7);
PORT_ON(PORTE,1);
return 0;
}
OTHER PAG
#include "SoR_Utils.h" //includes all the technical stuff
int main(void)
{
int counter=0;
//int reset=0;
//short int flag=0;
while(1)
{
switch (counter){
case 0:
funcion0();
break;
}
return 0;
}
Using this program with all the leds start, the total intensity in board is 8.31mA. the leds shine very low. If the total consumption possible for the AT90PWM3B is 200mA and for pin 40mA How is possible that the consumption for each led is 73uA?
The tension in pin is 5V in open circuit and 2.6V connected in the resistor and led
This project doesn’t have external clock. I am using the internal clock and I haven’t programmed nothing about it.
I have connected the pin to the oscilloscope and the signal is completely continuous in all the frequencies.
The connection the led is from pin to ground not from Vin to the pin. May be this is the problem.
-
When I upload the program the leds connected to the pins MISO, MOSI and SCK shine correctly
-
To repeat... if you try to hook up 22 LEDs without suitably limiting the current you are likely to exceed the absolute maximum current for the power pins by some margin! Suggest you switch to limit resistor values of 330R and 470R for the different LED types.
...How is possible that the consumption for each led is 73uA?
The tension in pin is 5V in open circuit and 2.6V connected in the resistor and led
If the pin is dropping to 2.6V when the LED is attached then it is not correctly configured as an output. In your code listing you don't seem to call configure_ports() anywhere, which may explain that.
The connection the led is from pin to ground not from Vin to the pin. May be this is the problem.
Unlikely, the AVRs seem to have a fairly even capabilities for current sink and source, unlike PICs where you would be better sinking the current. If you limit the LED current to 5-6mA you should get reasonable brightness and the pins should drive all your LEDs ok.
-
:D was configure_ports();!! Thanks and now look for limit resistors.