ATTiny-85 Does Color VGA, Sound and Joystick @ 32MHz!!

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

Greets Fellow Freaks!

Had a day off to hack about in my lab, so I came up with a challenge, and here are the results.

The Challenge : To make an ATTiny do color VGA and Sound.

So once I wired up the little chip to my AVRisp, I realized the challenge I would be facing. First was the severe lack of IO pins. Once you add an external clock, you have only 4 Io pins to use! Out of the 6 available IO pins, the clock uses one, and so does the in circuit programmer. Sure, you could blow the ISP fuse, but then you need to track down a beast called a high voltage programmer - not cool! So here I was faced with doing color VGA and sound out of only 4 IO pins.

Ok, we need at least 3 pins to do color VGA. You can mix horizontal and vertical sync to a single pin, and that leaves 2 pins for color, which results in 4 possible colors (3 colors and black). This left a single pin for sound, which would add another challenge, since I wanted to have at least 3 voices to play musical notes, sound effects and chords.

Well, to make this short, I ended pushing the ATTiny-85 to the absolute edge of sanity, and the system can do 4 color rock solid VGA (over a 640x480 screen), has 4 independent sound voices, and even includes an analog joystick with fire button! Games like PacMan, Space Invaders, and the like will be easily possible.

All of the heavy lifting is done in the background via assembly interrupt, and the user code is in C, with a complete set of libraries made. There are multiple video modes, and about half the program memory (4K) is free for the main C program. This is not a "chasing the beam" type of system, it is fully bit-mapped, so programming is super easy. I will publish this in great detail soon.

Here are some of the tricky things done to make this possible...

- Found that I could actually use the ADC with the reset pin (B.4) active by pushing it up from ground above the reset level a bit. Scored one more IO pin, and now the unit became a video game system!

- Found out that all VGA monitors support composite sync (mixed horizontal and vertical sync). Tried many new and old monitors.

- Found a tricky way to use the 2 8 bit timers to remove all interrupt latency. This was a challenge since the active line interrupt needs 1016 cycles. Without removing AVR's interrupt latency, VGA video looks horrific, or does not work at all. One missing cycle out of a frame of 266192 cycles is enough to make a monitor display nothing at all. You need STRICT control of cycles to make video.

- Found a way to mix 4 independent sound voices onto a single IO pin without needing a timer and did this in under 40 cycles!

- Learned that the ATTiny 25/45/85 series are rock solid at 32MHZ!!! you can even force the internal clock up to 33MHZ, but sadly the internal clock is not stable enough for VGA, so an external oscillator is necessary as with all AVRs, even the XMega. But 32MHZ is amazing for a 2 dollar chip!

Here is a very basic video of the "Quark-85 Game System" doing some sound and color...


https://www.youtube.com/watch?v=...

This will be one of the 3 game systems I intend to document and publish soon. If I have the time, I will post the preliminary project here with a schematic and source code for a Space Invaders clone. This project requires an ATTiny-85, 6 resistors, 2 capacitors, a 500K pot and switch (for the joystick), and a 32MHz oscillator module.

Unless you dig into the assembly core library, programming is super easy, since it is all done in C and require no interrupts or knowledge of the video timing. Code is like this...

While(1) {
CLEARSCREEN(2);
DRAWTEXT("Hello Freaks");
SHOWPIC("FreaksLogo",10,10);
PLAYSOUND(Voice1,220);
X = JOYSTICKPOS;
y = 20;
DRAWPIXEL(X,Y,1);
WAITLINE(480);
}

Will document this in full detail when time presents itself again.

Cheers Freaks, keep up the great work on this forum!

- Radical Brad -

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

Last Edited: Sun. Aug 31, 2014 - 03:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is simply amazing! Great work!!!

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

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

so, why do you require a password to view it?

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

Hey thanks!

I must admit, banging out a game system on an 8 bit AVR with 4 IO pins is a hell of a lot more fun than dropping an HD core onto an FPGA and hitting "compile".

I find my hobby going back to the bare metal and even 7400 logic more and more lately, and the enjoyment level has shot way up as well!

DO1THL wrote:
This is simply amazing! Great work!!!

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

Odd, anyone else have this issue? I only use Youtube to dump vids, and never changed anything about security.
It is getting views, so it must work for some viwers.

Brad

RickB wrote:
so, why do you require a password to view it?

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

Quote:

Odd, anyone else have this issue?

No problem here with Firefox and W7.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

At one point during this journey, I though it may be impossible for a micro-controller that has only 512 bytes of SRAM and 4.5 IO pins to blast out a fully bitmapped color VGA animation at 60 frames per second, but then I realized - this is no ordinary hunk of silicon man, it's a bloody AVR!

Now this is hot....


https://www.youtube.com/watch?v=...

Cheers,
Brad

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

It states that the video is private thus a google password is required. I did that, but why make it private? Just another google irritation.

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

Glad to see you're as mad as ever!

274,207,281-1 The largest known Mersenne Prime

 

"Head the warning. Avoid strong drink. It will make you shoot at politicians' -and miss."  -- B.Franklin.

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

Crazy as ever!

Sorry about the video, I fixed it now.
Seems Youtube auto sets it to "private", and you have to dig for the "public" setting. I use this site once a year, and each time it is completely different!

https://www.youtube.com/watch?v=...

Cheers!
Brad

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

Can't wait to see how you did it. Never liked space invaders, but maybe something else.

274,207,281-1 The largest known Mersenne Prime

 

"Head the warning. Avoid strong drink. It will make you shoot at politicians' -and miss."  -- B.Franklin.

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

Fantastic!

AtomicZombie wrote:
- Found that I could actually use the ADC with the reset pin (B.4) active by pushing it up from ground above the reset level a bit. Scored one more IO pin, and now the unit became a video game system!
Indeed:
http://www.avrfreaks.net/index.p...

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

That is some impressive work!

I hope you won't get offended, but is there anything that I could read about chip-tunes, really like them, never really understood how the sound is generated in the micro-controller, I would love to make a mini tracker with an avr, like a drum sequencer like a TR 808 but with different sounds.

Keep the great work.

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

Quote:

It states that the video is private thus a google password is required. I did that, but why make it private? Just another google irritation.

I'm guessing most people here have an Android phone so have a Google identity. Perhaps that's what's missing from your life? ;-)

BTW, like others I think what's being achieved using a tiny85 here is truly amazing.

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

Thanks for all the posative feedback!

Android phone? yeah, one of the 2 things I don't own, that and a television set. Never "texted" in my life, and last time I turned on a TV, the Simpsons just came out! All free time is spent next to a breadboard.

[UPDATE]

Removed the joystick POT and figured out how to add a standard retro style joystick (4 positions and a fire button). Now the ATTiny (with 4 available IO pins) is achieving the following...

- 4 color bitmapped VGA over a 640x480 screen
- 4 independent sound voices to play music
- Atari style joystick input
- 2,743,200 free cycles /second for user program!

I have 50% of a Space Invaders like game done, and hope to get a few free hours to complete it. Will post a preliminary project with schematic soon.

Cheers,
Brad

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

And I'm just trying to blink 2 leds...

274,207,281-1 The largest known Mersenne Prime

 

"Head the warning. Avoid strong drink. It will make you shoot at politicians' -and miss."  -- B.Franklin.

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

Well generating VGA ain't too much different - you just need to blink 307,200 X3 LEDs 60 times per second!

brad

Torby wrote:
And I'm just trying to blink 2 leds...

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

Dancing is easy when you know how...

Ross McKenzie ValuSoft Melbourne Australia

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

... but don't be afraid to step on a few toes and learn new moves!

valusoft wrote:
Dancing is easy when you know how...

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

I swear someone posted a similar project a year or two ago, where they got RGB and sound output from an '85. At first I thought this was that thread, except I saw that this thread is only a few days old.

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

A-Z,
Your work is amazing. I am wondering what you do for a day job? With your great skills, how do you avoid being kidnapped by the NSA? :)

It all starts with a mental vision.

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

blargg wrote:
I swear someone posted a similar project a year or two ago, where they got RGB and sound output from an '85. At first I thought this was that thread, except I saw that this thread is only a few days old.
I think it's the same project:
http://www.avrfreaks.net/index.p...

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Would love to see the code and build one ... or a hundred.

Seriously, if you'd like to turn this into a real product for those type that would be interested (and we know who we are), I can help.

Show me the code! :D

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

Dale, did you do the LCD driver for BG Micro ( ? ) in the remote past?

(If so, I've still got several of them in my parts bins!)

JC

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

@DocJC: Yes, that was me. It was my first and last PIC project. I've been a happy AVR camper ever since.

You can still find the support website (PIC-an-LCD.com) by using the Wayback Machine:

http://web.archive.org/web/20050...

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

Time has been very limited lately, but I did manage to do a bit more on the ATTiny-85 VGA game thing (Quark-85) while waiting for tiles to set.

I added an Atari / C64 compatible joystick port and optimized some of the graphics libraries.

 

To recap, this is an ATTiny-85 doing 4 color rock solid VGA, 4 voice sound and joystick input.

This chip offers the following lack of resources...

 

- 3 usable IO pins

- 512 bytes of RAM

- 8k of Program Space

 

I look forward to detailing how a 3.5 pin device can handle the following IO requirements...

 

- VGA Analog Red Signal

- VGA Analog Green Signal

- VGA Horizontal Sync

- VGA Vertical Sync

- Audio Output

- 5 Position Digital Joystick

 

That's basically 10 separate systems running from 3.5 IO pins. I say 3.5 pins because I am sneaking the ADC off the reset pin without killing the programming fuse bit.

Here is a video showing the result of 15 minutes of C programming in GCC using AVR studio...

 

 

Click for Video...

https://www.youtube.com/watch?v=8Z5Gcl8Py7Y&feature=youtu.be

 

All game coding can be done in C because the assembly audio/video engine runs silently in the background. Here is a chunk of code from the game...

 

// MOVE PLAYER SHIP
if (AVRC_JOYSTICK == 2 & SHIP_X < 59) SHIP_X++;
if (AVRC_JOYSTICK == 1 & SHIP_X > 0) SHIP_X--;

// DRAW PLAYER SHIP
AVRC_DRAWSPRITE(SHIP_X,45,SHIP);

// FIRE PLAYER MISSLE
if (AVRC_JOYSTICK == 5 & MISSLE_Y == 0) {
    MISSLE_X = SHIP_X + 2;
    MISSLE_Y = 45;
    }    

// DRAW PLAYER MISSLE
if (MISSLE_Y > 7) {
    AVRC_DRAWPIXEL(MISSLE_X,MISSLE_Y);
    AVRC_DRAWPIXEL(MISSLE_X,MISSLE_Y+1);
    MISSLE_Y = MISSLE_Y - 2;
    }
if (MISSLE_Y == 7) MISSLE_Y = 0;

 

I will complete this game next time I have an hour or so, adding, scores, music, levels, animated aliens, etc.

So far this basic game fragment only uses about 20% of the program memory!!

 

Ok, now back to the real world... *CLICK* -> Matrix Jack Removed.

 

 

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

Last Edited: Sat. Sep 13, 2014 - 09:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AtomicZombie wrote:

I added an Atari / C64 compatible joystick port and optimized some of the graphics libraries.

 

Neat. I can find a modern use for those C64 joysticks I've had since they were new.

 

I'm a little curious how you managed to detect all five switches with a single (or half of one) input pin. Are you essentially converting the digital inputs to analog with a 5-bit DAC (perhaps with an R2R resistor ladder) and then reading in the voltage from that with the ADC port?

Last Edited: Sun. Sep 14, 2014 - 10:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

christop wrote:

 

Neat. I can find a modern use for those C64 joysticks I've had since they were new.

 

 

I'm a little curious how you managed to detect all five switches with a single (or half of one) input pin. Are you essentially converting the digital inputs to analog with a 5-bit DAC (perhaps with an R2R resistor ladder) and then reading in the voltage from that with the ADC port?

 

In order to use the ADC on PINB.5 without killing your ability to ever program the chip again, you need to create a window of positive voltage above the reset point. Internally, leaving the programming fuse active does not stop the ADC from working, you just need to avoid dropping the reset too low.

 

So I found a way to do this with 5 resistors; different values for UP, DOWN, RIGHT, LEFT, and direct to VCC for FIRE. A 5th resistor is a divider to GND, but above the dropout voltage level that triggers a reset.

 

In order to make the C programming easier, I interleaved the ADC read system into the video rendering loop (assembly side), so it just sets a shared variable "JOYSTICK" to one of 5 values.

 

On the C side, you can access the joystick like this (wait for a FIRE button press)...

 

while(AVRC_JOYSTICK != 5);

Here is part of the assembly background code, showing how I read the ADC and set the variable during a pixel line rendering...

 

////////////////////////////////////////////////////////////////////////////////////////////////////////
////////// DRAW 64 PIXEL HORIZONTAL LINE / READ JOYSTICK ADC
////////// 814 CYCLES - 46 BORDER = 768 / 12 = 64 PIXELS / 8 = 8 BYTES
////////// SCREEN RESOLUTION : 73 X 48 X 1 OF 4 COLORS
////////// COLORS = 0:BLACK / 1:RED / 2:GREEN / 3:YELLOW
////////////////////////////////////////////////////////////////////////////////////////////////////////
AVRC_BMP:

// SEND PIXEL BIT 1 OF 8
ld r1,Y+ ;2
nop ;1
mov r0,r18 ;1
sbrc r1,0 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
nop ;1
nop ;1
nop ;1
nop ;1
nop ;1

// SEND PIXEL BIT 2 OF 8
nop ;1
nop ;1
nop ;1
mov r0,r18 ;1
sbrc r1,1 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
nop ;1
nop ;1
nop ;1
nop ;1
nop ;1

// SEND PIXEL BIT 3 OF 8
nop ;1
nop ;1
nop ;1
mov r0,r18 ;1
sbrc r1,2 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
nop ;1
nop ;1
nop ;1
nop ;1
nop ;1

// SEND PIXEL BIT 4 OF 8 / READ ADC (12)
nop ;1
nop ;1
nop ;1
mov r0,r18 ;1
sbrc r1,3 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
nop ;1
nop ;1
nop ;1
nop ;1
in r19,ADCH ;1

// SEND PIXEL BIT 5 OF 8 / JOYSTICK FIRE (12)
nop ;1
nop ;1
nop ;1
mov r0,r18 ;1
sbrc r1,4 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
cpi r19,250 ;1
brlo AVRC_AD1 ;1/2
ldi r19,5 ;1
AVRC_AD1:
nop ;1
nop ;1

// SEND PIXEL BIT 6 OF 8 / JOYSTICK RIGHT & LEFT (12)
cpi r19,230 ;1
brlo AVRC_AD2 ;1/2
ldi r19,4 ;1
AVRC_AD2:
mov r0,r18 ;1
sbrc r1,5 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
cpi r19,215 ;1
brlo AVRC_AD3 ;1/2
ldi r19,3 ;1
AVRC_AD3:
nop ;1
nop ;1

// SEND PIXEL BIT 7 OF 8 / JOYSTICK DOWN & UP (12)
cpi r19,190 ;1
brlo AVRC_AD4 ;1/2
ldi r19,2 ;1
AVRC_AD4:
mov r0,r18 ;1
sbrc r1,6 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
cpi r19,150 ;1
brlo AVRC_AD5 ;1/2
ldi r19,1 ;1
AVRC_AD5:
nop ;1
nop ;1

// SEND PIXEL BIT 8 OF 8 AND LOOP / STORE JOYSTICK (12)
nop ;1
sts AVRC_JOYSTICK,r19 ;2
mov r0,r18 ;1
sbrc r1,7 ;1/2
mov r0,r17 ;1
out PORTB,r0 ;1
dec r16 ;1
nop ;1
breq AVRC_PXE ;1/2
rjmp AVRC_BMP ;2
AVRC_PXE:
pop r19 ;2

 

I intend to detail this entire project line by line and wire by wire this winter. This will be one of three video game projects I plan to detail in a new E-Book download for my new site.

 

 

Brad - AVR Fanboy!

 

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

Last Edited: Sun. Sep 14, 2014 - 02:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How did you make your 6-pin ICSP header to breadboard plug?

 

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

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

Quote:
so it just sets a shared variable "JOYSTICK" to one of 5 values.
That means if you move or release the joystick while the fire button is pressed the event is delayed until the fire button is released.  If more than one joystick event occurs while the button is pressed, all but the last one will be lost.

 

You currently have:

 

                                               VCC
                                                |
 +----------------------------------------------+
 |                                              |
 |                                +------------------/
 |                                |             |
 |  R__|__                    ADC5|             |
 +---+   +---\/\/\---+------------|-----\/\/\---+   
 |                   |            |    pull-up
 |  L__|__           |            |
 +---+   +---\/\/\---+            |
 |                   |            |       ATtiny85
 |  D__|__           |            |
 +---+   +---\/\/\---+            |
 |                   |            |
 |  U__|__           |            |
 +---+   +---\/\/\---+            +------------------/
 |                   |                          |
 |  F__|__           |                          |
 +---+   +-----------+---\/\/\------------------+
                                                |
                                                |
                                               GND

                                    
                       
                      
Try this instead:

 

                                               VCC
                                                |
 +----------------------------------------------+
 |                                              |
 |                                +------------------/
 |                                |             |
 |  R__|__                    ADC5|             |
 +---+   +---\/\/\---+------------|-----\/\/\---+   
 |                   |            |    pull-up
 |  L__|__           |            |
 +---+   +---\/\/\---+            |
 |                   |            |       ATtiny85
 |  D__|__           |            |
 +---+   +---\/\/\---+            |
 |                   |            |
 |  U__|__           |            |
 +---+   +---\/\/\---+            +------------------/
 |                   |                          |
 |  F__|__           |                          |
 +---+   +---\/\/\---+---\/\/\------------------+
                                                |
                                                |
                                               GND


Selection of the resistors will be more challenging, but it will separate the fire button from the joystick as another 'channel', giving you two different ranges for R/L/D/U, one with the fire button pressed, and one with it released.

EDIT: Whoops, corrected a blatant flaw in the new schematic.

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Sep 14, 2014 - 06:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ralphd wrote:

How did you make your 6-pin ICSP header to breadboard plug?

 

Get yourself a few 90 degree 6 pin headers and bend them like so with pliers...

 

 

Digikey part number... 609-3343-ND

 

Brad

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

Last Edited: Sun. Sep 14, 2014 - 05:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:

 

Quote:

so it just sets a shared variable "JOYSTICK" to one of 5 values.

That means if you move or release the joystick while the fire button is pressed the event is delayed until the fire button is released.  If more than one joystick event occurs while the button is pressed, all but the last one will be lost.

Selection of the resistors will be more challenging, but it will separate the fire button from the joystick as another 'channel', giving you two different ranges for R/L/D/U, one with the fire button pressed, and one with it released.

 

Indeed! My original setup was like that, but I found it difficult to get that range with the ADC running in "hacked" mode. Using another pin for ADC, I could do this easily, even with 8 bits.

I might try it again though, maybe adding a self calibrating routine at the start of the engine initialization.

 

Brad

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

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

I wrote a brute-force resistor selector for something similar a while ago. It was made to find optimal resistor values for an array of N switches with N+1 resistors, such that all 2^N button combinations would yield a unique ADC result, and such that the 'distance' between adjacent readings was maximised.  You'd feed it the resistors you have in your parts bin, or a series (E6, E12, E24, etc) and spits out what goes where and what the expected ADC values will be for each switch combination.

 

I'll try to dig it up and tweak it for the above schematic.  What is the value of your GND-divider resistor?  Have you characterised the value of the reset pullup?  It will of course vary from device to device, and the reset threshold voltage will as well, but just so I have a starting point.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Thanks, I will post the current schematic when I have the next chance.

Just into some tile grouting now, then heading to China for 3 weeks, so I will be off the AVRFreaks grid for a while!

 

Brad

 

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com

Last Edited: Sun. Sep 14, 2014 - 05:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AtomicZombie wrote:

 

ralphd wrote:

 

How did you make your 6-pin ICSP header to breadboard plug?

 

 

 

Get yourself a few 90 degree 6 pin headers and bend them like so with pliers...

 

 

Digikey part number... 609-3343-ND

 

Brad

 

Nice.  If I hadn't already made my own ICSP jig, I'd probably go for yours.  Very clever!

http://nerdralph.blogspot.ca/201...

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

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

Thanks!

The best part... 48 cents for the part, and 15 seconds for the effort.

 

Brad

 

I Like to Build Bikes : http://www.AtomicZombie.com

I Like to Hack Stuff : http://www.LucidScience.com