GPIO inputs without pullup (HiZ) problem

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
g-knight
Posts: 11
Joined: 09 Oct 2016 19:06

GPIO inputs without pullup (HiZ) problem

Post by g-knight »

Hi,

I need to use Hi impedance digital inputs. I connected the input pin through a resistor divider using 100 K / 150 K. My input before the divider varies from 0 to 4.9 V. So output is expected to be between 0 & 2.95 V.

I used the following code:

Code: Select all

#define PIR_PIN     9
pinMode(PIR_PIN, INPUT);
pirState = digitalRead(PIR_PIN);
Unfortunately, this always report logical one value.
I measured with a multi-meter, and noticed that voltage on Z-Uno pin doesn't follow the divider output and seems to be constrained as if an internal pull-up were still enabled despite the "INPUT" used, and NOT "INPUT_PULLUP".

I also tried with an analog input pin 6 / ADC3, but it's the same.

A work around I found is using the analog way:

Code: Select all

int val = analogRead(A3);
if (val > 500)
  pirState = HIGH;
else
  pirState = LOW;
Is there a bug in the pinMode library?

Gerard
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: GPIO inputs without pullup (HiZ) problem

Post by A.Harrenberg »

Hi,

if you disconnect the divider from the Z-Uno and measure again, is the voltage 0 and 2.95V as expected?
The 100/150 kOhm seems also a little high, you might want to try lower values, but that depends also on the what source is connected to the divider.

Andreas.
fhem.de - ZWave development support
g-knight
Posts: 11
Joined: 09 Oct 2016 19:06

Re: GPIO inputs without pullup (HiZ) problem

Post by g-knight »

Hi,

Yes, if I disconnect the divider, I have around 0 and 2.95V as expected.

I don't think 100/150 K is so much, given the documentation:
"Pins configured as INPUT make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 MΩ in front of the pin. This makes them useful for reading a sensor."
I'm wondering if there isn't a bug in the low level firmware that manages the GPIO in the SOC.
But, it's strange that it's not been discovered before... So, did I do something wrong?

Gerard
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: GPIO inputs without pullup (HiZ) problem

Post by PoltoS »

The chip need some current to detect the voltage. Usually it is about 10 μA as stated here: http://z-uno.z-wave.me/technical/

10 μA at 3 V gives 300 kΩ - this is the limit for Z-Uno to detect correctly input voltage. 100-150 kΩ should still be ok.

Please chekc other pins too (not 9-16). May be there is a problem with 9-16 (they are a bit different from others)
g-knight
Posts: 11
Joined: 09 Oct 2016 19:06

Re: GPIO inputs without pullup (HiZ) problem

Post by g-knight »

Hi,

I tried with pin 22 and it doesn't work better. Looks the same...

After having programmed

Code: Select all

#define PIR_PIN     22
pinMode(PIR_PIN, INPUT);
I measured voltage with the pin left unconnected. I got about 3V (so, not floating), and if connect it to ground with ampere meter, it draws 64 µA. More than 6 times from what is written at http://z-uno.z-wave.me/technical/ and far from the 100 MΩ found in doc (https://z-uno.z-wave.me/Reference/INPUT/).

Sure the PULLUP is de-activated?

Gerard
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: GPIO inputs without pullup (HiZ) problem

Post by PoltoS »

Can you try with 47 kΩ? We took these data from the doc of the chip, have not measured it in more details.
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: GPIO inputs without pullup (HiZ) problem

Post by PoltoS »

are you sure your sensor have low output resistance? If it is an MCU (like PIR sensor), it's output R is about 100k itself. In that case use a dividor with arms 2k/1k. Looks like there is not enough current for Z-Uno to detect it.
g-knight
Posts: 11
Joined: 09 Oct 2016 19:06

Re: GPIO inputs without pullup (HiZ) problem

Post by g-knight »

No I can't use lower resistances, I really need high impedance.
For the PIR, I don't use something based on a microcontroller, it's a standard flood projector with discrete components, and I don't want to disturb its internal logic.

I'm pretty sure that's the pull-up is still enabled in the chip when using the "INPUT" parameter. Can't you check that point?

As I noticed the same behavior with ADCx inputs, I guess that sooner or later there will be troubles with measuring analog value having high impedance output.

Thank you.
Gerard
g-knight
Posts: 11
Joined: 09 Oct 2016 19:06

Re: GPIO inputs without pullup (HiZ) problem

Post by g-knight »

Hi PoltoS,

Is there any chance that someone in the Z-Uno project team at Z-Wave.Me has a look into this topic?

The value I measured shows an internal impedance of approximately 50 K Ohms, which is typical from microcontrollers' internal pull-up nowadays.

To solve this problem, I changed my circuit and added an op amp in front of the Z-Uno (a LM 324), but in my opinion it's a waste since if the pull up could be removed, the chipset is most probably having MOS inputs with high impedance.
I tried to find datasheet for Mitsumi WML-C85 or Sigma Designs ZM5101 (which the Mitsumi WML-C85 seems to be a second source), but without success. It seems that this part is closed source (I mean manufacturers aren't willing to share information).

Thanks
Gerard
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: GPIO inputs without pullup (HiZ) problem

Post by p0lyg0n1 »

Hi, Gerard. I try it and will post results here. The normal value of pull-up have to be about 20 KOhms.
Post Reply