Hi to all and Happy New Year with Health
I am not sure if the title is right but couldn't think anything else
So i need to measure the state of 3 switches that are connected in series and are powered from a 110v Ac from a transformer
i thought that the easiest way to do was to rectifier the Ac to DC and then with a simple voltage divider drop the voltage to under 5v to measure it with my microcondroller
(i placed the values only to first voltage divider but are the same values and the other 2)
i placed also a Zener diode of 5v for extra protection to my microcontrellers pins
My problem with that setup :
if the first switch is NO (Normally Open) then i read zero with analog read to all 3 analog pins .
If now close (NC) the first switch and the 2 other continue to be NO then i am getting high values for my first analog pin but also getting lower values to the other 2 analog pins .
if i NC and the second switch then i am getting at the first and second analog pins the same high value but the third one that is NO i still getting the lower values
i used an if statement in my code to filter the lower values to display them as 0 and so i can use it.
But would like to know why i am getting the lower values and if i could add some other component or make it with different arrange so when i the first Switch is NC then the two others be at 0 or almost to 0
As i am using a lgt8f328p chip with 12Bit ADC my Analog read values when the switch is NC are fluctuating : from 2900 to 3800
the Values that i am getting to the pins when are NO fluctuating : from 1200 to 2400
( 12-Bit ADC max value = 4096 , 10-Bit ADC max value = 1024 )
your schematic doesnt indicate anything else is connected to those switches - so why not use dc 5V?
I cant see that on your schematic.
the peak value of 110V rms is about 160V. Your divider drops that to 160*2.5/60 = 6.8V
So you may well be exceeding the input voltage for the analog pins.
a 5V zener diode will not provide that protection.
I'd suggest
1: you only need half wave rectification
2: you need to change the divider chain
3: you could use digital inputs
4: maybe opto-isolators?
the switches / transformer are part from an existing old control panel and my schematic is an attempt to sneak a peek from a distance the state of the switches
Ok will make a new one with that approach
Ok
My first goal was to use digital inputs but as i was getting so fluctuating readings was not possible to have stable readings ( fluctuating also from 0 to 1 )
do you know any dip package opt-couplers suitable for what i need to do?
i am familiar with the sharp PC817 that i am using a lot to my circuits but is for dc small voltages
Id agree ….A good simple way is to power relays from the switches or transformers in the panel and use the contacts as inputs .
You then have complete isolation from the panel to your Arduino .
You can get DIN mounting relays .
If you unsure of working with such electrics it’s simple for a sparkie to install the relays and bring out wires from the contacts .
Remove the 10k resistors.
Connect the opto transistor (and cap) between pin and ground.
Use the internal pull up of the ProMini pinMode(pin, INPUT_PULLUP);
The pin is now 'normally high', and low with power on the opto.
Leo..
It's not obvious. We don't know your skill level. Read here for a while and find out what you will see. The correction is not just for you - it's for all the people who read the diagram here.