Atmega328P wiring and reset button

Hi,
I 've designed (in eagle) a schematic (click the link to download it since there is no more space in the forum to be uploaded) which is a small robot. It is an Atmega328P connected to some leds,ir emitters and receivers, 8 transistors, 2 motors, a couple of LDRs and resistors. It moves around avoiding walls. I am not sure whether I have connected the atmega328 and the transistors correctly so would it be possible to check the wiring and enlighten me ? Also what transistors should I use to swith the motors on and off and how do I set up the reset button ?

Thank you in advance,
Alex

Schematic: msweb3 - v0.0.1.sch
Password: c6ve!@45f$cs648cs&564acd

Try Additional Options, browse to a file, the upload problem I think has been fixed.
Make the attachment a .png, .jpg, not everyone has eagle to look at files.
File:Export:Image, something like that in the Eagle menu.

You 're right! I checked it out yesterday but I couldn't upload anything :frowning:

Those H-bridges suck!

The "low" side will switch OK, but the 1k resistors on the "high" side will markedly limit the ability of the emitter followers to "pull" high. Even if you delete the resistors, you are losing about 0.7V in the emitter follower and more likely more than 1V when taking into account the ability of the mega chip to pull up close to the supply rail. At 5V, this really is significant, unless it is a 3V motor in the first place.

You could use more transistors, but arguably you really need a purpose-built IC for the job.

the motors are pretty small and I need them to turn slowly so apart from the voltage drop is there any other problem with the H-briges ?

Some problems:

  1. You have SMD '328P selected, was that intended?
  2. You have no 0.1uF decoupling caps on VCC, VCC, and AVCC.
  3. You have no 10K pullup resistor on Reset.
  4. How are you connecting for bootloading/programing and/or serial downloads?

I'd also go with an H-bridge chip or two skip all the transistors.

First of all thank you for your replies!!!

  1. Yes I am trying to make it as small as possible so the smd is the best option (and the only one)
  2. Could you please show me how to connect them ???
  3. I have not even started on the reset button since I don't know how the connections need to made. Is there a schematic which I will replicate ?
  4. I initially thought that I would make an ICSP as in the arduino uno (http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf) but then I realised that the reset was included :0 and I could not continue

Thank you for the suggestion! I will have a look at it!

  1. place a cap near each VCC, VCC, AVCC, pin, close as you can, other side to Gnd.
  2. See the PRO Mini schematic. Resistor from Reset pin to VCC. Can connect on off board button if needed for testing. That's what I do. Use the ICSP header.
    http://arduino.cc/en/Main/ArduinoBoardProMini
  3. Need SCK, MISO, MOSI, +5, Gnd, Reset on ICSP connector. Wire it just like the Uno.

alex_poupakis:
I initially thought that I would make an ICSP as in the arduino uno (http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf) but then I realised that the reset was included :0 and I could not continue

Yes, it is of course one of the six pins. So what? You just run the trace as you do for all the other pins, MISO, MOSI and such. It's not a problem.

Actually, CrossRoads refers to using an external reset button for (software) development but not in the final article. A really neat way to do this is to have it wired to a socket that plugs onto the ISP pins (using only the RST and GND pins).

CrossRoads: I think I did all you said in the right way! But is it ok to use the MISO, MOSI, SCK pins for something other than the headers ? (note this will be a pcb and so the components will be mounted at all times unlike the uno which has sockets and probably no components when it is connected through the ICSP)
In the Mini schematic there is a button! So do you mean something different than that depicted ? (I have made the reset button wiring as an extra option but if there is indeed a better option I will not use it)

Paul__B: To do what you are suggesting, couldn't I only connect the RST and GND headers together for a second (i.e. with a small copper wire) or would this not work ? And will I connect the RESET directly to the ICSP or do wire it as if there was a button there ? (I want to avoid the socket for practical reasons)

You have The spi pins connected to leds, so you will be fine. The only time to worry is when the pins are used as inputs and some other could control the pins when you wanted to for programming.

alex_poupakis:
CrossRoads: I think I did all you said in the right way! But is it ok to use the MISO, MOSI, SCK pins for something other than the headers ?

It is a standard part of the design of the Arduino that the ICSP pins are used by other things - it would be a waste otherwise. The only point in design, is to ensure that what they are used for at a time other than programming, will not restrict the application of the programming signals. If they are used as a output that is heavily loaded, such as a LED with resistor, that might be a problem though the LED only conducts at something over 3V so it is generally possible to assert a logic "high" from the programming adapter. If the pin is used as an input, and the device from which the input is sourced will actively assert a particular level when you are trying to program the chip (and is not simply disconnected when you do so), that can be a problem but generally since the inputs are at such high impedance, it will be possible to have a series resistor (perhaps 10k or more) which allows the ICSP controller to override this.

alex_poupakis:
note this will be a pcb and so the components will be mounted at all times unlike the uno which has sockets and probably no components when it is connected through the ICSP)

For production runs, you do not actually populate the ICSP pads with header pins, but use a jig with "pogo pins" to connect for programming (and testing).

If you design with care, the UNO can be programmed via ICSP with shields mounted or otherwise in circuit.

alex_poupakis:
To do what you are suggesting, couldn't I only connect the RST and GND headers together for a second (i.e. with a small copper wire) or would this not work ? And will I connect the RESET directly to the ICSP or do wire it as if there was a button there ? (I want to avoid the socket for practical reasons)

You can certainly use a jumper, but if you have to do it more than twice you might prefer to have an adaptor with a switch,

If you design with care, the UNO can be programmed via ICSP with shields mounted or otherwise in circuit.

What do you mean the UNO ? Won't my robot be able to be programmed from an UNO via ICSP ?

If they are used as a output that is heavily loaded, such as a LED with resistor, that might be a problem though the LED only conducts at something over 3V so it is generally possible to assert a logic "high" from the programming adapter. If the pin is used as an input, and the device from which the input is sourced will actively assert a particular level when you are trying to program the chip (and is not simply disconnected when you do so), that can be a problem but generally since the inputs are at such high impedance, it will be possible to have a series resistor (perhaps 10k or more) which allows the ICSP controller to override this.

You have The spi pins connected to leds, so you will be fine.

So in my design will the components conflict with the "programming signals" or not? (MOSI + 2 transistors with 2 1K resistors, MISO and SCK + LED with 100 Ohm reistor)

You can certainly use a jumper, but if you have to do it more than twice you might prefer to have an adaptor with a switch,

I 'll go with that because for my project robots will be programming robots (easier to connect the two headers than press a button or plug a socket automatically!).

Also if I want two of these pcbs to exchange data do I not connect RX-TX, TX-RX, GND-GND and use the Serial.write() command ?

Plus is there a more space-efficient way to connect two pcbs vertically other than headers and sockets? (Please do not suggest wires or anything off the board !!!)

Serial - yes.

Stacking vertically - probably not.
Alternately, plug all cards into a motherboard. Requires card edge connectors on all cards.
Think of a desktop PC, but turned sideways so the cards look vertical.