System of volts control - Page 1
Forum section: electronics / beginners

author: Lachin012
author_rank: Regular Contributor
timestamp: April 10, 2017, 11:33:18 am
content: Hi friends, help me to understand, I need to make control on arduino system of volts, it is probably possible to make also on other microcontroller when tension becomes 240 volts arduino has to see it and instantly switch-off my device and if tension lower than 170 volts fell in network it has to switch-off my device too. What scheme can be applied, probably there are schemes and a code on arduino, will be very grateful to any council, thanks.

author: Jeroen3
author_rank: Super Contributor
timestamp: April 10, 2017, 11:37:57 am
content: You are explaining the functionality of aVoltage Monitoring Relay. You should not have to make these yourself.There are cheaper variant than Phoenix. But since you've used a translator I'd suggest you search for them in your country.

author: Rerouter
author_rank: Super Contributor
timestamp: April 10, 2017, 11:41:57 am
content: I can tell English isn't your first language, as such i may misinterpret some things.You want your microcontroller to know when the input mains voltage is higher than 240V AC, and switch on an output of some kind, and switch it off if that mains voltage falls beneath 170V AC,How you will want to approach it is with an Optocoupler with a suitable resistor, for the mains side,and an op amp working as a "peak detector" on the arduino side, measuring the peak current through the optocoupler, you then measure that peak with an ADC, and set your thresholds accordingly,

author: Lachin012
author_rank: Regular Contributor
timestamp: April 10, 2017, 11:51:01 am
content: Quote from: Rerouter on April 10, 2017, 11:41:57 amExcuse for my English, Rerouter yes you are right quite so and it is necessary, perhaps you know the good scheme, and it is possible to eat a code which can be finished for mine is more whole,Here approximately so has to be as here.

author: Rerouter
author_rank: Super Contributor
timestamp: April 11, 2017, 08:25:18 am
content: Here would be the basic circuit, 4N25 is an optocoupler, you will need a diode in antiparellel with it, the 330K resistor should be 2W through hole,The optocoupler outputs a current, this currecnt creates a voltage on the 1K resistor, the 2 op amps then switch if the voltage is higher than there set point,The diode, resistor and capacitor on the right act like a filter, it will hold the arduino pin logic high until the next cycle arrives,You can then use those 2 logic outputs however you decide.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 08:41:44 am
content: Quote from: Rerouter on April 11, 2017, 08:25:18 amI don't see how that will work in practise, without having to be readjusted periodically.The CTR of an opto-coupler is hugely variable and will change depending on the temperature and as the optocoupler's LED wears out.A better way to do this would be to use a small mains transformer and a potential divider connected to the ADC of the MCU. It would still need some adjustment, as a small transformer always output a much higher voltage than its rated vale but once it's set up it won't need to be adjusted again.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 08:48:18 am
content: Hi Rerouter thank you for the scheme and what it is necessary to use op amps? tell still please what diodes at you on the scheme and what condensers? and it is possible to use this scheme without arduino?

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 08:50:32 am
content: Hi Hero999, you can show the scheme?

author: Rerouter
author_rank: Super Contributor
timestamp: April 11, 2017, 10:23:37 am
content: Hero, as there was no product lifetime given, i assumed it was a short term hobby project, as such, by keeping the led current to a rather low 1mA and no reverse potential stress, i would imagine it would last a number of months before it drifted enough to be noticibleEqually, based on the implied electrical knowledge of the op, i wanted to keep it as simple as possible,To the op,the op amps are acting as "Comparitors" they compare the voltage out of the optocoupler against your set points and switch if exceeded,the condensors (Capacitors) would be 10uF electrolytic capacitors, likely 16V for a 5V supply,And yes it could function without an arduino, attached is an approach with 3 nand gates

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 01:47:40 pm
content: Quote from: Rerouter on April 11, 2017, 10:23:37 amTry building it.Quote from: Lachin012 on April 11, 2017, 08:50:32 amLike this.R3 & R4 depend on the voltage on the transformer, when the mains is at the maximum voltage. For example: if you get 8V out, when the mains is at 250V and your MCU's ADC range is 0 to 5V:VIN(P-P)= 8*20.5= 11.314The potential divider needs to divide by:11.314/5 = 2.268The ratio for R3 to R4 is 1:1.268Suggested values for R3 & R4 to give a ratio of 1:1.25 which is near enough.R4 = 15kR3 = 12k

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 02:21:12 pm
content: Hi Rerouter thank you, you can tell me what it is precisely necessary to put operational amplifiers? it is possible to learn their name.

author: Ian.M
author_rank: Super Contributor
timestamp: April 11, 2017, 02:31:32 pm
content: Why even have an Arduino in the loop? Unless its providing delays or interlocking with other circuits or providing software adjustable thresholds, you'd be better off with a LM319 dual comparator wired as a window comparator.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 02:35:01 pm
content: Hero999 thank you, your scheme I will check too, it is possible you have a code under your scheme?

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 02:43:33 pm
content: There remains one question, perhaps someone already wrote similar code for arduino or atmega8? Tell me where to start writing code, how should this be?Perhaps there are some other schemes that can work without arduino, I will be glad to any proposal, thank you.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 02:55:01 pm
content: Quote from: Lachin012 on April 11, 2017, 02:35:01 pmNo, because I haven't written any.Fortunately, it should be fairly easy to figure out for your self. The values read from the ADC will be scaled and biased at half the supply voltage. All you need to do is work out the peak to peak voltage by subtracting the lowest value from the highest, over each mains cycle and switch the relay on/off accordingly.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 04:18:35 pm
content: Can I apply LM339?

author: Ian.M
author_rank: Super Contributor
timestamp: April 11, 2017, 05:36:21 pm
content: Sure. SeeNational Semiconductor Application Note 74, Fig.9 for the basic window comparator circuit and place the relay coil (with an anti-parallel diode) in place of the lamp.Then all you need is a DC voltage that follows the average mains voltage reasonably accurately and quickly. There are a number of ways of getting that. The most popular for a standalone professional application would be to directly divide and rectify the mains. However that would lleave the whole circuit live so is unsuitable for a novice experimentor.The next best choice is a small transformer with an adequate voltage rating, but as you want to sense over 240V a typical small transformer wont do it. However you can get twoidenticaltransformers and put their primaries in series and their secondaries in parallel to double the primary voltage rating. 220V to 6V or 9V transformers would be ideal. Feed that into a bridge rectifier - I'd probably use Schottky diodes for lower voltage drop and better linearity, and load the bridge output with a resistor, 220R 1W should do nicely.Next you need a RC filter - you probably want no more than 1% ripple which means it needs a time constant of 4.6/f. The input frequency is 100Hz (50Hz full wave rectified) so RC needs to be 0.046. A 1K resistor feeding a 47uF capacitor will do nicely. If the output voltage is too high, replace the 1K resistor with a potential divider, but either keep the Thevenin equivalant resistance at 1K or scale the capacitor value to maintain the time constant. The resulting voltage can directly feed the window comparator. I wouldn't go above 10K for the filter resistance as you don't want the comparator's load on it to become significant.Obviously you need a seperate regulated supply for the LM339 and relay - if yo try to use the same transformer as the control voltage it will make the relay chatter at the lower end as when it turns on the voltage will drop, causing it to turn off again.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 05:50:20 pm
content: Quote from: Ian.M on April 11, 2017, 05:36:21 pmThat's a good idea but isn't it a bit overkill?Although less accurate, one transformer will probably do, with the reference derived from the voltage regulator powering the circuit. Relay chattering could be avoided by adding some hysteresis (more than the ripple voltage) to the comparator. It would need some adjustment but should be fairly reliable.

author: Ian.M
author_rank: Super Contributor
timestamp: April 11, 2017, 06:09:01 pm
content: IMHO it gets rather complicated to use the same transformer for power and control, and as 1VA transformers are fairly cheap its easier for a novice to spend a little more with a higher probability of success. You yourself proposed a dedicated control voltage transformer in reply #9 - I just pointed out that unless you want to spend a lot of money on a 380V rated control transformer, you'd need two cheap 220V ones in series/parallel to get the voltage rating.Of course if you are willing to draw up a circuit with a single shared transformer for power and control to guide the O.P given that the input voltage range exceeds 170V to 240V (or it would be pointless), and specify critical parts, its a different matter.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 06:21:24 pm
content: Thank you, and nevertheless what to me it is necessary to take the scheme what I could begin work and do the scheme?I of course need the reliable scheme what well would work, I of course wanted to make on arduino, but if it is possible and without arduino that let there will be so, for me a main thing what everything would work.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 07:41:11 pm
content: Quote from: Ian.M on April 11, 2017, 06:09:01 pmWhat he really needs is a voltage measuring transformer but they're expensive. A separate 1VA transformer will do. Two in series is a bit overkill. If it's very underloaded, then it should be fairly linear.I agree that running the circuit off the same transformer can complicate matters, introduce instability and wasn't a good suggestion for a beginner.EDIT:You need lots of hysteresis. Attached is a simulation showing it connected to rectified AC (simulated by V1 & Vripple). The voltage is divided by a factor of eight by R1 & R2. V2 provides the reference which is further divided by R3 to R5 to set the thresholds for the windows comparator. R6 & R7 and R8 & R9 introduce hysteresis.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 08:09:08 pm
content: I will find the transformer for what it is necessary? you just show me what it is necessary to collect the scheme, also one transformer will be enough for me, my loading will be no more 2kW, and all this will switch-off the relay if tension 240v or 170v, it is visible on video what was made by the person if it is so possible to make me arranges it as at him on video.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 08:50:00 pm
content: Quote from: Lachin012 on April 11, 2017, 08:09:08 pmIs there supposed to be someone talking in the background? It's horribly muffled.Have you asked the creator of the video for the schematic?

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 09:06:52 pm
content: Yes I wrote him, there where watched video in You Tube, but he hasn't answered me.

author: Zero999
author_rank: Super Contributor
timestamp: April 11, 2017, 09:22:16 pm
content: The attached schematic will only work, as drawn with the transformer linked below. You could use a different transformer but component value would need to be changed.http://www.farnell.com/datasheets/65263.pdfPart numbers:VB 1,0/2/6VB 1,0/2/12VB 1,0/1/6

author: Lachin012
author_rank: Regular Contributor
timestamp: April 11, 2017, 09:44:50 pm
content: Hero999 thanks how I have understood this scheme as shown in video and will disconnect 240v and 170v?How I have understood on the scheme two V1 V2 transformers are specified? tell still here what, I don't see where will be my loading is connected? on the scheme I see RL tell what is it?

author: SL4P
author_rank: Super Contributor
timestamp: April 11, 2017, 10:01:28 pm
content: OP.Can i ask a couple of questions...?Is this intended as a learning project. A practice / short term 'hobby'?Is it To be turned into a product, or long-life installationIs it an Arduino project, or was that just your first shot in the dark?Also keep in mind you are talking about mains electricity.Whatever you do, it can kill those around you if you take your eye off the intrinsic safety requirements.It's a good study project, but stay safe!

author: Ian.M
author_rank: Super Contributor
timestamp: April 11, 2017, 10:06:00 pm
content: @Hero999,Hmm. that's a fast peak detector, which is good if you need a fast-acting over-voltage cutoff, but not so good for undervoltage as the RC time constant of 0.21 is going to slow it down a bit.My proposal was for an averaging circuit, and with a time constant of 0.047 would be 4 1/2 times faster acting on undervoltage. The response to a minimal excursion past either limit would be in 2 1/2 mains cycles, faster for larger excursions.

author: Zero999
author_rank: Super Contributor
timestamp: April 12, 2017, 08:18:04 am
content: Quote from: Ian.M on April 11, 2017, 10:06:00 pmI would have thought a faster overvoltage than undervoltage cut-off would be desirable. I didn't do any calculations on the peek detector circuit. If it's too slow, C1 can be reduced. Providing the ripple is less than the hysteresis voltage on the window comparator circuit, then it will be stable.Quote from: Lachin012 on April 11, 2017, 09:44:50 pmV1 represents the secondary winding of the transformer. Remember, with the component values suggested, it'll only work with the transformer I linked to previously. To work with a different transformer R1 to R5 will need to change.V2 is a constant 5V regulated supply.RL represents the relay coil.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 12, 2017, 12:02:24 pm
content: SL4PHi, this is not a hobby, it should stay in my device for a long time, since very often the voltage in the network is released then it rises, this is my first such project is volt control, I would like to of course do this on arduino, but so far it does not work out, I I do not know where to start writing my code for arduino.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 12, 2017, 12:05:45 pm
content: Hero999 Thank you for the explanation, but I can not understand what you showed me the diagram, is it what I need? If it's 240v it will cut off the network voltages? And if it's 170v too it will turn off?Hero999, did I correctly identify the numbers of the LM393 legs? How can I replace the 2N7002?

author: Zero999
author_rank: Super Contributor
timestamp: April 12, 2017, 05:09:26 pm
content: The pin numbers look correct to me, from memory. If you're unsure, the pinout for the LM393 is on the datasheet, which can be found using a search engine.The 2N7002 can be replaced with the 2N7000 or BS138.

author: Lachin012
author_rank: Regular Contributor
timestamp: April 12, 2017, 05:22:38 pm
content: Hero999 thank you very much you very well explained everything, but now I want to understand, this circuit disconnects only by high voltage? Or does it work like high voltage and low voltage?

author: Zero999
author_rank: Super Contributor
timestamp: April 12, 2017, 05:32:57 pm
content: Quote from: Lachin012 on April 12, 2017, 05:22:38 pmI'm not going to answer either of those questions. It's something you need to work out for yourself.Please concentrate on understanding the schematic. Do some research into potential dividers and window comparators.You can simulate my schematic in LTSPICE (a free download) if you download the .asc file I attached to the post linked below.https://www.eevblog.com/forum/beginners/system-of-volts-control/msg1183854/#msg1183854

author: Lachin012
author_rank: Regular Contributor
timestamp: April 12, 2017, 05:41:34 pm
content: Hero999 thanks, sorry, I just did not see your file, now I realized, thanks again, now I'll compile the scheme and check how everything works, after how everything is checked I'll write the result here.