Page 1 of 1

Flowcode v4: Software PWM. Atmega8 8 LEDs Problem

Posted: Fri Jun 20, 2014 6:43 pm
by theoneandonly2002
Hi,

I need to controll the brightness of 8 LEDs individual using my atmega8.
I tried to build something, but it only works for 4 Leds.
If I use more, then the LEDs are just flickering.

Is there any other solution in flowcode to solve this Problem?

Thanks very much

Re: Flowcode v4: Software PWM. Atmega8 8 LEDs Problem

Posted: Fri Jun 20, 2014 7:22 pm
by kersing
Please do not post questions in the Tips and Tricks forum. That is reserved for posting (clever) solutions that may benefit other users.

Re: Flowcode v4: Software PWM. Atmega8 8 LEDs Problem

Posted: Sat Jun 21, 2014 2:33 am
by medelec35
The only small issue I can spot with your flowchart is the LED's will never be off with duty of 0.
To correct that, instead of Timer_Count = PWMx
You should have Timer_Count >= PWMx
I don't believe adding the greater than sign will cure the flickering.

If you can see flickering then hardware speed is running to low for the application.
I would suggest you do the 1Hz test to make sure hardware is running at the correct speed.
If it is there either hardware has to run at a higher speed.
Or
Preload timer with a value that stops flickering but still allows main code to run with no issues.
If you preload with too high value, program will fail to run correctly

Can you try the attached flwochart.
I have preloaded timer0, but I'm not sure what is the best value to preload timer with?
It may need to be a bit of trial and error.

Martin

Re: Flowcode v4: Software PWM. Atmega8 8 LEDs Problem

Posted: Sat Jun 21, 2014 7:07 am
by theoneandonly2002
Hi,

thanks for this.
It still shows the same problem. 4 Leds work. 5 or more no chance. Only flickering
But I checked the timing and it seems that my microcontroller is a little bit to slow.
When I do a delay of 200ms between the LEDs to get from dark to bright it takes around 1 second.

I set the fuses of the Atmega to 8Mhz and in Flowcode I did the same. I used AVR Studio 5.0 to set the fuses.
Is there anything else I can do?

Re: Flowcode v4: Software PWM. Atmega8 8 LEDs Problem

Posted: Sat Jun 21, 2014 12:02 pm
by medelec35
I
theoneandonly2002 wrote:When I do a delay of 200ms between the LEDs to get from dark to bright it takes around 1 second.
It looks like your internal osc is running at the default 1MHz
That's why it's always a good idea when staring a new project to do a 1HZ test and make sure that on/off timings are correct.
Loading compiling your flowchart then loading hex file into my AXIS presto programming software shows:
AVR hex file.png
(90.76 KiB) Downloaded 2765 times
For some reason it's still showing 1MHz after you have selected 8MHz.
So if my programming software is showing correct information, it looks like your hardware is running 8 times slower than expected hence flickering.

How you got means of loading hex code directly and check the fuse settings?

Also after setting up fuses can you post the generated hex file so I can check it's fuse settings.