Main Site Documentation

Adc - op amp interface panda ii


#1

The LPC 2387 datasheet, figure 16, shows a “suggested ADC interface” with a max 40 K resistor connected to AD0. I’m currently connecting AD0 input directly to the output of an Op Amp that limits the voltage swing to 0-3.4 volts. The unused ADC inputs are tied to ground.

Two questions:

[ol]Is a resistor on the input of the ADC required or best practice?
The 3.4 max voltage seen by the ADC is above the 3.3 V spec. Can this slight over voltage result in significant problems?[/ol]

I could put in a voltage divider to limit the AD0 input to 3.3 V, but this seems like overkill for a 0.1 volt over voltage on a 5 volt tolerant pin unless that 0.1 V can cause larger errors.


#2

LPC user manual says this:

[quote]while the ADC pins are specified as 5 V tolerant (see Section 8–1), the analog multiplexing
in the ADC block is not. More than VDD(3V3)/VREF/3.3 V (VDDA) should not be applied to any pin
that is selected as an ADC input, or the ADC reading will be incorrect. If for example AD0.0 and
AD0.1 are used as the ADC0 inputs and voltage on AD0.0 = 4.5 V while AD0.1 = 2.5 V, an
excessive voltage on the AD0.0 can cause an incorrect reading of the AD0.1, although the AD0.1
input voltage is within the right range.[/quote]

I don’t know what the error could or would be for 0.1V, in the real world.


#3

I saw that also, but as you note it doesn’t provide much guidance for a real world error for 0.1 volt. It also refers to error on another ADC channel, AD0.1. My guess is that if I’m using only AD0.0 the ADC reading would saturate at 1024, but that is only a guess. Looks like I might have to just try it and see what I get.

Thanks for your response, godefroi.


#4

My experience has been in complete agreement with the LPC 2387 manual and I have at least a half dozen crippled Panda’s that would not be if I was a little more careful with the breadboarding. This comment applies also to the effect of high readings affecting the following readings, even with delays in between.

I would suggest you use the divider and take the minor precision hit.

One other Panda trait that can cause grief is that the pins all initialize HIGH so if you don’t include a dropping resistor and try to read something like a TMP 36 temp sensor, it will damage the sensor.


#5

Randomr, are you saying that the ADC inputs will initialize high? That would puzzle me as I thought they were just inputs.


#6

Yes, exactly that. All of the anolog inputs and the digital inputs initialize HIGH 3.3 v until your program takes effect. In addition to damaging sensitive sensors, It wreaks havoc with devices you are trying to control. If you want to, say, control a motor with a HIGH pulse from a digital pin, when you first power up your board the motor will start until your program takes effect unless you pull it down with and external resistor. I really have no idea why it was designed this way.

An alternative is to use your external power switch to be powered OFF when the the pin is High. This works, but is counter intuitive.


#7

So in my case I have 5 unused ADC inputs tied directly to ground. If those pins go high on startup I would think that might damage the ADC unless I tie to ground through a resistor. That doesn’t appear to be the case, however, as AD0.0 still works and digitizes accurately. Is there some internal protection in the LPC 2387 for a short to ground on these pins?

Thanks for your help.


#8

They don’t initialize high, they initialize as inputs with a weak pullup. There are numerous previous threads on this (many by me), such as this:

http://www.tinyclr.com/forum/2/3742/#/1/msg35313


#9

The pins upon power up are set as inputs with weak pullups(~35k?) I believe.


#10

As I stated earlier, they all initialize high with weak pull ups. An 3 in particular can be configured as in or output. If you tie a tmp 36 temp sensor to directly to an3 the sensor WILL die, guaranteed.

If you have even a cheap Voltmeter stick it on the inputs and read it for yourself. Or listen to whatever advice you choose.

If you tie a switched device to a digital line it will start if it has a high start flag Guaranteed.

I can afford to destroy Pandas. If you can do the same then do as you please.


#11

Thanks for the link, godefroi. I searched the forum before starting this thread, but I didn’t get any hits that seemed relevant. From a quick look at your link it sounds like a direct ground tie on the ADC inputs doesn’t do damage. I’ll search other posts to see if there’s any reference to how to best to “unfloat” unused ADC inputs.


#12

I am curious godefroi. How could you tell an input pulled high at initialization from one intialized high? Very strange.

Do you have a mosfet that can tell the difference? That is something I could use…


#13

No, I was using the pins for digital outputs, so I could merely use an external pulldown that could overcome the internal pullup.

I ended up using a shift register for output anyway, so it was never an issue.


#14

[quote]No, I was using the pins for digital outputs, so I could merely use an external pulldown that could overcome the internal pullup.

I ended up using a shift register for output anyway, so it was never an issue.[/quote]

Yes. Point being, for those who have not already blown Panda inputs or had strange things happen when they power their boards. I seriously doubt that most would include an otherwise wasteful pull down resistor. Why indeed would you add a pull down to combat a pullup…

  1. ALL Analog inputs initialize HIGH.
  2. All Digital pins initialize HIGH.

If your program assumes a motor is OFF until you tell it to go high it will turn on as soon as power is supplied and if your program faults then it will stay ON HIGH until you deal with it.

If you have a sensor attached that cannot tolerate a 3.3v input, it will be DESTROYED.

This is advise from actual use. Not some theoretical might happen. Hopefully to save you some time and money.

Have fun out there.


#15

Just to make sure that I understand all that has been explained in this and previous threads, the analog inputs initialize high through internal pull up resistors. If I want to pull them low, I should do that with an external resistor tied to ground, however, since they are not floating due to the internal pull up, it may not be necessary - right?. As gus said in the earlier thread,

http://www.tinyclr.com/forum/2/3742/#/1/msg35313

I appreciate the cautions about unexpected high pins after reset and will keep that in mind.


#16

The problem is that the external pulldown is FAR from ideal. It creates a useless (at best) voltage divider. It wastes current whenever the pin is high. It’s not really an option, I don’t think, on analog inputs. I don’t know how one would deal with it.

In my case, I would’ve had 16 solenoids pull open 16 water valves, only to have them crash closed all at once seconds later. This would have been disastrous for my setup (as in, damaging to the water lines). I ended up using two shift registers instead of using GPIO directly, but that shouldn’t be strictly necessary.

I can’t find clear documentation for either LPC2387 nor STM32 on what the internal firmware does with pins on startup. Anyone know off the top of their head?

Note that we’re not the only ones with this “issue”. The Netduino people deal with it. It seems to me (and I’ve got practially no experience here) that the “normal” thing that microncontrollers do is set pins to high-Z on reset (input with no pullup/pulldown). This has the effect that they “float” somewhat randomly. It’s more useful in specific settings (where each pin that is being used is being used for a specific use), but makes it more complex to do general prototyping (because you’d need to use external pullups/pulldowns for pretty much every GPIO pin you used). Just my interpretation.

I asked a question some time ago about this very phenomenon on electronics.stackexchange: http://electronics.stackexchange.com/questions/17377/pulldown-resistor-on-mcu-output

With OSS systems like Cerberus and Hydra, one could modify the NETMF to set pins to do whatever they liked on reset. For production systems, it seems to me that the standard high-Z would be best.

We could petition the NETMF team to change this, but I doubt we’d get very far, as it’d be a massively breaking change with previous releases.

The next best strategy seems to be to design your GPIO circuits such that they’re “active low”, meaning, use PNP transistors instead of NPN transistors. I know, that doesn’t help with analog inputs.


#17

I have been using Fez Panda’s in conjunction with one of my licensee’s for about 12 months.

This much I know form testing.

The sd card logging has been flawless. In some instances over 3 months logging.

I use a multiplexer to feed an AD695 thermocouple reader. 8 channels.

I read 8 thermocouples, voltage, current, cfm, tach, airstream, airstream temp through a wind tunnel.

The FEZ panda also controls a dc power supply, and a heat source (1500 watts).

This I know beyond a shadow of a doubt.

The digital and analog pins initialize HIGH regardless of other opinions you may have seen in this thread.

If you approach the highs of any value it affects the next analog read.

Over 3 months continuous reads in a single file.

Very useful device if you can cut through the bull sh?t that some want to publish.


#18

godefroi;

In my opinion, using pull downs is a waste of programming and power. Until FEZ can get these functions to launch powered down a simple solution would be to dedicate one pin to invert the poles on launch and use a program key to set that. I cannot think of a any reason why the original programmers would want them high. One of those mind boggling ‘what the hell were they thinking’ moments.

In other words set a single pin to invert all other pins on reset. Then normal programming high would turn some function on.

One of my current apps checks for correct date/time and whether the sd card is valid. This can take several seconds and if a motor is running that should not be during that time it creates a big problem.
I can deal with it with inverse programming, but once again, “what the hell were they thinking”


#19

randomr:

They’re not initialized as HIGH, they’re initialized as input-with-internal-pullup. It’s a small distinction, but important. As to why it was done this way, I cannot say. It’s not clear to me whether this was/is a decision of the NETMF team, or whether it was/is a decision of the GHI team. I can say with near-positive certainty that if you wanted a Panda that initialized as intput-high-z (floating) or input-with-internal-pulldown, GHI could make it happen for you. It would cost some extra money, but may be worth it in the long run.

It is inconvenient for me as well, but the good news is that with the OSHW offerings of GHI, it can be easily changed.


#20

godefroi;

I fail to see the distinction between initialized high and pulled high. It is like saying you weren’t run over by a tank, it was just a massive tracked vehicle.

The point that I am trying to make is that in their current configuration as they are now sold the pins all initialize at the reg voltage of approx 3.3 v. and will stay there until your program executes and tells them to be something else. If your program fails to reach that point then any external switched devices that are flagged to run on a high pulse WILL be running. This is clearly not understood by all and could lead to a destructive situation if not dealt with in hardware. The same goes for voltage sensitive sensors. If they are expected a high Z neutral input and instead get 3.3 volts they can and will be damaged.