Forum Index > Projects > LED Pegboard and Matrix Projects
 Problem with Peggy2 using the ATmega328P
 |  Printable Version
By: Anonymous: Dave () on Thursday, April 02 2009 @ 10:30 AM PDT (Read 12218 times)  
Anonymous: Dave

Greetings! I'm the proud owner of a Peggy2.1 and I'm starting to muck around with the example code and libraries. I've been able to run the various examples using the ATmega168 that came with the kit with no problems. Then I had the bright idea of trying a spare ATmega328 in the Peggy2 that I had ordered along with an arduino .... I figured I might as well have a spare for when I eventually fry the one in the arduino Smile

Anyhow, the ATmega328 works most of the time (the 16 grey scale and cube examples work fine) ...however, when I try the peggy2_MoveToLineTo example I run into an odd problem. After the 8th pass through the loop() the Peggy2 seems to reset...or at least one row goes all ON for about 1/2 a second then the generated line patterns repeat. I get the same behavior when messing around with certain static combinations of LineTo commands. I tried my other 328 (that normally lives in my arduino) with the same results. I put the original 168 back in the Peggy and all is working correctly again.

So I'm wondering if anyone else has run into similar problems using the 328 in the Peggy2 or if the bootloader in the ATmega328 from EMSL has been tweaked in some way (and if so, can I get the code?).

I'm using arduino-14 with the Peggy2 0.3b library.

Thanks!





       
   
By: DaveParker (offline) on Thursday, April 02 2009 @ 10:52 AM PDT  
DaveParker

Replying to my own post with new user login. No more anonymous coward. Big Grin


Forum Apprentice
Apprentice

Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Thursday, April 02 2009 @ 11:20 AM PDT  
Windell

The ATmega328P "for Peggy 2" that our web store has is just a regular ATmega328P, with the "stock" Arduino Bootloader, and the default Peggy 2 program running on top of that-- so there's nothing unusual there.

I have not seen the problem that you are describing. It *could* be that you are instantaneously drawing too much power at one point, dropping the voltage too low and resetting. But... it's surprising to me that something could behave so differently between the 168 and 328! Anyway, I'll give it a try, and see if I can reproduce the problem.

-Windell



Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: DaveParker (offline) on Thursday, April 02 2009 @ 11:30 AM PDT  
DaveParker

Thanks Windell!

Oh, if it is of any importance, my Peggy is using the 10mm diffuse white LEDs (fully populated)... I'm not sure if they draw more power than other types.


Forum Apprentice
Apprentice

Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Thursday, April 02 2009 @ 11:36 AM PDT  
Windell

Peggy 2 uses current-regulated drivers, giving the same current draw for any LED color.

The Peggy 2.1 does have a power adjustment, you might try turning both pots to minimum to see if the problem persists.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: DaveParker (offline) on Thursday, April 02 2009 @ 02:52 PM PDT  
DaveParker

Humm... the trimming pots do have an affect...but it's a little complicated. I ran a series of tests with my peggy2.1 running the peggy2_MoveToLineTo sketch. With an ATMega168, the peggy runs the sketch just fine with both pots set at either their max or min value. However, with the ATMega328 peggy doesn't run the sketch properly at either extreme. With the pots set to their min resistance (bright), peggy will reset immediately after starting the sketch (alternating between two lit rows and nothing every second or so). With the pots set to the max resistance (dim), peggy resets after the 8th loop every time.

I ended up running a series of tests while measuring the resistance between GND and pin 23 of each STP16DP05 LED driver which sets the constant current. I measured the in-circuit resistance with the power off and kept the resistance of both LED drivers the same. I'm powering the peggy using the wall slug that it came with. I measured the voltage while the peggy was running at 5.08V.

5.5K - instant reset
3.0K - reset after 8th loop
1.5K - reset after 8th loop
1.2K - reset after about 30 seconds
1.1K - reset after about 30 seconds
1.05K - reset after about 30 seconds
1.025K - reset after about 30 seconds
1.0K - reset after about 3 minutes
0.975K - reset after about 3 minutes
0.965K - reset after 1.5 minutes
0.960K - reset after either 10 or 30 seconds. Sporadic.
0.950K - reset after 8th loop
0.900K - reset after 8th loop
0.743K - reset after 8th loop

So my peggy with ATMega328 seems to work best in a tight band around 1K.

I only tried one 328 and not my 2nd one. However, both chips work fine in an arduino.

I quickly eyeballed the specs on the 168 and 328 and it looks like there are some current driving differences between the two chips. However, I don't know if this is the cause.

For the time being, I'm quite content to tinker using the 168 chip. I don't currently need to use the 328. I was just trying it because I had one. However, I'm curious to know what's going on and if my peggy is special in some way...and is fixable...or if some alterations are needed to the design....or software. The peggy with the 328 runs most example sketches just fine after all. Perhaps it's driving an all-on row followed by an all-off row that it doesn't like? I'll fiddle a little more to see if I can make any rhyme or reason out of why it decides to reset.

Best,
Dave


Forum Apprentice
Apprentice

Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Thursday, April 02 2009 @ 03:18 PM PDT  
Windell

Ah-- one thing that could easily be causing the difference between the 168 and the 328: if the fuse bytes have different settings on the two, giving a different brownout voltage on the 328. The brownout detection level on the '168 (Arduino default) is 2.7 V. Now... do you know what the settings on your '328 are? Does it have the current-revision Arduino firmware? Did you program it yourself to set the fuse bytes?


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Windell (offline) on Thursday, April 02 2009 @ 03:29 PM PDT  
Windell

Yes, more signs point to that: If a '328 were programmed with the same fuse settings that are normally used for the '168 based Arduino systems, that would configure the '328 to reset whenever its power supply gets down to 4.3 V, not 2.7 V. *BIG* difference.

Workaround #1: Reflash that '328 with the proper fuse values.
Workaround #2: Add a much bigger capacitor to the circuit, in parallel with the 1000 uF one that's already there. Maybe a 10,000 uF to 100,000 uF, 10 V, should make things happy.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: DaveParker (offline) on Thursday, April 02 2009 @ 05:27 PM PDT  
DaveParker

I'm learning all sorts of things today...which is great! I figured out how to read the fuse values of the 168 and 328p I've been using with my usbtiny programmer. As far as I can tell, the fuses are programmed correctly. One of my 328p's came in an Arduino Duemilanove. The other I programmed using the "Tools > Burn Bootloader > w/ USBTinyISP" option in arduino-14. According to the datasheet, my 328p's are set with a brown-out voltage V(BOT) of 2.7V (typ).

PHP Formatted Code
328p (same for both of them)
high:     0b11011010
low:      0b11111111
extended: 0b101

168
high:     0b11011101
low:      0b11111111
extended: 0b0



So I don't think this is my problem (emphasis on "this" and not "my"Wink. I could try the additional cap idea...or try using my bench supply..but later. It's dinner time! ....well almost.


Forum Apprentice
Apprentice


Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Thursday, April 02 2009 @ 09:50 PM PDT  
Windell

Okay, I've just tried this and I'm not able to reproduce the error with batteries or plug-in power supply... peggy2_MoveToLineTo seems to run fine on either my 168 or 328.

The driver chips should be taking the full load of the current driving, leaving very little current consumption for the AVR. It is *conceivable* that a solder bridge in the right place could cause one of the rows to be requiring too much current to run. Hard to say.

A second possible cause is that the power supply could be tripping off momentarily, if you're exceeding its capacity. That *should not* happen, by the current limits that we set. However, something is wrong *somewhere.*



Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: DaveParker (offline) on Friday, April 03 2009 @ 12:16 AM PDT  
DaveParker

Thanks for the info Windell. I've done some more investigating with my peggy2. The short version is that the 328P seems to work fine if I lower the voltage to around 4.7V.

I tried a different regulated wall slug with a 4.5V output and that worked okay (voltage was really 4.7V). I also hooked the peggy2 up to my bench supply and found that it ran ok at 4.7V or 4.8V (pulling between 50mA and 60mA) but went into the reset condition when the voltage was between 5.0V and 5.1V. When the reset condition happens the current spikes to ~360mA as (at that point) three rows are brightly lit. Using a multimeter, I didn't see the voltage drop on Vcc going into the 328p. I think it's time to hit craigslist for a good used scope.

I dug out my magnifier and looked at the solder connections around the 328p and the LED drivers (and caps and resistor) and didn't see any bridging or flaky looking connections. I swapped the two LED drivers but the behavior didn't change.

To explore the reset condition at 5V I wrote a short sketch to cycle through turning each row on at a time. Rows 0 - 3 lit normally, but when it go to row 4 it went into reset. I started adding exclusions to rows. I found that rows 4,5,8,11 were problematic. When I added an exclusion for row 12, the peggy2 then started resetting after row 9. I verified that this was repeatable....very strange. At this point I gave up and verified that I could cycle across all the rows at 4.7V.

So my workarounds are to a.) not use the 328 or b). use my other lower voltage wall slug.

Anyhow, thanks for your advise on this. If you have any brainstorms, please let me know...but for now I'm going to get back to trying to use the peggy for something. I'm planning on hooking an xbee to it and then sending it some data that does something cool....no idea what that is yet, but I'm sure I'll come up with something Smile


Forum Apprentice
Apprentice


Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Friday, April 03 2009 @ 07:19 PM PDT  
Windell

Okay, I'm quite a bit puzzled by that. I was testing it with a 5 V power supply yesterday and didn't see any issues.

One other thing to check... I might expect behavior like this if you did not have the big capacitor on the board, or if it were backwards or otherwise damaged. You might check to make sure that's doing the right thing-- one way would be to try taking it out, to see if that makes it worse. Current spikes *should* be smoothed out by that cap pretty well.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Art Dahm (offline) on Saturday, April 04 2009 @ 09:06 PM PDT  
Art Dahm

Peggy 2.1?


Art Dahm • My Peggy 2.0 Web Page • www.mindlessdiversions.com/peggy2/

Forum Apprentice
Apprentice

Status: offline

Registered: 06/07/08
Posts: 10
Los Angeles, CA

Profile Email Website  
   
By: DaveParker (offline) on Saturday, April 04 2009 @ 10:13 PM PDT  
DaveParker

Yes, it's a 2.1 with the pots to tweak the column brightness.


Forum Apprentice
Apprentice

Status: offline

Registered: 04/02/09
Posts: 13

Profile Email    
   
By: Windell (offline) on Saturday, April 04 2009 @ 11:07 PM PDT  
Windell

>Peggy 2.1?

We've added occasional minor "bumps" as they become available-- it's still what we're calling "Peggy 2" these days. Big Grin


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   



 All times are PDT. The time is now 06:10 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?