Unexpected Voltage Drop on Atmega328P-AU

Just completed my first PCB, and everything works except for an unexpected voltage drop on one of the GPIO pins. I have PIN 7 (called "Sensor Activate Pin") set as an output pin. It switches HIGH to provide power to a sensor. The sensor only consumes 5 mAh of energy, so it's perfectly suitable to be powered through the GPIO pins. When testing on a breadboard and perf board, everything works fine. However, on the PCB, the GPIO pin that's supposed to be powering the sensor is only providing 0.850v, despite having 5V supplied to VCC. This causes issues because my sensor needs at least 3v.

I'm a little lost as to why this is happening. I would expect that nearly 5V should be coming from the GPIO pin and not 0.850v.

Attached is my schematic and PCB:

Imgur

Imgur

There should be a base resistor on Q1.
When PD7 tries to go to 5v, the base to emitter keeps it LOW ( ≈.7v).
You might have damaged the output pin.

1 Like

Yes, a 10K to 100K resistor between the base and the port pin is required.

1 Like

1: Your sensor doesn't consume 5'mAh', but I will gladly believe that it draws a typical max current of 5mA.
2: If the sensor module has one or more capacitors on it, the peak current draw can be far more than the 5mA you cited and in fact far more than the 20mA limit of an Atmega328 pin. In my experience, the Atmega328 pins are current limited, often preventing damage in such scenarios.
3: IMO it is not a good idea to power anything from a microprocessor pin. They're designed as logic level inputs/outputs, not power supplies. Ok, a single led will be fine if you current limit it to well below the safe limits of the controller because an led does not have any capacitance or inductance (at least not significantly) that will create surge currents and/or voltage spikes.
4: You mention 'supplying 5V to the sensor', but that's not really what you're doing by driving an NPN transistor with pin PD7. You're essentially using the S9013 as a low-level switch, enabling a 10k/10k voltage divider, making the voltage at junction R1-R2-'Battery Voltage' drop from 5V to 2.5V when pin PD7 is set high. I'm not sure what you want to accomplish with that, to be honest. In addition to the missing base current limiting resistor mentioned by the others, of course. Looks like you're using PD7 for a dual purpose which likely makes your problems worse. Yet, you have plenty of pins to spare, so why...?

To be honest, I think there's some fundamental flaws in your approach. I'd scrap this PCB and start over.

1 Like

Often a good idea to breadboard a design, to prove it all works OK, before designing a PCB.

He did; apparently it worked fine then. But in addition to breadboarding, it's also a good idea to thoroughly think about a solution before even attempting to put it into a practice. In this case, a more theoretical review should have triggered alarm bells.

1 Like

Which does suggest something changed between breadboard and PCB.

Yes, likely. But since this seems to be a case where correct functioning might rely on e.g. the contact resistance of a breadboard, a design review is in order.

Yes! That makes sense. I can't believe that I forgot to add that.

Lots of good points. Thanks for the feedback.

Yeah, that is exactly what I want. Enable the voltage divider with PD7 through the transistor. But PD7 to also supply power to the sensor. But I think not having that base resistor is causing the problems. And yeah, using just another spare PIN would probably be easier in the end.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.