Forum Index > Projects > Larson Scanner kit and LED Menorah kit support
 Reprogramming the AVR: Menorah -> Scanner
 |  Printable Version
By: karlbyoung (offline) on Thursday, April 19 2012 @ 09:42 AM PDT (Read 1499 times)  
karlbyoung

Rank newbie here. Having tons of fun, but could use some advice, or at least moral support.

1) Built Deluxe Menorah -- worked!
2) Built Diavolino -- worked!
3) Built ISP Shield, hmm what can we program? Ah, the Menorah. Let's turn it into a scanner!
3a) Added 6-pin header to Menorah, and got appropriate cable.

The immediate goal is to upload the hex program for the Scanner into the ATTiny2313 on the Menorah board. But AVRDude is not getting appropriate responses from the ISP shield program loaded into the Diavolino.

I eliminated any issues with power (Diavolino powered by USB FTDI->TTL cable; Menorah powered from ISP shield with correct jumper setting). Communication speed at 9600 baud works fine.

NOTE: the following is for someone who understands the SPI protocol, especially the step-by-step part of it. I've assumed lots of knowledge from the mad scientists out there. I can provide many more details if necessary.

I loaded my own program into Diavolino to debug the problem, and walk through the SPI protocol (bit-banging so we can go really slow). Wanted to send standard "Enter Programming" message to tiny2313, and see what we got for a response. Enjoyed writing my program, which does the following:
-- hold down momentary switch, enter my "testing" mode (pull RESET low)
-- while in testing mode, a click on the switch will toggle the SCK line to the tiny2313
-- prior to SCK going high, set MOSI to next bit from command bytes (plenty of delay so it can settle in)
-- prior to SCK going low, read MISO, save away
-- after 16 clicks (8 bits, up and down), display returned byte over Serial back to console on my laptop
-- after 4 bytes, exit testing mode (RESET goes high)

With 6-pin cable not connected to Menorah, received 0's back (expected).

With 6-pin cable connected to Menorah, receive an echo of the command back (i.e., send, 0xAC, receive 0xAC at same time, then 0x53, then etc., etc -- not supposed to happen). With LED's connected to RESET, SCK, MOSI, and MISO, I find a curious thing: whenever I take SCK high while MOSI is also high, then MISO goes high, too (hence the echo) but also RESET goes high (hey! I didn't do that!). When SCK goes down, all the lines return to the "expected" state.

First guess: I've somehow got a bad soldering connection on the Menorah board that connects MOSI with MISO and RESET (since those lines don't affect the working of the Menorah program, I wouldn't have seen it before now -- after all, it was my first soldering attempt). Continuity test with a meter doesn't seem to bear that out.

Second guess: There's another, less obvious bad soldering connection somewhere else on the board (Oy. Have to find that, somehow)

Third guess: I messed up the tiny2313 somehow, and maybe fried the SPI pins when I soldered the chip in. (Don't look forward to de-soldering the chip -- next time a socket!).

I've bored you enough already. Question: Am I on the right track, and have I missed something obvious?

Possible responses: A) You're doing fine, atta boy! B ) Bizarre project, but nothing obviously wrong; keep at it. C) What a newb--what were you thinking? D) something else (with suggestions/explanations)

I'd appreciate any response--even (C). I can provide bunches more info.

Many thanks. I've especially appreciated the wealth of info in previous posts.

--Karl B.


Forum Apprentice
Apprentice

Status: offline

Registered: 04/19/12
Posts: 7

Profile Email    
   
By: Windell (offline) on Thursday, April 19 2012 @ 05:46 PM PDT  
Windell

This is a slightly odd approach ( B ); normally people start by saying what error they got, and we tell them to make sure that the 6-pin cable is connected correctly on both ends, and to make sure that their command-line argument is correct. Also, the reset-override thing. Don't forget that.

I work with SPI a lot, but frankly, I don't know the programming protocol in great detail. One thing that I do know is that the four SPI & reset lines are not tolerant of low-impedance loads like LEDs during the programming process. If you want to read out the signal states (without stopping programming) then put a 10k resistor in series with each LED and use very bright LEDs so that you can still see them.

One other thing to consider: The default CPU clock speed on the larson and menorah kits is only 512 kHz. That may mean that you need to use a very slow bit rate in your avrdude command line, when first programming the chip. Please see our article about "rescuing" an AVR with a low clock rate.


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: karlbyoung (offline) on Friday, April 20 2012 @ 08:07 AM PDT  
karlbyoung

Thanks for your reply. Most useful. Here's what I got from it:

1) Normally people start by saying what error they got...


Whoops. Sorry. "avrdude: Device signature = 0X00000000; Yikes! etc."

With this (all zeroes), I wanted to look into the communication and make sure we were getting real response from the attiny.

2) ...make sure the 6-pin cable is connected correctly at both ends


Check. Also checked continuity through cable and compared circuit diagrams (and PCB layouts) to understand that Pin 1 goes to Pin 1, Pin 2 to Pin 2 etc. It doesn't seem to matter, but in the schematics the numbering of the pins on the 6-pin header is different between the "ix PCB" and "ISP Shield". The important part -- physical connectivity between signals -- is consistent.

3) ...make sure command-line argument is correct


Check. Initially used the command line in the make file for the Larson project, then as debugging went on, started using more and more stripped-down version until finally (in a DOS box on Win 7):

PHP Formatted Code
    C:\WinAvr>avrdude -b 9600 -c avrisp -p t2313 -P COM8 -v



4) ..also the reset-override thing


Check. Actually tried both ways, no difference.

5) ...lines are not tolerant of low-impedance loads...[You can] put a 10k resistor in series with each LED


Now done. Used to have mere 390 ohm resistors, now upgraded to 10k. Plus, pin 13 already has an LED attached to it (on the Diavolino), although it is hidden under the shield. Since I have my step-by-step program to walk through the clock half-cycles, and can print to the console the values of pins, I may just lose the indicators.

What with all your suggestions and the implied mantra of "check, check, and double-check" I am methodically going through the entire circuit to make sure I haven't messed something up. Already found one problem that gets rid of the "echo" nonsense in my first post. Now down to just "always getting zeroes from the SPI protocol".

6) ...may mean that you need to use a very slow bit rate in your avrdude...Please see our article


I'll look into that right away. 'Twould be lovely if it were something like that.

I appreciate your time in responding. I will be posting the results of my continued research and testing over the weekend (silly day job keeps getting in the way). Unless the above sparks a new thought or suggestion, no need to respond until then. Many thanks.

--Karl B.





Forum Apprentice
Apprentice

Status: offline

Registered: 04/19/12
Posts: 7

Profile Email    
   
By: karlbyoung (offline) on Monday, April 23 2012 @ 09:33 AM PDT  
karlbyoung

Weekend testing results indicate that no reliable signal is coming back on MISO from the ATTiny.

1) The value on the input pin MISO (on the Diavolino) appears to be low, although over time it tends to float towards its neighboring pin, MOSI. This suggests to me an open connection.
2) When I activate the internal 20K ohm pull-up resistor on the Diavolino, then MISO is always High. Never changes.
3) Continuity checks on the Menorah board are inconclusive--mostly I think there's no connection between the header pin and the appropriate MISO pin on the AtTiny, sometimes it seems like there is. Re-soldering seems in order.

I could probably verify that the problem is on the Menorah board if I just broke down and bought a USB-tiny; but I got the AVR-ISP shield because it looked like more fun. It's certainly been a learning experience.

Sorry if I'm boring everyone with this exercise, but it is useful for me to be able to get some feedback. Any last suggestions?

Thanks so much,

--Karl B. Young


Forum Apprentice
Apprentice

Status: offline

Registered: 04/19/12
Posts: 7

Profile Email    
   
By: karlbyoung (offline) on Monday, April 23 2012 @ 10:50 PM PDT  
karlbyoung

Success. And the culprit was -- poor soldering. When I re-soldered some of the critical pins, and the header, suddenly all started working. It is a joy to see (brings a tear to me eye).

The Menorah is now a scanner.

And I have an AVRISP that works.

--Karl B.


Forum Apprentice
Apprentice


Status: offline

Registered: 04/19/12
Posts: 7

Profile Email    
   



 All times are PDT. The time is now 08:55 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?