Forum Index > Projects > LED Pegboard and Matrix Projects
 USBTinyISP question
 |  Printable Version
By: jamie (offline) on Thursday, March 06 2008 @ 01:32 PM PST (Read 16129 times)  
jamie

Hi,

I am going to attempt to program the microcontroller on my peggy. I bought the USBTinyISP kit from adafruit.net, put it together, have the drivers and winavr installed, and that's where I'm at.

I could have sworn I saw a page somewhere here that showed screenshot examples of how to compile a script and write it to the controller via the USBTinyISP programmer, but I can't for the life of me find that page now. Does anyone have the link to that page?


Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: Windell (offline) on Thursday, March 06 2008 @ 03:20 PM PST  
Windell

With screenshots? I'm not sure that we have one like that, but I'll walk you through it.

(LadyAda has some screenshots: http://www.ladyada.net/make/usbtinyisp/avrdude.html)


Before plugging in the programmer, make sure that the power supply connections are correct. The usbtiny programmer can provide power to a target board, if it doesn't require much power. Peggy can potentially draw quite a bit of power at startup, so we need to have it (her?) independently powered during programming. Step 1: Turn on power to the peggy board-- the LEDs should be on. Step 2: Remove the jumper on the programmer that provides power to the target board-- it's the little jumper by the 6 and 10 pin cables. Step 3: Attach the 6-pin cable to the Peggy, matching the red stripe of the cable to the end of the connector with the arrow. Step 4: Connect the USB cable to your computer, and try to program it.

(Also note: If everything was working and stops working at some point, it can sometimes help to unplug the USB cable and plug it back in again-- I think that the USB port can be shut off if it spikes at too much power.)


The Peggy firmware (original version) is here:
http://www.evilmadscientist.com/source/peggy1_0.zip

Or, you can go for the new-and-more interesting firmware here, which fades in and out, and then adds some "noisy" scanlines:
http://www.evilmadscientist.com/source/peggy_scanline.zip

No matter which version you use, uncompress the archive and move into that directory. Open up the makefile with a text editor and check that the following settings are correct:

PROGRAMMER = usbtiny
PORT = usb
MCU_TARGET = atmega164p
AVRDUDE_TARGET = m164p

NOTE: The "p" suffix is required for the current versions of the AVR toolchain-- it was inconsistently required (or not) for some older versions.

Save the makefile. Open a terminal window and change to that directory. Type "make all" (no quotes) and return. It should look something like this:

PHP Formatted Code
oskay$ make all
avr-gcc -g -Wall -Os -mmcu=atmega164p     -c -o peggy.o peggy.c
peggy.c: In function 'main':
peggy.c:246: warning: unused variable 'iteration'
peggy.c:244: warning: unused variable 'j'
avr-gcc -g -Wall -Os -mmcu=atmega164p   -Wl,-Map,peggy.map -o peggy.elf peggy.o
avr-objdump -h -S peggy.elf > peggy.lst
avr-objcopy -j .text -j .data -O ihex peggy.elf peggy.hex
avr-objcopy -j .text -j .data -O binary peggy.elf peggy.bin
avr-objcopy -j .text -j .data -O srec peggy.elf peggy.srec
oskay$


Note: Your name may not be oskay. Wink

If it looks like that, ending in a bunch of "avr-objcopy" lines, the compile was successful. If not, you'll get error messages that use the word "error."

Next, run the installation command: make install

A lot of text will go by, since the avrdude program does a lot of stuff. If all goes well, the last few lines output by avrdude should look something like this:

PHP Formatted Code

[....]
avrdude: verifying ...
avrdude: 6623  bytes of flash verified

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK

avrdude done.  Thank you.



If it looked like that, everything worked properly and you have reprogrammed your board. Some rows of LEDs will blink during the programming process.

If you instead get error messages, something has gone wrong in the avrdude setup. Again, try (once) unplugging the USB and plugging it back in. Then, go have a look at this page:
http://www.ladyada.net/make/usbtinyisp/help.html


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: jamie (offline) on Friday, March 07 2008 @ 07:49 AM PST  
jamie

Thanks for the great instructions! I struggled until about 2am last night trying to get it to work. I keep getting "initialization failed, rc=-1" from avrdude when running "make install". I read through just about every thread in the ladyada.net forums and couldn't fix it. I'm going to get back at it tonight.


Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: Windell (offline) on Friday, March 07 2008 @ 07:59 AM PST  
Windell

Be sure and go through the "Help" page that I linked to at the end. Also see this thread where someone else has seen a similar problem-- apparently it helped to unplug the 10-pin cable!


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: jamie (offline) on Friday, March 07 2008 @ 09:08 AM PST  
jamie

I tried just about everything, including removing that cable. In case my 6 pin cable was bad, I also tried the ten pin cable on the 6 pin header. They mention that you use version 1.10 USBTiny drivers for the newer versions of avrdude, and 1.12 versions for older versions, or something like that. I've swapped drivers so many times, applied a patch they have there, tried it on 2 different PCs, tried it with the board powered by itself, tried it with the programmer powering the board, etc....

I'm pretty good with soldering, and I'm confident I soldered the USBTinyISP kit together properly. I'm going to start tracing out connections with my meter to make sure everything is connected to where it should be tonight.

You don't have to have a crystal in the peggy board in order to program it do you?

Could the board hack I did to wire up some LEDs to other rows be preventing the programmer from talking to the AVR chip in peggy? I can't imagine it would. I was thinking of maybe removing the AVR chip in the peggy board, putting it in a socket, and connecting the pins directly to the programmer to rule out anything on the peggy board as a cause. Would that be a waste of time?


Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: Windell (offline) on Friday, March 07 2008 @ 09:13 AM PST  
Windell

I do suspect that the problem is in the programmer. For the other one that wasn't working (in the other thread), I took my programmer over there one day and actually tried it out-- I was able to program it. So there's something going wrong with *some* of these programmers on *some* of these boards... it's as though some spec is only barely being met. You certainly could try programming the chip on its own-- it would be interesting if that helps, but there is no reason that it should not work to program in system as well.

(A crystal is not needed.)

I'm going to try to reproduce this problem here-- I've just ordered a new programmer and I'll see if I can get it to screw up. If I can, maybe there's a fix. Mr. Green


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: jamie (offline) on Friday, March 07 2008 @ 09:31 AM PST  
jamie

That's great if you could reproduce it and figure out how to fix it. If I get it working tonight I'll let you know. It's funny that this part is the hardest. You would think either the soldering of the kit, or the actual programming would be more difficult.


Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: Windell (offline) on Saturday, March 08 2008 @ 03:52 AM PST  
Windell

I have been able to reproduce the problem and solve it in two different ways-- so a solution exists, if not a beautiful one. Smile

Stay tuned.


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: bbum (offline) on Saturday, March 08 2008 @ 12:46 PM PST  
bbum

Oooh... can't wait for details on this!


Forum Henchperson
Henchperson

Status: offline

Registered: 01/23/08
Posts: 22

Profile Email    
   
By: jamie (offline) on Saturday, March 08 2008 @ 12:52 PM PST  
jamie

Hey bbum,

I fixed my USBTinyISP via option #2 here:
http://www.ladyada.net/forums/viewtopic.php?t=5342

It worked great for me...not sure if that will be the official solution or not but I'm up and running. Smile

BTW....thanks for donating the animation code you posted in one of your other threads. I used it as the basis to program my Pac-Man ghost sign. I'm writing a final post about it on my site right now...should be up in a few minutes:
http://www.noiselandarcade.net


Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: bbum (offline) on Saturday, March 08 2008 @ 02:33 PM PST  
bbum

Quote by: jamie

Hey bbum,

I fixed my USBTinyISP via option #2 here:
http://www.ladyada.net/forums/viewtopic.php?t=5342



Thank you for the link and Windell for the fix!! Once I have the strength to lift a soldering iron (stupid flu), I'll slap a couple of zero own resistors into the circuit and be done with this bug.


It worked great for me...not sure if that will be the official solution or not but I'm up and running. Smile

BTW....thanks for donating the animation code you posted in one of your other threads. I used it as the basis to program my Pac-Man ghost sign. I'm writing a final post about it on my site right now...should be up in a few minutes:
http://www.noiselandarcade.net[/p][/QUOTE

Awesome! I'm glad the code was of use. If you based it on the latest from the svn repository, it uses the 'off' switch as a mode switch between animated, solid on, and off. Could be easily modified to not light up the rows of one frame in your case. The code also demonstrates one means of de-bouncing a switch; probably not the best way, but -- hey -- it works!

That is a really neat sign. I was thinking I might have to toss together a Peggy w/a little semi-animated Robotron dude...

b.bum


Forum Henchperson
Henchperson

Status: offline

Registered: 01/23/08
Posts: 22

Profile Email    
   
By: jamie (offline) on Saturday, March 08 2008 @ 03:04 PM PST  
jamie

Forum Henchperson
Henchperson

Status: offline

Registered: 02/26/08
Posts: 15

Profile Email    
   
By: bbum (offline) on Wednesday, March 12 2008 @ 10:40 PM PDT  
bbum

I dropped a couple of zero ohm resistors in, as per the instructions, and the programmer works flawlessly with the board that was previously problematic!! Thank you!! While I had the programmer opened up,I also hacked in a switch to make it easy to toggle powered vs. unpowered mode. http://www.flickr.com/photos/bbum/2329894953


Forum Henchperson
Henchperson

Status: offline

Registered: 01/23/08
Posts: 22

Profile Email    
   
By: Windell (offline) on Wednesday, March 12 2008 @ 11:31 PM PDT  
Windell

Fantastic! I'm really glad that we were able to find a solution that works. And your switch is a very good idea. (Right now I have two programmers, one with the jumper, one without. Your solution is better.)


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:02 AM.
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?