Arduino Forum

Using Arduino => General Electronics => Topic started by: Joes on May 05, 2016, 08:37 pm

Title: Voltage Detector
Post by: Joes on May 05, 2016, 08:37 pm
hi there

 i have made this as shown on this site:
http://hackaweek.com/hacks/?p=380 (http://hackaweek.com/hacks/?p=380)

all works fine but i would like to reverse the operation of the LED
when voltage is detected LED is low

What would be a good way of doing this?

Thanks Joe
Title: Re: Voltage Detector
Post by: raschemmel on May 05, 2016, 08:54 pm
Quote
What would be a good way of doing this?
 
Add a transistor inverter (https://www.google.com/search?q=transistor+inverter&rlz=1C1GPCK_enUS504US504&tbm=isch&imgil=4hK9UNK6R2jLkM%253A%253BOPoCyKlmjskcnM%253Bhttp%25253A%25252F%25252Fwww.electronics-tutorials.ws%25252Flogic%25252Flogic_4.html&source=iu&pf=m&fir=4hK9UNK6R2jLkM%253A%252COPoCyKlmjskcnM%252C_&usg=__VCwE4kNULityYt_BF5Fk4YaTp1E%3D&biw=851&bih=694&ved=0ahUKEwjZw9jazcPMAhVX8WMKHSNrCvEQyjcIKA&ei=o5YrV5nmNdfijwOj1qmIDw#imgrc=4hK9UNK6R2jLkM%3A) on the input ?
Title: Re: Voltage Detector
Post by: Grumpy_Mike on May 05, 2016, 10:30 pm
Or wire the last transistor with the resistor between the collector and the supply ( just like the other two ) and then wire the LED between the collector and the emitter.
Title: Re: Voltage Detector
Post by: raschemmel on May 05, 2016, 10:35 pm
Quote
and then wire the LED between the collector and the emitter.  
?

Are you sure you  meant to say that ?
Title: Re: Voltage Detector
Post by: Grumpy_Mike on May 05, 2016, 10:39 pm
Well anode to collector and cathode to the emitter, that is what I meant.
Title: Re: Voltage Detector
Post by: Joes on May 05, 2016, 10:51 pm
right ok, should i be fine using the same 220R or should i go for something more like 2K?
Title: Re: Voltage Detector
Post by: Grumpy_Mike on May 05, 2016, 11:09 pm
Quote
should i be fine using the same 220R
Yes.
Title: Re: Voltage Detector
Post by: dlloyd on May 06, 2016, 02:36 pm
You may need to add a "test" pushbutton (or power switch) to prevent the constant current draw when not being used.
Title: Re: Voltage Detector
Post by: Joes on May 06, 2016, 08:31 pm
the LED does not go out, it duels a bit but that is it, i did increase the 220R but made no difference?
Title: Re: Voltage Detector
Post by: Grumpy_Mike on May 07, 2016, 12:51 pm
Then put a normal diode in seriese with the LED.
Title: Re: Voltage Detector
Post by: MarkT on May 07, 2016, 02:28 pm
the LED does not go out, it duels a bit but that is it, i did increase the 220R but made no difference?

the LED does not go out, it duels a bit but that is it, i did increase the 220R but made no difference?

This circuit detects mains AC (detects in the radio sense, rectifies and amplifies), so that the current
through the 220R load is pulsed, which the size and length of the pulses increasing as the copper
strip picks up more stray field.  This means that most of the time the output transistor is off, so
that simply complementing the output won't work well.

You would need to low-pass filter the output voltage, then use a comparator to threshold the signal,
then drive an LED to get the inverted sense (light only when little input, no light when strong input).

[ Its probably possible to add low pass filtering earlier on in the circuit by adding a capacitor to
one of the transistor bases, that might help ]
Title: Re: Voltage Detector
Post by: Joes on May 08, 2016, 10:34 pm
Quote
Then put a normal diode in seriese with the LED.
Seemed to make no difference :smiley-confuse:


there must be a way you can do this with keeping a low component count?

thanks Joe
Title: Re: Voltage Detector
Post by: MarkT on May 09, 2016, 01:38 am
Tried the capacitor yet?  This is a very high gain circuit (gain around 10 million), so it picks up mains
interference from any nearby object, which means it is pulsing - you need dc to be able to invert
the sense of the LED.
Title: Re: Voltage Detector
Post by: dlloyd on May 09, 2016, 03:12 am
I think the output could be inverted like this, but that would mean constant drain on the battery when no electric field is near the copper strip ... so a "test" switch might be needed.

Also note that its much more difficult to perceive impulse activity on an LED that is normally ON than an LED that is normally OFF. Using a capacitor as MarkT has suggested could resolve this.

(http://i.imgur.com/NEZDwCW.png)
Title: Re: Voltage Detector
Post by: runaway_pancake on May 09, 2016, 03:28 am
Please confirm, for the record,
you did this...

(http://i270.photobucket.com/albums/jj118/new_clear_days/stuntpics/theotherway_zpsswyrwoy8.jpg)

and "no joy", right?

BTW, with 9V, I'd go with >= 470ohms, not 220. [He used a rechargeable batt., "7V"]
Title: Re: Voltage Detector
Post by: raschemmel on May 09, 2016, 06:15 pm
Please confirm what happens when you short the copper strip to your circuit GND.
Title: Re: Voltage Detector
Post by: Joes on May 09, 2016, 10:54 pm
right my circuit looks like this:

(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/theotherway_zpswnettdlq.jpg)


i did try your theory (dlloyd) but led just stayed on.

The 220R i have increased it but it did not seem to help.

i have been using a voltage from 7 to 24v from a power supply.

shorting the copper strip to the circuit GND made no difference but if i short it to vcc (through a resistor) the LED go's out.


This is what i am seeing over the LED when voltage is present:

(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/IMG_2191_zpsm90mpewq.jpg)

so are we looking at a capacitor now?
Title: Re: Voltage Detector
Post by: dlloyd on May 09, 2016, 11:02 pm
Quote
so are we looking at a capacitor now?
I would try 100µF across the LED ... this will give a time constant of 22ms.
Title: Re: Voltage Detector
Post by: raschemmel on May 09, 2016, 11:09 pm
Quote
shorting the copper strip to the circuit GND made no difference but if i short it to vcc (through a resistor) the LED go's out.
According to the schematic, shorting the strip to Vcc should blow out the base of the first transistor because there is no base resistor.
Title: Re: Voltage Detector
Post by: raschemmel on May 09, 2016, 11:15 pm
Quote
This is what i am seeing over the LED when voltage is present:
   
You must be in Europe. That's 50 Hz.

The led is always going to be dim when driven by a 50 Hz signal.

Is there any waveform with nothing touching the copper strip ?
Title: Re: Voltage Detector
Post by: Joes on May 10, 2016, 07:34 pm
nothing touching the copper strip:

(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/IMG_2194_zpsvtarkidk.jpg)


with a 100UF over the LED:

(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/IMG_2195_zpsmqfcim8n.jpg)


yes 50Hz here 
Title: Re: Voltage Detector
Post by: dlloyd on May 10, 2016, 08:41 pm
The capacitor should make the LED stay OFF longer when a signal is detected at the copper strip.

(http://i.imgur.com/s2a2vBv.png)

(http://i.imgur.com/7QAmYRe.png)
Title: Re: Voltage Detector
Post by: Joes on May 10, 2016, 09:14 pm
but as you can see in post 20 pic two, after adding a cap the led is now on more than before :smiley-confuse:
Title: Re: Voltage Detector
Post by: raschemmel on May 10, 2016, 09:30 pm
What is the point of this project ?
WHAT EXACTLY do you need this for ?
Title: Re: Voltage Detector
Post by: Joes on May 11, 2016, 08:51 pm
Quote
What is the point of this project ?
WHAT EXACTLY do you need this for ?
i am making a relay card with a trip led on it to let you no that the power source has been lost, so i am switching 230v supply but there is no neutral local to the relay card. so thought this would be a good route to go but maybe not.
Title: Re: Voltage Detector
Post by: raschemmel on May 11, 2016, 09:40 pm
Can you use one of these (https://www.sparkfun.com/products/11005) ?
Title: Re: Voltage Detector
Post by: Joes on May 12, 2016, 08:09 pm
would like to keep it all on the PCB and is a lot more money 
Title: Re: Voltage Detector
Post by: CrossRoads on May 12, 2016, 09:08 pm
The relay card has 9V battery, you want it to turn on an LED when 230V that the relay contacts are switching is lost?
How about something like this?
AC from relay comes in, divide it down and rectify/filter it to a reasonable DC level, drive the base of a P-channel MOSFET.
When AC is present, MOSFET is off.
When AC is lost, Gate is pulled low, turning the MOSFET on and lighting the LED.

If not, please clarify your requirement further.

(https://forum.arduino.cc/index.php?action=dlattach;topic=398848.0;attach=166769)
Title: Re: Voltage Detector
Post by: raschemmel on May 12, 2016, 09:40 pm
Why not replace led with optocoupler ?
Title: Re: Voltage Detector
Post by: Joes on May 12, 2016, 10:38 pm
(CrossRoads) thanks for your input that looks spot on :) few question:
1 The two first resistor (the divider) what resistances would you recommend? i have had a play with a volt divider calculator but was getting random numbers.
2 i have be using those diodes so do you think they would be adequate? Diode (http://uk.rs-online.com/web/p/rectifier-schottky-diodes/7877548/?searchTerm=787-7548&relevancy-data=636F3D3126696E3D4931384E525353746F636B4E756D6265724D504E266C753D656E266D6D3D6D61746368616C6C26706D3D5E5C647B337D5B5C732D2F255C2E2C5D5C647B332C347D2426706F3D313426736E3D592673743D52535F53544F434B5F4E554D4245522677633D4E4F4E45267573743D3738372D37353438267374613D3738373735343826)
3 100UF for the capacitor?
4 Resistor next to the cap 10K?
5 do you think this is an adequate Mosfet? Mosfet (http://uk.rs-online.com/web/p/mosfet-transistors/8222649/)


Thanks Again


Title: Re: Voltage Detector
Post by: Joes on May 12, 2016, 10:44 pm
And one more question, if i was using this on multiple relays all switching different phase but with a common 9v would this cause an issue?

Thanks Joe
Title: Re: Voltage Detector
Post by: raschemmel on May 12, 2016, 11:05 pm
Quote
would this cause an issue?
 
issue with what ?
what kind of issue ?

I still think replacing the led with an opto-coupler would allow you to put everything under software control instead of requiring a human to view a led.
Title: Re: Voltage Detector
Post by: Joes on May 13, 2016, 09:22 pm
Quote
issue with what ?
what kind of issue ?
The GND will be linking phases together, but obviously through four resistors, could that cause any issue?

 
Quote
I still think replacing the led with an opto-coupler would allow you to put everything under software control instead of requiring a human to view a led.
what software? the end is just an LED.

and how would you make an opto work as there is no neutral?
Title: Re: Voltage Detector
Post by: raschemmel on May 13, 2016, 09:30 pm
An  opto is nothing but a  led driving a phito transistor through an isolation barrier. Tbe output has a pullup resistor and sends a high or low to arduino.
Title: Re: Voltage Detector
Post by: Joes on May 13, 2016, 09:37 pm
so how would you wire it?

again there is no arduino in this project
Title: Re: Voltage Detector
Post by: CrossRoads on May 13, 2016, 09:51 pm
"Tbe output has a pullup resistor and sends a high or low to arduino."
More likely Needs a pullup resistor.
(http://forum.arduino.cc/index.php?action=dlattach;topic=398848.0;attach=166925)
Title: Re: Voltage Detector
Post by: Joes on May 13, 2016, 10:01 pm
so correct me if I'm wrong, on the LED side in replacement of the neutral your using the earth?
Title: Re: Voltage Detector
Post by: raschemmel on May 13, 2016, 11:11 pm
Quote
More likely Needs a pullup resistor. 
Yes, I was trying to explain the concept of an opto.


Quote
o correct me if I'm wrong, on the LED side in replacement of the neutral your using the earth?
No. Forget about earth and neutral. What I am about to describe creates an isolated interface from your voltage detector to an arduino input so YOU do NOT need to LOOK at a LED ! The arduino will detect it and the software will deal with it.



Just look at the led you already have. (the one connected across the transistor)
(http://forum.arduino.cc/index.php?action=dlattach;topic=398848.0;attach=166939)

Now remove that. (JUST THE LED, but change the pullup resistor (the one connected to the last transistor) to the correct value for the opto)


Now connect the opto led where your led used to be.
Now connect the emitter of the opto output to the arduino GND
Now connect a 10 k pullup resistor from the collector of the opto output to +5V .
Now connect a wire from the collector of the opto output to an arduino digital input.
You DO NOT NEED TO THINK OR ASK ABOUT THE EARTH OR NEUTRAL.
NOTHING ELSE CHANGES . Everything else in your circuit remains the same. Only the led is gone and the resistor value is changed.
The result , after following the above is an isolated input to the arduino. NO ELECTRICAL CONNECTION TO THE REST OF YOUR CIRCUIT. (unless you are connected to the the arduino GND for some reason).
DO NOT CONNECT 9V BATT GND TO ARDUINO GND !

JUST FOLLOW THE ABOVE INSTRUCTIONS.
Title: Re: Voltage Detector
Post by: Joes on May 14, 2016, 09:54 am
right ok i see where your coming from now thanks for explaining that.
just to say again there is NO Arduino in this project so at the end its just an LED, so correct me if I'm wrong again but the output of the opto will still be the wrong way round and it will be pulsing?

thanks again for you input
Title: Re: Voltage Detector
Post by: raschemmel on May 14, 2016, 10:53 am
Ok, no arduino Hmmmn. How did I miss that ?
I guess I have arduino on the brain  LOL...
Ok your question about the opto suggests you still don't "get it".
Let's PRETEND for a moment there IS an arduino ( at the "end")
GOOGLE "OPTO COUPLER"
An ooto has an INPUT ( the LED) and an OUTPUT ( the photo transistor)
YOUR DETECTOR has a LED (what a coincidence)
If we REPLACE YOUR LED with the opto coupler led and follow my other instructions, what we wind up with at "the end" , is a microprocessor interface for your voltage detector.

The "point" of your detector is to generate a "trip LED" for the relay card. The simplest way would be an ac relay with a 9V battery powered led connected to the N.C. contacts of the relay so when the mains was lost, the relay would deenergize shorting the N.C. contacts , lighting the led.  With no mains , your detector stops pulsing because all of the transistors are off.  If the last transistor iis off , then the led across the collector and emitter of the transistor would be ON because the transistor is not shorting the anode and cathode of the led.

. In that case,  the arduino ( that we're pretending exists) could detect that automatically using the digital signal coming from the collector of the optocoupler where it is pulled up to 5V by the resistor. But , in retrospect, a microprocessor seems overkill for a led. ( LOL)
Title: Re: Voltage Detector
Post by: Joes on May 14, 2016, 05:47 pm
Yer normally it does include an Arduino lol


something like this?

(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/Screen%20Shot%202016-05-14%20at%2016.42.13_zpsay21j70v.png)

Title: Re: Voltage Detector
Post by: raschemmel on May 14, 2016, 06:02 pm
NO NO NO !

You violated the FIRST LAW OF OPTO COUPLERS 1

NEVER CONNECT THE INPUT GND TO THE OUTPUT GND !
Remove the LED from across the opto collector and emitter  and put it in parallel with opto led
Adjust resistor value of resistor connected to last transistor to something that allows enough current through opto led and physical led which have been placed in parallel.
Remove the connection between the opto led cathode and the opto transistor emitter
Remove the connection from the opto transistor pullup resistor and the 9/v battery.
Connect the opto transistor pullup resistor the arduino 5V
Connect the opto transistor emitter to arduino GND.
NOW , you electrical isoslation.
There is NO POINT IN USING AN OPTO ISOLATOR (https://en.wikipedia.org/wiki/Opto-isolator) IF YOU ARE GOING TO JUMPER THE INPUT TO THE OUTPUT . That makes no sense whatsoever because it defeats the WHOLE PURPOSE of an opto ISOLATOR.
By connecting the opto transistor ONLY to the arduino and NOTHING ELSE, the logic signal sent by the opto has NO ELECTRICAL CONNECTION TO THE VOLTAGE DETECTOR because the opto led and the opto transistor are separated by a transparent 5000 V isolation barrier.
If you MUSH have the visual led there , you would NOT put it where you put it because that prevents the opto transistor from sending a logic signal. The led forward voltage would be on the collector of the transistor all the time and you would never get a HIGH (opto led off) or a LOW (opto led ON)

 You would put it in parallel with the opto led and adjust the current limiting resistor according to support both leds.
Title: Re: Voltage Detector
Post by: Joes on May 14, 2016, 06:30 pm
i don't have 5v just the 9v

so the LED is staying in the same place?
Title: Re: Voltage Detector
Post by: raschemmel on May 14, 2016, 06:52 pm
Quote
so the LED is staying in the same place?
I thought you only posted that last schematic to ask if that is what I meant when I thought there was an arduino, but you said there is no arduino so of course there is no purpose for the opto coupler without an arduino. My last reply was an attempt (not sure if I succeeded ) in explaining to you how an opto coupler works but by your last reply it seems like you thought I was suggesting you add an optocoupler even though you don't have an arduino.
Let's try this:
Scenario A : (no arduino) => thus , no opto coupler
Scenario B : You decide to ADD an arduino to detect loss of mains power and send an RF signal somewhere or send an SMS text message or send an message by internet, then my last reply applies as is .
The physical (visable)led stays where it was, and all the instructions in my last post apply.
Title: Re: Voltage Detector
Post by: Joes on May 14, 2016, 07:07 pm
Quote
Scenario A : (no arduino) => thus , no opto coupler
no arduino


Quote
Scenario B : You decide to ADD an arduino to detect loss of mains power and send an RF signal somewhere or send an SMS text message or send an message by internet, then my last reply applies as is .
no just the LED


all i would like to do is light up a LED when i have a lose of power that is it no more lol



going back to the start
this works but the LED works the wrong way round:
(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/Voltage-Detector-Schematic-copy_zps7t39wojb.jpg)



so you lot come up with this to reverse the operation of the LED:
(http://i906.photobucket.com/albums/ac270/Joes-110/Mobile%20Uploads/theotherway_zpswnettdlq.jpg)


but that did not work the LED says on

so need to find a way of solving that or find a better way of doing this
Title: Re: Voltage Detector
Post by: polymorph on May 15, 2016, 05:12 pm
A big problem with this kind of touch switch is that the slightest leakage current in the first transistor is magnified tremendously.