Stand Alone Atmega328P-AU Programming Hardware Setup

Hi all :slight_smile:

I am new to stand alone microcontrollers so I hope that someone here can have a good look at my schematic to confirm that the hardware setup is correct (or not).
I need to confirm that I have this part right before ordering the PCBs.

I plan to burn the bootloader before installing it on the PCB but I figure that I should make it accessible through the jumper pins just in case I need to reload the bootloader for whatever reason.

Even though I've setup and all of the components together for testing (before finalizing it on the PCB with mostly SMD devices), I may need to tweak the sketch a little here and there afterwards since the actual values may be slightly different in the SMD PCB version.
One such device of concern is a Kelvin connected current shunt resistor/amp (all in one package). It's the INA250A Bidirectional 15 Amp Current Sense Amplifier in case anyone wonders about that device. The internal shunt resistors are only 2 mOhms (.002 Ω).
In reality, the INA250A is probably more accurate than the microcontroller.

Also, I wonder if I should skip using the FTDI provided 5V VCC and just use the PCB's on-board voltage regulator to supply the voltage to the chip. I realize I still need to connect the grounds together.
Would it be better to use VCC from the FTDI or does it matter? (doesn't seem like it would make any difference to me but I thought I'd ask in case any of any of you have had experience with using an on-board voltage supply source).

Edit: I just realized that I circled A4 and A5 (OLED connections) on the schematic, I didn't think that part through enough! :slight_smile:

I would GREATLY appreciate any feedback and advice you have to offer!!

Have a great day!!

Joe

If you're going to be doing heavy-duty analog stuff, you might want to include the inductor low-pass filter between VCC and AVCC, and pay special attention to the layout around the non-I2C analog pins...

Otherwise, it looks pretty OK. The Serial/ISP connector doesn't seem at all standard - did you want it to be?

Hello and thank you for taking the time to respond. :slight_smile:

I'm not sure if the analog tasks I'll be doing would be considered heavy duty or not.
I have one that measures an incoming signal from a voltage divider, it's for monitoring the voltage on a lipo supply battery and I don't want it to drain below 3.2 volts per cell. That one doesn't have to be very accurate, about 200mV one way or the other is good enough for that input.

I do have one analog input that needs to be as accurate as possible (accurate to within 100mV would be great if that's possible but from what I've seen so far that may be wishful thinking, 50 mV would be awesome). This will be coming from the shunt resistor/amplifier circuit I mentioned above.

I have read about using a low pass filter on the DIP version but I couldn't find any info on it for the SMD 32 pin version.
Do you have any specs on what cap and what inductor to use for that processor?

As for the layout around the non I2C analog pins, I couldn't find any layout examples and I may have missed the text portion, it's a long read! :slight_smile:
Do you have any layout examples or specs for the processor layout?

I plan to complete all of the debugging using a standard Pro Mini before uploading to the stand alone processor but it would be nice to have the serial port active just in case as long as it doesn't take too much hardware. I'm starting to run out of room on the board but I could stretch it out some more if I need to.
I'm using Eagle, it's not the free version so I can make the board any size I need, I would like to keep it the current size so it will still work with an enclosure that I found for it.

I'm not sure what I need to do to make make a serial connection.
I was thinking that it should work as long as I have the header for the FTDI connection but I guess I was wrong? :slight_smile:

Seriously, any advice and help I can get is greatly appreciated!!

I rarely ask for advice, most of the time I dig in and research things to death and it seems that I have gone as far as I can without some professional advice :smiley:
I'm fairly well versed at the hardware side of control systems but I'm fairly new to the controller side.

BTW, I basically copied a diagram that someone else posted but I never could find anything definitive about that diagram.
What caught my attention was that all of the .1uf caps from Vcc makes (3) .1uf caps parallel with each other since both Vcc pins and the AVcc pin go the the same voltage source, and they all use a common GND. I use parallel caps quite a bit for filtering so it's not unusual to me, I'm just wondering, is that the way it's supposed to be in this case?

Thanks again!!

Joe

I have read about using a low pass filter on the DIP version but I couldn't find any info on it for the SMD 32 pin version.
Do you have any specs on what cap and what inductor to use for that processor?

It's not package-specific. See section 24.6.2 Analog Noise Canceling Techniques of the datasheet.

(10uH, 100nF)

As for the layout around the non I2C analog pins, I couldn't find any layout examples and I may have missed the text portion, it's a long read! :slight_smile:

There is all sorts of "common folk wisdom" about minimizing noise in the ADC section of a PCB (mostly WRT noise generated BY the digital section of the same PCB!) I don't really have the expertise or testing experience to give you sure advice, just a caution that it's an area often ignored on Arduino boards. I don't even really know that it matters that much, at the relatively low ADC speeds of the Arduino.
(It gets especially worrisome if you're going to be using I2C, which necessarily dumps some relatively high speed digital functions in the same area of the chip and PCB used by the analog pins.)

I'm not sure what I need to do to make make a serial connection.
I was thinking that it should work as long as I have the header for the FTDI connection but I guess I was wrong? :slight_smile:

No, that's about right. And the circuitry you have is OK (could use a diode on RESET - see the Uno schematic, but it's not THAT important.) But the pinout of your current connector doesn't match the FTDI pinout:

all of the .1uf caps from Vcc makes (3) .1uf caps parallel with each other since both Vcc pins and the AVcc pin go the the same voltage source, and they all use a common GND. I use parallel caps quite a bit for filtering so it's not unusual to me, I'm just wondering, is that the way it's supposed to be in this case?

Each cap should be "near" its respective power pin, so as to provide a low-impedance path to a power source for each section of the chip. (without having to go around the PCB and bond wires to the other side of the chip. You don't want to just put the three caps next to each other between VCC and GND somewhere random on the board. (You can probably find explanations of "bypass capacitors" on the net.)
(here's an example - C1, C5, and C9 are the bypass caps.)

You didn't actually post a picture of what your PCB looks like. That might be a good idea too - there's a lot that can go wrong between a schematic and a PCB.

Your response has given me what I needed so I could point my research in the right direction, I didn't realize that the entire analog section should be isolated until I researched it further (as a direct result of your response and advice!).
Thank you so much for that!!

You are right, the low pass filter is not package specific, as it turns out I simply missed the part concerning the low pass filter and analog ground plane layout, I must have been really tired and it just didn't register in my brain. :slight_smile:
I found that section (page 258 I think) and it makes sense to use the filter as long as I use a proper isolated ground plane around all analog pins, the filter without the dedicated ground plane probably wouldn't help much.
Now it makes more sense about the .1uf caps since one of them is isolated with the analog ground plane.
After I complete the PCB, I plan to run some tests with a scope for noise and accuracy. I ran some tests today on a Pro Mini and it's not very good as far as noise on the analog pins is concerned so hopefully adding the filter and isolating the area around the analog pins should show a reasonable improvement.
If you like, I can post the results here when I get it done (I can take a few photos of my scope and post some numbers to go along with it).

Obviously I will have to redraw that part of the schematic, the ground pin nearest to the AREF pin is connected to the analog ground plane (along with the .1uf cap from AREF to that same ground plane).
That ground plane should not be connected in any way to the chassis or battery ground since it's actually connected internally (inside of the Atmega 328 processor).
I have attached a screen shot showing the suggested low pass filter and analog ground plane along with what I did in my PCB layout, obviously I will have to make some changes!! :slight_smile: The caps are fairly close to the processor now but they should be closer (like in the example you posted), there's no dedicated analog ground plane at all in my PCB layout!!
It's worth making the PCB a few millimeters larger to get a more stable and more accurate analog reading from the shunt resistor/amplifier IC, I can always find a suitable enclosure, in fact I may have one 3D printed (I can easily model one in Fusion 360).

Actually, The reason I ran the traces the way I did was because of my observations of other Arduino Pro Mini boards (both the genuine and clone versions). I have attached another screen shot showing the layout of one of the clones and it's not too far off from what I did to my PCB layout (not much different from the genuine board either).
I can only imagine that the traces under the processor look just as nesty as it does on the bottom of the board!

I have also attached a screen shot of another portion of my PCB that shows how I normally treat various ranking planes.
I've already done some testing at the output of the on-board switching regulator (with my scope) and I wound up adding a 47uf cap to make the output a little smoother, I had to experiment by using different values until the ripple was just under 30mV, too much capacitance isn't a good thing in my experience and I'm sure you are aware of that fact as well.

The 6 amp buck converter was already filtered properly since it's a POL module.
I used a 6 amp buck converter along with a 7 amp photoMOS SSR, I'm running slightly more than 3 amps through them but I like things to run as cool as possible.

I knew that the header pins for bootloader and programming weren't in a specific order and I did that because I usually use single Dupont connectors rather than a solid 6 pin connector, I use ribbon cables most of the time but the order didn't seem to be that important to me, having said that, it probably would be better to put them in order while keeping in mind that the FTDI Tx pin goes to the board's RX pin (same thing for the Rx pin), I've heard of people connecting those backwards and then have a hard time figuring out why their board won't program.

I can't tell you enough how much I appreciate your help!!!
PLEASE feel free to let me know if you think I've missed something or if you think I'm still not getting this right!!

Respectfully,

Joe

Here is the other attachment: I ran out of allowed upload space per post.

Here's the new layout with the added low pass filter.

Through some additional research I discovered that the analog ground plane does need to be tied back to the source ground (preferably at the battery terminal). I kept wondering if the internal ground would be good enough and it turns out that it's best to run a straight trace back to the source ground as long as it doesn't choke off any other ground paths.
Since the software won't allow separated polygons and traces with the same name (which defeats the purpose), I just ran it through a "0" Ohm resistor at the battery terminal, that's a fairly common way to do it, maybe there's a better way but I don't know what it is yet.

Like I mentioned before, this is my first time dealing with the controller end of circuits so this is new territory for me. Most of my work has all been hardware with switches and sensors without the need for microcontrollers, I guess it's time I try to catch up with current technology (the best I can anyway).

Fortunately I managed to rearrange everything and add the low pass filter without enlarging the board.

Let me know what you think please, kind sir? :slight_smile:

Thank you!!

Joe

You should try to fit the AVCC bypass cap over by the AVCC pin (next to the AREF cap, and over he same ground plane.,,

I should keep mentioning that when I design PCBs, I use a lot of advice and "folklure" from the net, and when they actually work, I'm all "cool! It must have been good advice!" But I've never turned a board into an actual product, nor done the sort of extensive testing that would prove that the boards are working "well." And I've never done anything where the the analog circuitry was critical.

westfw, I'm puzzled by your picture of the FTDI connector. There's no DTR. I thought they all had DTR, but have never seen one with RTS. Maybe just my limited experience.

I took your advice and placed the low pass filter cap along with the inductor over the analog ground plane. Not sure why I didn't do that the last time I rearranged things? Duh!!
I'm hoping that placing the inductor over the analog ground plane is a good thing. I do believe it's a good idea to keep the cap and inductor as close to each other as possible.

Fortunately I have the equipment and the know how to do some extensive testing on this board when it's done so this should prove to be a good learning experience for me.

I have never had any of my designs go into production either and probably never will but many of my designs that use sensors, limit switches and user operated switches (some with PLCs that I was able to program myself).
Most of those were used on industrial machines that I designed and built over the years. I am more of a mechanical engineer than I am an electronics engineer, most of my knowledge in electronics is based on research, trial and error, no formal training or degree!

Again, Thank You so Much!!

Joe