Maker Pro
Maker Pro

Analog Multiplexer

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
I tried to get analog values of each LDRs throught a multiplexer,but the problem is i couldn't get what i need,it always give me the same value(1023) when i was changed the light intensive,please help me guys,,i will attach the code and protues filre..Thankyou...!
 

Attachments

  • 74HC4067.rar
    21.7 KB · Views: 5

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Please show us a schematic of your circuit and how it is connected to the voltages to be measured.. Hard to guess what you did there - and I do not have proteus to read your data.
 

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
I tried to get analog values of each LDRs throught a multiplexer,but the problem is i couldn't get what i need,it always give me the same value(1023) when i was changed the light intensive,please help me guys,,i will attach the code and protues file.simply what my need is to get read many LDR readings using with less number of pins in arduino uno.Before make the circuit,I draw the schematic diagram in protues 8.Thank you ..
 

Attachments

  • 74HC4067 schematic diagram.PDF
    37.2 KB · Views: 5
  • CODE.pdf
    61.2 KB · Views: 1

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
What is the actual measurement of the voltage at the input of the multiplexer (pins 6, 7, 8 and 9)? These voltages need to be in the range 0 V ... Vcc (Vcc of the arduino).
Are you sure the assignment

#define muxln 0

is correct? The example here uses

int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V

which would be A0 (instead of A3) in your case. (Sorry if that's a not so intelligent question, just judging from similarity, I'm not that particularly familiar with arduino code).
You alsi state in your code:

Serial.print("Values from 4067");

Bit the same reeference as above has a note:

**The default analogRead() resolution for these boards is 10 bits, for compatibility. You need to use analogReadResolution() to change it to 12 bits.
 

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
Actual measurements of 6,7,8,9 pins are in between 0-5v .I think code is ok.
Just ignore the print (values from 4067),what my requirement is to only read LDR values..
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
And what is the output voltage of the multiplexer / input voltage of the arduino?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
The reference also states:
Details and Caveats
The analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output, the pull-up resistor will be set, when switched back to an input.
It may therefore be advisable (not necessarily required) to explicitly set the analog pin of the arduino as input:
Code:
pinMode(muxln, INPUT);
in the setup routine of your code.
 

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
The reference also states:

It may therefore be advisable (not necessarily required) to explicitly set the analog pin of the arduino as input:
Code:
pinMode(muxln, INPUT);
in the setup routine of your code.
Did not see any changes bro
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
There is no output voltage displayed for multiplexer
No wonder the analogread() delivers constant values (although I'd have expected something around 0 for no input voltaeg to the arduino.

Just to make sure: The multiplexer is connected to 5 V power supply? The schematic doesn't show such a connection (but this is often taken as implicit and not drawn).
 

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
No wonder the analogread() delivers constant values (although I'd have expected something around 0 for no input voltaeg to the arduino.

Just to make sure: The multiplexer is connected to 5 V power supply? The schematic doesn't show such a connection (but this is often taken as implicit and not drawn).

There is no power input for mux (in proteus ) but the EN bar pin is actually grounded.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
I'm not asking about proteus, I'm asking about your actual breadboard. Do you have Gnd and Vcc connected to the 74HC4067?

Or is this only a simulation? If so, then what actual values do you use for the LDRs' resistances?
Check that the 74HC4067 is connected to the correct power rails in proteus. This is a feature not shown on the schematic, it uses implicit connection. See this discussion.
Also your arduino seem to be floating, tehre are no connetcions to GND and Vcc either.
 

sasindu1997

Jan 13, 2020
7
Joined
Jan 13, 2020
Messages
7
I'm not asking about proteus, I'm asking about your actual breadboard. Do you have Gnd and Vcc connected to the 74HC4067?

Or is this only a simulation? If so, then what actual values do you use for the LDRs' resistances?
Check that the 74HC4067 is connected to the correct power rails in proteus. This is a feature not shown on the schematic, it uses implicit connection. See this discussion.
Also your arduino seem to be floating, tehre are no connetcions to GND and Vcc either.

This is only a simulation.
LDR resistances Dark 1M
Light level max 500 ohms

I read above discussion also..thankyou for it and i gave 5v and 10v to mux..now the case was changed.In both two voltages,program give 0000 values
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
At 500 Ω for the LDR the output of the LDR/R resistive divider is only 2.5 V (max value, trimmer at max. value). That should show as 2.5 V at the input and at the output of the multiplexer. If not, check the power supply to the mux.
 
Top