ADC6 pin logic state - ATmega 328p TQFP

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

Hello guys, I've been facing a weird problem with ADC6 pin, as it should be only an input for the ADC.

It happens that it seems in my case this pin is "internally tied" to ground and I was believing it was high impedance one. I intend to use this pin just to read the RDSon resistance of an N channel MOSFET, so this  pin is tied to MOSFET drain. The load that I have between 30V and MOSFET drain was always ON regardless the mosfet was on or off. I dig a lot to found the issue and found it was leading to GND, thus the load always on. Then I decided to simply cut the PCB line (ADC6) and now my mosfet circuit works prety well as intended.

 

Is there a way to surpass this problem by software?

 

P.S. On datasheet I can't see nothing about this pin (including also ADC7)...

 

Regards

This topic has a solution.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If indeed you have a '328P, then indeed ADC6 is only an ADC input and is not tied to ground.

 

I'd suggest you look at the rest of the circuit for some other connection.

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

I will check my board to see if I have a short circuit or something else.

 

So, theusch, can you confirm me this PIN is in high-impedance state and there is no possible way to have a defined voltage (e.g. 0V or 2.26V)?

 

Regards

 

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

Yes it is high-impedance--if indeed you have a '328.

 

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

Hi guys, here is the circuit I'm in trouble with ADC6. I already checked for shorts and I don't have them on the board.

I'm using Rsense to measure current accross load, that is, Im in fact trying to measure voltage on a small resistor.

Again, when I connect the board even without configuring  the ADC mux to choose ADC6 as input channel, the result is always the same, my load is on.

When I cut the wire that goes to ADC6, the mosfet works pretty well as intended.

By looking at this circuit do you see anything wrong?

 

 

Regards

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

The load that I have between 30V and MOSFET drain was always ON regardless the mosfet was on or off.

 

It would be nice to see the schematic.

 

If you accidentally applying a significant overvoltage to the pin may have damaged it.

 

JC

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you accidentally applying a significant overvoltage to the pin may have damaged it.

Now, I'm not a sparky, but when the MOSFET is off, the AVR pin sees 30V, right?

 

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.

Last Edited: Mon. Jun 8, 2015 - 06:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are right theusch...problem found!! How innocent...

 

Any design idea to perform the same measurement without this overvoltage problem on ADC6 pin?

 

TY very much.

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

The simplest is to just add a series resistor that will limit any pin current to 1mA when the MOSFET is off. You won't get a valid ADC reading. when the MOSFET is off, of course.

 

Note that the required 25K to 27K is larger than the recommended maximum source resistance of 10K. This may result temperature dependent offset (drop) across the added series current limiting resistor.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Now, as I said I'm not a sparky.  What if you put the signal tap on the Gnd side of the MOSFET? 

 

After all, what is the on resistance of the MOSFET?  Perhaps 0.1 ohm? ;) 

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.

Last Edited: Mon. Jun 8, 2015 - 09:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That would actually work, provided that the voltage across the current sense is small compared to the gate voltage. Say 100mV max for logic drive. Since there is no (static) gate current, all of the drain current also flows through the source. Its a nice solution and one I forgot about.

 

Jim

 

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Tue. Jun 9, 2015 - 05:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good morning,

 

@theusch, the PCBs are already made and to put the signal tap on GND side I would have to add another resistor between GDN and source that now is impossible. The RdsON is ~0.1ohm.

Next time I redesign the PCB I will put Rsesnse on source-GND side of mosfet to avoid this issue. My circuit wil never switch more than 1A so Usense=1A x 0.1ohm = 0.1V maximum.

In fact the impact on Vgs will be very low and mosfet will work pretty well.

I will try to measure current in a more suitable place of PCB for now. My circuit is a boost converter.

 

@jim, a serial resistor on ADC6 line is more feasible on actual situation.

 

Thanks guys for your help.

 

 

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

...impossible... Next time I redesign the PCB ...

Wow--all of your board designers and layout people and parts selectors are generally flawless?!?

 

You have no soldering iron and jumper wire to connect the cut track to the other MOSFET pin.

 

What is the Rdson?  Aren't typical values like 20mohm?  If you keep your connection where it is, won't the Rdson impact your readings?  Won't the curve of Rdson affect your readings?

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

This is a personal project with a personal design I've done for myself but with professional PCB (solder mask and silk screen), that's why it is difficult to "cut and solder"...of course not impossible but hardwork. I can not move Rsense from mosfet drain to source...and there is no point in putting ADC6 tap on mosfet source since I will measure always 0V. 

The RdsON is the ON resistance of mosfet and is ~ 0.1ohm. The don't need to much precision on the readings, just need to have an approximate value.

Here is the board schematic:

 

 

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

Simple, lift source leg of mosfet from grn pad.

remove R105, stand on end between mosfet S leg and gnd pad

solder jumper across R105 pads

cut blue trace running to left pad of R105.

Add jumper from feedthru near atmega to S leg of mosfet and relocated R105.

 

Enjoy!

 

 

Jim 

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

The series resistor (in the the ADC input line)  is  protective, at best. It is protecting against a poor design and is intended to keep things from blowing up. 

 

Shifting that current sense resistor to the other side of the FET will not change how your power switching works. The series resistance (FET and current sense) is identical in both cases. With a maximum of 100mV across the current sense, it won't change the gate drive (significantly) unless the MCU Vcc is unusually low. 100mV out of, say, 3.3V should change VERY little.

 

You WILL need to be careful about I*R drops in traces that carry the load current. Been there, done that. The best thing to do would be to connect the microcontroller's "ground" to a single point which is the ground end of the current sense resistor. That is, collect all of the MCU ground connections together (ground net), and run it  as a single trace to that end of the resistor. Bypass, well, of course, AT the MCU (between Vcc and ground net), not between Vcc and some ground plane that has load current flowing through it.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Simple, ...

But OP said:

...impossible... Next time I redesign the PCB ...

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

Learning how to do micro-surgery is a great skill to have.

 

It will let you tweak and experiment, before committing to another PCB.

 

Besides, you've got a dead PCB on your hands, so you have nothing to lose.

 

A vice to firmly hold the PCB is desirable.

Wear a Headband magnifier, or use a jeweler's loupe, to see better.

Use a SHARP razor blade type knife to cut traces, (often just a slice through the trace is fine).

Practice tack soldering a small jumper wire onto the trace, and to wherever.

 

If you are lucky, and the ADC6 pin is the only dead I.O pin, you can re-route the signal to another ADC input pin.

A few minutes at the bench and you will back up and running to continue debugging your project.

 

Don't forget to change the ADC code to use the new pin.

 

JC 

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

Hi, TY for showing me that there is nothing impossible! Yes I will cut and solder R105, transfering it from mosfet drain to source.

I should have no problem driving the gate since I'm using 5V on microcontroller and mosfet is logic level, so at 5 volts the channel is almost all open, and little 0.1V drop will not affect it.

 

When I designed my PCB I already left 2 extra ADC inputs as you can see on jumper JP3, so if I would make a mistake (and I did it!!) I could correct it right after :)

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

I my earlier years it was not uncommon to have a fix or two on the pcb - even from the large computer manufacturers. 

You'll need to put some low pass filtering on the adc input methinks and some bypass caps closer to the processor.