PeerReview of non-working code - ledheart.c

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm attempting to port the ledheart.c code from
http://www.nerdkits.com/videos/l...
(a ATmega168) to a Tiny13 8pin uC so that I can implement a better flashing effect for my fiberoptic modification of my Star Trek Pinball:
http://www.austinmodders.com/mod...

I like the way his leds randomly enter into a brightness phase then dim back down... and move on the the next led in random order.

I only need to flash 4 LEDs so his code is proably overkill for such a small number of LEDs.

I've had to minimize the code by hand to just get the program to fit within the 1K flash available on the Tiny13.
I've been debugging the code all day long and can't seem to get it to flash right.

Basically; in it's current setup - I've set PB4 to be the ROW driver. PB1-3
are the COL drivers.

I've basically wired all the LEDs the same direction. Kathode to pin. Anode to 100ohm resistor. Resistor to Row driver (PB4).
None of the LEDs are lighting.

I've checked the pins with a logic probe. I only seem to be getting transitions on PB1 and PB4. PB2 and PB3 are low.
This leads me to beleive the code either doesn't work with a small number of COLs or I've introduced a bug with the minimization.

For debug purposes; I've #defined in the blink_all function... and taken out the twinkle() function.
Leading me to beleive there is something wrong with the ISR function. I'm thinking it's related to the way he's calculating the indexes of the columns.

His original code is here:
http://www.nerdkits.com/videos/l...

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not try to get a single led to burn first?

from your description the row driver (PB4) has to be always high to get the LED on. Then you need to drive the colom low. You need all 4 lines to be output for this to work.

I do not now the supply voltage of the system, but 100Ohm at 3V gives about 13mA ((3-1,7)/100) for 5V you have ((5-1,7)/100)=33mA. personally I think that is quite high for a LED, but there are LEDs that need this current....

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it's a 3.3V system right now.
Mostly blue/white leds.
I redid the code now, simplifying it to 4 LEDs just driving them from the pins without fancy row/col setups.
Now I can't seem to get the flickering to go away. Setting the Tiny13's CS2:0 bits to 001 (no prescaling) seems to make the code stop working.

Wired each LED with Anode to a single
pin and a 100ohm resistor to ground. PB1 - PB4 are tied to LEDs.
I then modifed the source; simplfying it.
I've gotten it to mostly work; the LEDs light and randomly get brighter like the heart.

However, I am seeing excessive flickering which I can't seem to track down.

I thought it might be because the Tiny13's CPU is defaulted to 9.6MHz vs the 68's 14.7MHz.
I tried dropping TCCR0B's CS bits to 001 to run clkIO w/ no prescaling... but when I did that - the code no longer seemed to function.
I tried increasing the internal clock by a factor of two using CLKPR; but didn't seem to help.

Scratching my head here.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

flickering can be the timer when you kept that running.

It might also be a processor that is resetting.

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp wrote:
flickering can be the timer when you kept that running.

It might also be a processor that is resetting.

Did some test code and verified it wasn't MCU reset.

I did some more troubleshooting and figured out that the LEDdisplay ISR was not firing fast enough to display them properly. Tied the OCRA compare timer to an ISR and called the ISR more often based upon updating the timer.

Fickering has been greatly reduced. Tomorrow I iterrate some more on the Compare ISR in an attempt to minimize the flicker.

Attachment(s):