Go Down

Topic: 4051 and unused pins (Read 1 time) previous topic - next topic

Pandadoudou

Hello,

I'm using a 4051 to mux the only analog pin on a Wemos D1 Mini to read various sensors.

I've hooked up the 4051 Gnd pins directly to Gnd, the control pins to some digital pins and all the 4051 select pins to either an analog sensor or nothing (circuit open). Vcc is connected to the Wemos 3.3 powered by 3 1.2v AAA batteries.

Each minute I read from only 2 of the 4051 inputs (and then go into deep sleep) :
Battery level by connecting the muxed pin to Gnd with a 100K resistor : OK
Ldr sensor with it's resistor : ok-ish

The other pins are open but not parsed in code.

My issue is the ldr output has not the same result as if directly connected to an analog pin. The results are a little bit to high.
I map the output 0-1023 to 0-100% as float.
The mapped result Delta is higher as the value is higher.
Ie: 22%-23%, 85%-100%, (direct analog vs muxed)

Do I need to connect the unused terminals to Gnd even if their not used/called?
Do I need a capacitor somewhere?

I'll provide a fritz diagram this evening if required.
Thank you.

Boris

Grumpy_Mike

#1
Nov 16, 2019, 08:58 am Last Edit: Nov 16, 2019, 09:00 am by Grumpy_Mike
Quote
Do I need to connect the unused terminals to Gnd even if their not used/called?
Yes.

Quote
Do I need a capacitor somewhere
Yes a 0.1uF ceramic one between power and ground of the chip. As close to the pins as you can get it. All external chips need this.

Wawa

#2
Nov 16, 2019, 09:52 am Last Edit: Nov 16, 2019, 09:54 am by Wawa
Ldr sensor with it's resistor : ok-ish
Problem is that the WeMos D1 mini has an absolute/voltage A/D, and is not really suitable to measure ratiometric sensors like an LDR. Fluctuating battery power is going to make this (instability) worse.
What are you measuring.
Leo..

PaulRB

#3
Nov 16, 2019, 11:35 am Last Edit: Nov 16, 2019, 11:48 am by PaulRB
Quote
Vcc is connected to the Wemos 3.3 powered by 3 1.2v AAA batteries.
That's a confusing thing to say. Are the batteries connected to the 3V3 pin or the 5V pin on the Wemos ?

I think the best way would be to connect the batteries to the 5V pin. The Wemos' regulator would then provide a stable 3.3V, until the battery voltage drops to around 3.5V. Even below that, the Wemos will continue to operate for some time. But during that time the ldr reading will be affected.

You could use a third input on the multiplexor to measure VCC. Then you can compensate for any voltage at VCC, in effect making your sensor ratiometric in software.

Quote
I'll provide a fritz diagram this evening if required.
Fritz diagram not required. Schematic diagram is required. You can use Fritzing to make a schematic: just switch to the schematic view and make that look neat & tidy.

Pandadoudou

#4
Nov 21, 2019, 05:46 pm Last Edit: Nov 21, 2019, 05:48 pm by Pandadoudou
Hello,

Sorry for the delay and thanks for your inputs.

I hooked up 3 1.2V NiMh batteries to the 3.3v pin of the Wemos.
I read this method is wasting less energy than using the 5V pin (while allowing to use the batteries to a lower voltage too)

On my first prototype, I had no 4051 so I plugged the LDR directly to the analog pin and using the same powering method.

About the diagrams, I tried the schematics view but I have a hard time making it readable. The cables seems connected whenever they cross (no bridge)

You'll find attached the fritzing file, sorry. (just remove the .txt extension)

Thanks again.

Boris

PaulRB

Quote
You'll find attached the fritzing file, sorry. (just remove the .txt extension)
Sorry, can't do that on my phone.

Pandadoudou

Ok I managed to cleanup the schematics view.
Black is GND
Red is 3.3v
Green is the data
Purple is the A0 data

Thank you

Paul__B


Always a good idea to have the sensor - the LDR - going to ground and the pull-up - you have chosen 100k but in this case for a pull-up you should probably use more like 22k - to your 3.3 V supply.

If you want to read your battery voltage, you will want to connect your second 100k to your battery, not ground.

You do not really need to connect the other multiplexer inputs to ground for two reasons.  One is that you will not be switching the multiplexer to those inputs anyway.  The other is that the voltage divider in the WeMOS is already pulling the analog input to ground.

The risk in connecting three 1.2 V NiMH batteries to the 3.3 V pin is that when charged they will provide not 3.6 V but 4.2 V and exceed the ESP8266 rating.

The risk in connecting three 1.2 V NiMH batteries to the Vin pin is that the regulator will sag when the input is 3.6 V.

Grumpy_Mike

Quote
You do not really need to connect the other multiplexer inputs to ground for two reasons.
I have found that you do need to connect unused inputs to ground with some makes of multiplexers. This is because of the interference picked up with the floating inputs can cause these pins to oscillate and the cross talk between channels will bleed into the channels you are using. Look up the cross talk figure on the data sheet of the manufacturer you are using. Those can be different and can be inadequate when leaving an input floating.

To be on the safe side I always ground unused multiplexer pins.

PaulRB

IO1 on the mux seems to be connected to ground through R3. Should there also be a resistor to pull it up to 3V3 or 5V?

Pandadoudou

#10
Nov 23, 2019, 11:39 am Last Edit: Nov 23, 2019, 11:50 am by Pandadoudou


The battery mesurment was indeed an error whild retranscripting it in schematics.
I fixed it in attachment.

I don't have much experience with battery powered devices, but I was expecting that using 3x1.2V batteries would give me 3.6V.
I mesured 4.2V with my voltmeter but still tried to power the wemos (since I had a few laying around)

How to limit the voltage to a max of 3.6V ? Something like a Zener diode ? (my electonics knowledge fades a little bit on this side)

The main point of my understanding is that using a 4051 VS not using one is not giving me the same readouts, when powered by the same power source.

I may have to setup another protoboard with the 2 in parallel to ensure the captor is not badly behaving.

Regarding the 4051 this may be this one.

EDIT : Hum, I only saw this :


Thanks again.

PaulRB

Quote
an error whild retranscripting it in schematics.
That shouldn't have happened. Fritzing checks that your schematic view and you breadboard view are consistent and highlights any connections that don't match between the two diagrams.

Pandadoudou

That shouldn't have happened. Fritzing checks that your schematic view and you breadboard view are consistent and highlights any connections that don't match between the two diagrams.
No I mean I misconnected it to GND instead of VCC by memory :)

Pandadoudou

Any new idea ?
I managed to find the value is 20% higher than the other prototype.

I updated the method to query the multiplexed to switch pin, wait, then get the value.
It seems to reduce any noise versus switching the pin and polling directly.

I tried to add a 0.1uF capacitor as close as the 4051 between the VCC and GND pin without success.
I tried to add a 4.7uF capacitor between the 3.3V and GND pin without success.

For now I'm only applying a correcting factor of 20% on my data but this is not ideal.

I'll have to buy soon some potentiometer to validate the readouts manually.


Go Up