Timer

Yes, the line:
pot_idx=(unsigned char)(analog8(4)*36/255);
is where you are selecting which analog input pin to check.

‘analog8(4)’ returns the analog voltage connected to ADC4 (which is PC4, pin 27 on the dip package). To check the trim pot on the Orangutan, which is connected to ADC7, I would change that command to read ‘analog8(7)’.

-Adam.

Hi Adam, I have sorted the adc problem cheers for help.

The circuit is complete now and i have started moving it to a copper perf board. The wiring is CRAZY, and i am a bit worried there is going to be a short somewhere…

Quick question thyough. to program the mega168, the vs1002 breakout board must be off, otherwise i get huge errors, any ideas why?

have you go any ideas how i can program the mega168 in a pemanent circuit with the vs1002???

Glad to hear it’s going so well.

Your programmer uses the SPI hardware interface, the MISO, MOSI, and SCK pins (PP3, PB4, PB5), which is also what reads the SD card and how the mp3 chip and the AVR communicate. It’s not fully shown in your schematic, but I assume you have those pins wired both to the SD socket, the mp3 chip, and a programming header?

You might be able to program the board with everything hooked up by simply removing the SD card, or you may need to have a way to physically disconnect the mp3 chip and SD socket (a super-easy solution, if it works). Can you program the AVR if you connect it’s SCK pin (PB5) only to the programmer, but leave everything else the same? If so you can put a jumper in your soldered board to cut this connection when you want to program the chip. A third option would be to have a removable power jumper for power to the SD card socket and mp3 chip. Actually now I’m worried that programming with the SD card in is a bad idea anyway, since it could do unexpected things to the data on it.

Another option, once you have your software how you like it, you shouldn’t be making frequent updates, right? Instead of soldering your ATMega168 to the perf board you could buy a DIL IC press-in socket for it, like part 22-0175 from Rapid. This way when you want to change the software you’ll actually be able to pull the AVR off of your board, put it back in your breadboard and program it there by itself. If you wanted to get really fancy, you could get a ZIF socket, like part 22-1565 from Rapid, and wire up a permanent programming board. ZIF stands for “zero insertion force”, which you don’t have to press it in, just drop it in and turn the lever.

In any case, it’s very easy to damage a chip by soldering directly to it’s pins, so in any case I would recommend buying the DIL socket, soldering that to your board, and just pressing the AVR in.

Good luck with your crazy wiring!

-Adam

Thats quite a scary post you just wrote - i wish i had asked you all that before i began, because i have already soldered the mega168 to the board… i dont think its going to work…

Do you know anyone (company or whoever) who would make a real board and populate it with components for me - possibly in smd but dip is fine, because my abilites are not good enough for me to be wasting components like i am.

I could possibly make the cad drawing that they could work from… In that snake like robot you made, did you do that in smd? did you do the soldering for that, or did a machine?

EDIT: As i thought apparent short circuit on mosi line - programming mode failed…

The only feeling of hope i have is i had the same error on th breadboard a few times, and somehow - without knowing what i did, it fixed itself - i think a capacitor wasnt in properly though then, but now everthing is soldered down, and there are a jumble of wires on the back. I have looked around for a short but cant see anything…needle in haystack…

the vs1002 and the sd board have no vcc connected, the only thing though is that the ground of the vs1002 breakout board IS connnected and I wonder whether that is a problem, whenever i was reprogramming on the breadboard i always unplugged the groung of the vs1002 breakout board aswell as the vcc???

To see what a mess of wires looks like, and if you want to be embarrased by THE worsed electronics ever, look at the pictures here:

ksd-design.co.uk/photos/photos.html

I know of a couple of companies in the US who will make and even populate boards, and give you free software to work out your design, but it gets quite expensive very quickly, especially if you just want one. For example, my lab just placed an order for some reasonably complex boards yesterday, which were about $70 per board at the bare minimum quantity of six boards. If we wanted a few hundred copies we could have paid just a couple of bucks per board, economies of scale and all.

I don’t think all is lost on your board though, you may just need to pull out some wires, then build the system back up as you verify bits are working. The AVR chips are pretty hardy, so I would assume for now that this one survived until you prove otherwise. Actually I think your board looks pretty good, especially for your first attempt (you should see the first board I ever tried to solder, and that was a kit!). Welcome to the wonderful world of solder-rework!

On most hobbyist’s soldering tables right next to the iron you’ll find some de-soldering tools. You can reheat the solder on your board and pull out wires, and stick new ones into the hot solder. To remove two-lead components like resistors you can alternate heating the ends for about a second each until they’re both free. For many-leaded components, or just to clear solder out of holes, you can get a spring-loaded solder sucker. Cheap ones are plastic, and you can hold them to the hole on one side of the board while heating with your iron on the other side. Personally, I like the metal, self-heating ones, but they’re a little more expensive.

Also, the overly-specific error messages you see when the programmer is having trouble (i.e. X is shorted to Y, programming failed) are almost never the actual problem. If your multi-meter has a continuity-testing mode (it beeps when the test probes touch connected wires) you can check if you actually have a short. Disconnecting just power to the mp3 chip (and pulling out the SD card) should do it, but it’s possible that the mp3 chip could draw just enough power from the signal lines to keep screwing things up. As usual, it’s a case of try and see!

-Adam

Cheers Adam, I dont think i have broken the chip because the program I(we) have been making has a function that if the mp3 decoder isnt attached an led flashes - which it is!

I am annoyed with myself - i left my multimeter on and the battery is inside - no easy access.

i will hold off on having a board made then.

straining my eyes to see, there seems to be no short, and as a board it all seems working, i have placed a jumper so the mp3 decoder and sd card can be unplugged, but cant test the program as a whole because changed it just before adding it to the board like an idiot so dont know if the program works anyway!

suppose getting my multimeter working is my first step, i had hoped if i went to bed and wake up tomorrow i would work but that is thinking like a lottery player - which i’m not.

I’ll just keep fiddling about then see what happens, the avr studio help said something about pulldown resistors - what are they. it says something about if the resistance is too high then can get error messages???

Pull-down or pull-up resistors are used to ‘pull’ a pin to a high or low voltage (respectively) most of the time, while allowing that pin to be pulled the other way without a short circuit. For example, the reset pin on your ATMega168 has a 10Kohm pull-up resistor, so normally it’s sitting at +5V, which allows your program to run. To switch the AVR to programming mode, the programmer pulls the reset pin down to 0V. If you didn’t have a resistor there, and just connected the reset pin to +5V the programmer would be short-circuiting power to ground and bad things would happen. The resistor limits the current that can flow from power to ground, and lets the programmer safely pull the reset pin low.

Aside from that I don’t see any pull-up or pull-down pins connected to the AVR in your schematic. This is just AVR Studio guessing at why the programming pins are acting weird.

-Adam

If pin 1 is my reset pin, then there is a resistor there, but I;m sure that has always been there…

Yes, and it should be there (actually it needs to be there for the microcontroller to work at all). The AVR Studio error message just meant that resistors connected to the other programming pins can cause problems. You don’t have resistors connected to the other pins, but you do have other devices (the mp3 chip and the SD card) that are interfering.

-Adam

I have my continuity meter working, but everything seems to give a reading! so i have taken a scren driver, and i am going to touch both leads to the shaft, the continuity selection on the multimeter is like a diode, a triangle, on a wire withe a perpendicular vertical line at the tip of the triangle. the screen reads just a 1. OK so this is what happens when i touch the leads to the shaft of the scredriver:

the screen reads -523, then flicks through a few lower numbers before displaying 000.

i have two pads on the board, one is where all my gnd leads go and one is where my vcc leads go. if i touch the multimeter between them i get 429 on the screen and it stays there and doesnt go away unlike the screw driver.

the correlation seems to be that lines that definately touch, ends of a wire or a screw driver the numbers appear then disappear.
Lines that I dont think should have any connection, gnd and vcc for instance, the numbers stay. what does that mean.

i’m not sure how to diagnose a problem with such strange outcomes…

each side of a resistor gives me a constinuos number,

the connections that will go to a programmer:

programmer pin 1: continuois number - goes to mega8 pin 18
programmer pin 2: number appears then disappears - goes to ground
programmer pin 3: number appears then disappears - goes to mega8 pin 19
programmer pin 4: number appears then disappears - goes to mega8 pin 17
programmer pin 5: number appears then disappears - goes to mega8 pin 1
programmer pin 6: number appears then disappears - goes to vcc

infact if i touch pin 1 to any other pin i get numbers jumping all over the place!!! i’m at a loss…

The continuity checking mode on many multimeters also lets you check the polarity of diodes, and in general the equivalent resistance between any two points in a circuit. It’s not unusual for you to see the numbers jump around when you check any two parts of your circuit, since they are all connected in through the various devices. When you see 000 resistance (and hear a tone if your multimeter has a built in buzzer) that means the two points you are touching are directly connected, and if these points shouldn’t be connected you have a short circuit somewhere.

-Adam

so i am actually looking for 000 not numbers?!

if i am getting numbers continuosly between two points that shouldnt be conected then thats a good thing?, and if those numbers settle to 000 then they are connected?

and what if i get 1, does that mean the resistance is sooo high its off the scale, like when you set voltmeter too low? Is there a tolerance i should be weary of, i.e is 68 too close to a connection?

PS Have you seen my thread “mapper”?

Right, 000 means there is no measurable resistance between the two points, and thus that they are shorted together, and 1 with no other digits means immeasurably high, or not connected at all as far as you’re concerned. 68 probably means 68 ohms of resistance between two points ,which is by no means a direct connection, but could certainly cause problems. For example, a 68 ohm resistor between one the programming pins and ground would certainly keep you from being able to program the AVR.

-Adam

P.S. I did just spot your mapper post, I hope Ben’s answer makes sense.

68ohm was between pins 3 and 4 of the 6 pin programmer cable if you know what i mean, still sound like a problem?

That sounds a little unusual. It could be a very minor short, like with a microscopic whisker of solder. Or it could be the mp3 chip, or the SD card. It could also be that your multimeter continuity tester reads out in some unit other than Ohms. Did it come with a manual? I have two, and one seems to be reading out in ohms, but the other is reading out some other numbers that don’t make a whole lot of sense.

-Adam

I had a look at the manual. They call it a diode test (the picture on the multimeter is a diode). Itdisplays the approx voltage drop and the value is in millivolts and a reversed connection will show just a 1. so what does 60millivolts suggest to you? To me it now sounds like a higher number is a good connection
rapidonline.com/netalogue/specs/85-0662.pdf
I have run a surgical knife between all the connections to cut any small lines of solder but still getting that 68 …

When the programmer actually is doing the programming, does it use some of the 6 pins that it isnt when it is in standby, because if i plug everything in, the light on the programmer is green - pretty happy. The momen i press program, it flashes read and i get that flamming error, once i press ok it goes back to green, so maybe i can work out from that which lines are noticing the short, might help me - i’m clutching at straws here!

When one of the AVRISP programmers sees a voltage between the VCC and GND pins it checks the reset pin pull-up resistance. So long as that resistor is there, and is above (but still in the ballpark of) 4.7Kohm, the green light goes on. This tells you that your problem has something to do with the MISO, MOSI, and SCI communication lines.

I can’t seem to load rapidonline.com right now, but I’ll take your word for it. Both of my multimeters have separate diode check and continuity modes. A 60mv voltage drop between pins 3 and 4 (SCK and MOSI) doesn’t sound right, but it could be just the odd floating behavior of the powered-off mp3 chip. The real test would be to de-solder the wires connecting the mp3 chip to the programming pins and seeing if you still have problems. After that I would double check that the connections from your AVR to the programming header are correct, then just keep pulling wires off (except for power, the programming header, and the reset pull-up resistor) until you are able to talk to the AVR with the programmer.

There should be 0 voltage drop between two points on a circuit connected with just bare wire (or a short) and a very high voltage drop (probably showing just 1) between things that should not be connected, like the programming data pins.

-Adam

The trouble is with my design is that if two completely seperate things are going to ground or whatever, and one is close to the ground that the other, I’ll connet them together to save on wire everywhere (you can probably see this in the picture). If everything worked then it would be OK but the moment there is a problem, finding it is impossible. I have gone for a new approach. I have bought a desolderer, and a dil socket that clips the mega168 in - no pressing down. I am going to remove the mega168 and program it in a breadboard, then place it back in the dil socket - i will then be able to program it. Now i just have to hope that wherever this short is, it doesnt affect the actual circuit, and more just the programming of the microcontroller!

one of those late night errors with no voltage regulator, what would 9volt dc do to a microcontroller for about 10 mins?

Ouch! There’s only one way to find out. I I’ve been impressed by PIC and AVR resistance to high voltage before, but 9 minutes is a long time. Just be glad you didn’t hook up power backwards, that’s a real killer!

-Adam