Can someone help me review this schematic? - Page 1
Forum section: electronics / projects

author: redgear
author_rank: Frequent Contributor
timestamp: July 05, 2020, 08:52:26 am
content: I am a beginner and I have got few questions with the first project I am attempting. I am trying to build a reliable timer circuit with three timing options. The use case is very similar to a microwave oven i.e., the circuit should check if the doors are closed, three timing options that can be selected with the buttons, start, stop and pause options for the timer.I first thought of using a 556 timer(restricting to only two timing options) with a relay. But I also needed a display(lcd displays, not 7 segment leds) and it was not possible to interface a display with the 556 timer.Another option was to go with a microcontroller like arduino which is easy to work with but I'm sure about the reliability. And they also cost more.I was searching online and found this circuit for a microwave oven controller. I'm thinking to modify this to my needs than trying to build it from scratch. I have few questions:1) I am not able to find AT89C52, what else can I replace it with? Will any 8-bit 8051 do fine?2) I just need to control one relay and 5 input switches. Can I just leave the other ones floating?3) This circuit is designed to work with high power components while my total power usage will be around 80W, do I need to re-calculate for the resistors and capacitors?4) Do I need a resistor in series with the C5 10u cap?ThanksEDIT: Forgot to add the image

author: moffy
author_rank: Super Contributor
timestamp: July 05, 2020, 01:28:22 pm
content: In your position I would be tempted to use an Arduino Nano or Uno board. Plenty of shields (what they call add on boards) LCD, relay etc. and plenty of examples as well as a simple free development and programming environment. Forget the schematic you have it will only confuse issues. The forums are very active as well.

author: StillTrying
author_rank: Super Contributor
timestamp: July 05, 2020, 01:58:39 pm
content: "I just need to control one relay and 5 input switches."Plus 6 MCU outputs for sending characters to the LCD ?If that's all you need your circuit would be much simpler than that one.

author: WattsThat
author_rank: Frequent Contributor
timestamp: July 05, 2020, 06:47:03 pm
content: QuoteDid you mean to say “not sure about the reliability”? And then define the cost. They cost more than what? Various Arduino AVR based clones can purchased for less than $5 with zero effort and they are just as reliable as any other mass produced electronic device. In most circumstances, I’d say far more reliable than a one off strip board cobbled together prototype, especially so for one built by someone inexperienced.You also have to consider programming the microprocessor. You don’t just buy an 8051 based part and go to town, what compiler? How to you get the code into the part? The edit-compile-upload cycle has a time cost and don’t overlook it. If this is your first rodeo, stick with Arduino platform, it will greatly improve you chances of success. It’s difficult to give further advice until until we know what your experience level is, both from a hardware and software point of view.

author: janoc
author_rank: Super Contributor
timestamp: July 05, 2020, 09:04:38 pm
content: Quote from: redgear on July 05, 2020, 08:52:26 amNo, depending on version it may not have any ROM, it may be old EPROM type, it may have only 4k flash instead of 8k, it could be one time programmable ...Try AT89S52 instead of 89C52, that version is still commonly available and can be programmed in-system (unlike the 'C' series which needs an external programmer that you insert the chip into).But for a new project I would rather use an AVR (= Arduino) than 8051 series, it is *much* easier to program for.

author: phil from seattle
author_rank: Super Contributor
timestamp: July 05, 2020, 09:39:43 pm
content: Unless you are familiar with the 8051 and have the programming hardware, I agree with the Arduino suggestion. It is much easy to get going and doesn't need anything more than USB cable to program it. The Nano is perfect for what you want.Second, I'd skip the 16x2 LCD and opt for something a little more modern unless you are going for a retro look - ILI9341 based LCDs are pretty cheap and easy to use. You get color and, if you want, font support to make a much nicer looking display. Tons of code available for it.As to the relay - you will need to properly size it for application. I would derate the mfr's specs (especially current) by 50%. There are a lot of garbage relays out there.

author: redgear
author_rank: Frequent Contributor
timestamp: July 07, 2020, 08:09:38 am
content: Quote from: moffy on July 05, 2020, 01:28:22 pmQuote from: StillTrying on July 05, 2020, 01:58:39 pmQuote from: WattsThat on July 05, 2020, 06:47:03 pmQuote from: janoc on July 05, 2020, 09:04:38 pmQuote from: phil from seattle on July 05, 2020, 09:39:43 pmThank You for everyone that replied. I am considering a arduino at this point. But still, I will have to work on the rest of the circuit, stepping down the mains to 5v, hooking up tactile switches to the arduino and detecting key press, I will quickly design it and post it here for review.I am rn only confused about making the start button work only when the door is closed. Like, if its pressed with the door open, the timer should not start.Thank you all again.

author: redgear
author_rank: Frequent Contributor
timestamp: July 07, 2020, 08:48:53 am
content: All my components, except for the microcontroller will use direct mains voltage. I am planning to run the mains voltage with a fuse and filter caps directly to the components.For the microcontroller I have two options, stepping down the main voltage and using voltage regulator like 7805 or using a CC-CV Flyback Controller like UCC28740. Ti has a nice reference design that I can use. Which one would you guys recommend?

author: moffy
author_rank: Super Contributor
timestamp: July 07, 2020, 10:10:34 am
content: I wouldn't use mains except when essential for safety purposes, you want to make the board as safe as possible to work on. You can use say 12v relays which can be switched by a transistor and the arduino to control any voltage including mains. Your switches will need to interface with the arduino, so just use the same supply as the arduino. Makes everything much safer for working on.

author: redgear
author_rank: Frequent Contributor
timestamp: July 07, 2020, 10:26:36 am
content: Quote from: moffy on July 07, 2020, 10:10:34 amThanks,I would have to use the mains. The Arduino and switches run 5v(stepped down and regulated from mains) and the components would be connected to the mains with a fuse and a relay that is controlled by the Arduino. What do you think?

author: moffy
author_rank: Super Contributor
timestamp: July 07, 2020, 10:54:12 am
content: See if you can sketch out your idea on a piece of paper and then upload a photo. You only need to use rectangles for such things as the arduino. Don't worry about it being rough or incomplete, it is a starting point which can be built upon.

author: redgear
author_rank: Frequent Contributor
timestamp: July 07, 2020, 02:27:33 pm
content: Here is a simple block diagram of what I have in mind. Looking forward for your suggestions.

author: moffy
author_rank: Super Contributor
timestamp: July 07, 2020, 03:18:21 pm
content: Yes, that looks pretty good, and nicely drawn. You will need some sort of supply to drive the relay coil, you can use the 5v regulated, but 5v relay coils tend to draw a bit of corrent. What I tend to do is provide an unregulated 12v supply (what your transformer, bridge rectifier and caps provide). The transformer can have a 9v or 10v RMS secondary, when rectified and filtered will produce around 12v dc (with large enough caps). That can also be used to power your 5v regulator. Also 12v relays are plentiful because of cars. To drive the relay coils use a suitable transistor, and a flyback diode across the coil to reduce spikes.

author: redgear
author_rank: Frequent Contributor
timestamp: July 07, 2020, 03:27:23 pm
content: Quote from: moffy on July 07, 2020, 03:18:21 pmThanks! I will make the changes and post a schematic.

author: mariush
author_rank: Super Contributor
timestamp: July 07, 2020, 04:24:10 pm
content: a small 5-15 VA 12v transformer + bridge rectifier + smoothing cap or a small 12v dc power supply.A 7805 / LM317 / whatever linear regulator to produce 5v for the microcontroller and the LCD display.ULN2003A (darlington transistor array) or something similar to turn the relays on and off (you can connect the microcontroller directly to this, instead of having resistor and npn transistor for each relay ... you have 7 transistor+resistor pairs inside a dip chip)Some diodes for each relay (for voltage spike protection when relays turns off)momentary buttons with resistor on each one to limit current, put all buttons on a port and maybe set interrupt on change ... when a button is pressed an interrupt is triggered and you have your value. (or just constantly poll the buttons which would be useful for debouncing purposes)For extra fun, you may want to experiment with capacitive touch like you see on lots of devices .. see for examplehttps://www.digikey.com/product-detail/en/microchip-technology/CAP1206-1-SL/CAP1206-1-SL-ND/5886099whole category here:https://www.digikey.com/products/en/integrated-circuits-ics/interface-sensor-capacitive-touch/560/page/2?k=capacitive%20touch&quantity=50&stock=1&ColumnSort=1000011&pkeyword=capacitive%20touchFor example

author: moffy
author_rank: Super Contributor
timestamp: July 08, 2020, 01:28:34 am
content: Here is a rough schemaric of what I was talking about:

author: redgear
author_rank: Frequent Contributor
timestamp: July 08, 2020, 01:44:52 pm
content: Quote from: mariush on July 07, 2020, 04:24:10 pmThank you for suggesting this, looks great!QuoteWow, This is cool. Btw, connecting all buttons on single port won't work for me. Cos, i'm planning to include both reset and pause.Quote from: moffy on July 08, 2020, 01:28:34 amThanks a lot for the circuit:)I m planning 0.1uF caps for C1 and C2 and a cap 470uF cap C0 before C1. And instead of transistors for relays, as mariush suggested I'm going for ULN2003A. For the voltage reg I haveUA78M.Let me know what you guys think.Thanks again

author: moffy
author_rank: Super Contributor
timestamp: July 09, 2020, 01:06:12 am
content: The cap C1, (C0+C1) has to be large enough that at full load i.e. max current out of 5v and all relays on, that the voltage never drops below about 8v. This is so the relays stay on, and the regulator doesn't drop out of regulation. There is a simple formula: C1 = (i*dt)/(Vmax - 8v). For 240v/50Hz, dt = 10ms.The use of the ULN2003a is an excellent idea, just stay within the packages total current and power limitations. The built in diodes make life a bit easier also.

author: mariush
author_rank: Super Contributor
timestamp: July 09, 2020, 04:43:24 am
content: Probably a simpler formula to use to approximate capacitance : C = Current (Amps) / [ 2 x AC Frequency x ( Vdc peak - Vdc min) ]So if you have a 9v AC transformer, after rectification it will be 9 x 1.414 - 2 x voltage drop on diode of bridge rectifier = 12.7- 2 x 0.8v = 11.1v peak dc voltage ... but can be higher if you use low voltage drop diodes like let's say 1n5818 (~ 0.3v at 0.1A, 0.5v at 1A) instead of a bridge rectifier.Let's say you need 25mA for each relay, and you have 4 relays ... that's 100mA ... your micro and lcd will use another 10-20mA ... let's round it up to 125mA and let's say you're in a 60Hz mains countrySo if you want at least 10v all the time : C = 0.125 / [ 2 x 60 x (11v - 10v) ] = 0.125 / 120 = 0.00104166 Farads or 1041 uF ... so I'd use at least 1200uF 16v rated capacitor.It would make sense to use a 12v AC transformer ... after rectification and drop of around 1.6...2v (if you use a generic cheap bridge rectifier) you'll have a peak voltage of around 15v.Most relays should be perfectly fine with this high voltage, but if you're paranoid you can simply add a couple diodes in series to drop voltage by some amount (ex 1n400x diodes will drop 0.7v per diode) and get it closer to 12v ...What you add in cost for diodes, you potentially save in using smaller capacitor ... C = 0.125 / 120 x (15v - 10v) = 125 / 600 = ~ 208uF

author: moffy
author_rank: Super Contributor
timestamp: July 09, 2020, 06:32:10 am
content: Quote from: mariush on July 09, 2020, 04:43:24 amNice formula. I would only say that the voltage regulation on small transformers can easily be +20%. So a no or light load your on 12v RMS can easily become 18-19v. Needs to be kept in mind, for both 5v regulator dissipation and possibly excessive voltage across the relays. Depends on a few things to do with the transformer.

author: redgear
author_rank: Frequent Contributor
timestamp: July 09, 2020, 06:37:52 am
content: Quote from: moffy on July 09, 2020, 01:06:12 amQuote from: mariush on July 09, 2020, 04:43:24 amThank you bothWon't the 9v transformer be a better design choice? Since I will be using a Linear Regulator, 9v would mean less energy is wasted as heat.As for the diodes I'm considering the S1M diodes for the bridge rectifier and 1N4148 as protection diodes for the relays.My device has a EM ballast, I'm concerned if the LCD Display will output gibberish when they are turned on, is there a way to filter it? Would filter caps be a good idea? How do I calculate the capacitance required?Looking forward for what you guys have to suggest.

author: redgear
author_rank: Frequent Contributor
timestamp: July 09, 2020, 06:41:09 am
content: Quote from: moffy on July 09, 2020, 06:32:10 amThank you. So, it would be better to have two regulators in parallel or a vol. reg. with a higher power rating, correct?

author: moffy
author_rank: Super Contributor
timestamp: July 09, 2020, 06:59:02 am
content: I would still go with my original suggestion (the relays don't need a voltage regulator), but the actual currents and transformer are important, like any electronic circuit, just be aware of it. The transformer should have a voltage regulation figure which gives you the difference between no load and full load. A 10v RMS secondary would be good, but I really haven't seen any, but 9v is more common and should do, all things considered. You just need to make an informed decision based on what is available, you can calculate the voltage readily enough. Then choose your relays and see what their minimum pull in voltage is. I looked up one:https://docs.rs-online.com/4354/0900766b8139785f.pdfand the minimum pull in voltage is 9v for a 12v coil and drop out voltage is 0.6v.

author: redgear
author_rank: Frequent Contributor
timestamp: July 09, 2020, 07:28:48 am
content: Quote from: moffy on July 09, 2020, 06:59:02 amThanks. 9,10,12v RMS is available. Have to do some readings before I choose one. Do you have any brand suggestions?

author: moffy
author_rank: Super Contributor
timestamp: July 09, 2020, 07:36:11 am
content: Sorry, I don't but if you choose a reputable supplier you tend to get decent honest components. Also good components will have detailed data sheets. Not Chinese though, they can be all over the place, you often have to derate a component by at least 50%.P.S. I don't mind buying Arduino boards from Ebay etc. because they are an open standard.

author: mariush
author_rank: Super Contributor
timestamp: July 09, 2020, 04:18:09 pm
content: Quote from: redgear on July 09, 2020, 06:37:52 amActually, no, not really...You have a few problems.Low VA transformers (let's say 10-25VA) will have very poor regulation at low currents.... let's say under 50mA, the voltage may be up to 20% higher than the rated voltage.So, for example, a 9V AC may output 11v AC at very low currents, which rectified ends up to something like 11v x 1.414 - 2 x 0.5v = 14.5v (the diodes in the bridge rectifier also have low voltage drop at very low currents)The most power hungry components are the relays, while they're turned on... those will consume around 10-25mA each. In contrast, your microcontroller will consume maybe 1-5mA and your LCD display will consume 3-5mA plus something like 15-45mA when the backlight (if any) is turned on. If you add some status leds, maybe 5-10mA per led?So basically, in the worst case scenario where all relays are off, and the backlight of the lcd display is off, your circuit may consume less than 20mA, which means the transformer has the potential to output higher voltage than expected.On the other hand, you also have to be aware of fluctuations in the mains voltage.If you design your circuit to be used in various places, you have to take in consideration that voltage may not be always 110v , 120v or 230v ... it's perfectly legal to have something like -5% ... +10% , or even +/- 10%I often see at 2-3 AM the voltage on my mains socket creeping up to 247v, which is still legal (230v +10% = 253v) ... but I can also see the voltage go down to around 215v sometimes.So here's some calculations for two transformers : 115v/230v AC -> 9v and 115/230v -> 12v AC , taking in consideration low and high AC input (excel spreadsheet attached at the bottom):Transformer.xlsx(10.09 kB - downloaded 64 times.)As you can see, with a 9v transformer in the worst case scenario, you may have as little as 8v AC or a bit under 10v after rectification. That may still be enough to keep relays working, but it's a bit of a worry.On the other hand, at very low current and if you have a high ac input, your input voltage may be up to 15v..16v ... which is uncomfortably close to 16v, so if you want to be absolutely safe, you'd have to use bulkier 25v rated capacitors.(a lot of people assume "oh, i'll just use 9v or 10v ac transformer because I'd be able to use smaller 16v rated capacitors but that's not safe)With 12v, worst case scenario you'd have 13.35v or 20-22v at very low currents but the average would be around 15v25v rated capacitors would be fine, 35v rated would be even better.The only concern you would have is using linear regulators with low maximum input voltage (like let's say 1117 series which may have maximum input voltage of 17v DC)Now going back to linear regulator ... the linear regulator does dissipate the difference between input and output in the form of heat.BUT, keep in mind that you're gonna power the microcontroller and the lcd display (and maybe <0.5mA for uln2003a) and some status leds ... so let's say under 50mAEven with high input voltage, the amount of power dissipated with be relatively small :Power wasted = ( Vin - Vout) x Current .... ( 15v - 5v ) x 0.05 A 10 x 0.05 = 0.5 watts ....This is below the requirements for a heatsink on a to-220 regulator (it will be quite warm at around 50-70 degrees but otherwise will be perfectly fine.Let's say you're idling the circuit and you use only 10mA and transformer peaks to 22v ... (22v - 5v ) x 0.01A = 0.17 watts

author: redgear
author_rank: Frequent Contributor
timestamp: July 10, 2020, 07:52:24 am
content: Quote from: mariush on July 09, 2020, 04:18:09 pmWow, Thank you so much for taking the time to explain with so much detail. Time for me to start working on the schematic. Few more questions before I start:1) For circuit protection will a fuse alone be enough? Will I need to use a MOV?2) Do I need a EMI filter circuit between the AC in and primary of transformer?3) While reading about power supplies, I came across the TNY268PN from Power Integrations which can be used to design a SMPS and it fits my requirements. Do I really need a SMPS or transformer + linear reg be enough(with your previous answer, I think this should be enough)?Thanks

author: redgear
author_rank: Frequent Contributor
timestamp: July 10, 2020, 01:02:31 pm
content: Here is an update. I have a minimal schematic now.How does it look? Do I need to make any changes? Should I add any other protection than Fuse?

author: phil from seattle
author_rank: Super Contributor
timestamp: July 10, 2020, 03:44:28 pm
content: Don't connect N to gnd. AC relay? don't connect through gnd.

author: Syntax Error
author_rank: Frequent Contributor
timestamp: July 10, 2020, 04:10:46 pm
content: Quote from: phil from seattle on July 10, 2020, 03:44:28 pmAgreed. It's not just your Arduino that is likely to get killed.Why not dispense with the relay? If you are just sensing mains, then use a 240V rated opto-isolator to signal the micro-controller. You can buy these "arduino mains sensor opto-isolator" boards on ebay for under €10.

author: mariush
author_rank: Super Contributor
timestamp: July 10, 2020, 06:07:47 pm
content: Quote from: redgear on July 10, 2020, 07:52:24 amYou're welcome. I think a fuse will be enough, no need for MOVs and complex things. Make sure you pick a suitable fuse though , properly sized.For example, let's say you have a 115v to 12v transformer and your circuit consumes up to 2 watts (around 150mA) ... that would be about 2 watts / 115v = 0.017A of current on the primary.You'd probably want the fuse to blow if the circuit starts to consume more than double that, so probably a 50mA fuse on the primary side would be a good choice. 100mA would be overall safer.... may be too big to pop if a relay shorts out.Make it slow blow, because when you first plug in your device that capacitor right after the bridge rectifier will suck energy like a black hole, especially if it's low esr, so you'll get a current spike on the transformer for a few milliseconds until the capacitor fills up.As for using chips like TNY ... that's an offline power switcher, they're more complex circuits than regular dc-dc switching regulator chips. You're too much of a beginner to deal with such ICs that work with mains voltage ... stick to the safety that a classic transformer gives you or use a ready made ac-dc adapter (a phone charger, usb adapter, wallwart)Also, that TNY chip would require a custom made high frequency transformer that would probably cost more than a ready made switching power supply.

author: redgear
author_rank: Frequent Contributor
timestamp: July 11, 2020, 05:31:24 am
content: Quote from: Syntax Error on July 10, 2020, 04:10:46 pmQuote from: phil from seattle on July 10, 2020, 03:44:28 pmOops. I totally forgot. I had a different component there at first. Thanks for pointing it out.Yes, it is an AC relay. I am adding a annotated schematic with this post.I have some components in the circuit that requires AC mains supply. The Arduino must switch on or off based on few conditions. The components should be powered when SW1 and either of switches SW3 or SW4 is closed. I had initially connected the switch directly to Arduino. SW1 is a cut-off switch, so I directly connected it to supply. I felt it is more reliable, as soon as the switch is opened, the power to the components is cut-off. So even if the micro-controller malfunctions, I can be sure that the power will be cut-off when the switch is opened. Is there a better way to do it?Quote from: mariush on July 10, 2020, 06:07:47 pmAlright, thanks. Considering the maximum power consumption for micro and the display, the current was around 500mA, so I doubled it and included a 1A fuse. The components would consume around 2.4A in total and I have a 5A fuse.

author: mariush
author_rank: Super Contributor
timestamp: July 11, 2020, 10:32:14 am
content: I don't understand the stuff about AC in your schematics.Relays have two sides, one you connect to your microcontroller / uln2003a ... when 12v+/- something goes through the coil and energizes it the other side of the relay engages and the circuit is closed, connection is made and all that. As long as that coil in energized, the connection is kept... unless you buy bi-stable relays which only need a pulse for let's say 100ms to permanently switch to one position.See the ms paint picture i just made....You may want to look into TRIACs and optical isolators/triac drivers with zero crossing ... you just send signal to the triac driver (which is also optical isolator) and when the AC sinewave is near 0 or at 0, the driver turns on the triac and you get power to your device.A well known usage is in soldering stations and hot air guns, where a microcontroller or analog circuit turns on the AC connected heating element using a triac and triac driverSee the schematic here :https://sc0ty.pl/2012/10/my-soldering-station/He's using a MOC3041 triac driver, which is available in DIP package :https://www.digikey.com/products/en/isolators/optoisolators-triac-scr-output/904?quantity=0&ColumnSort=1000011&page=1&k=moc3041&pageSize=25The triacs will dissipate some heat when in use, so they'll have to be on some heatsink, and you'll have to be very careful about not touching the heatink or the triacs because they'll be live (i suppose you could use a mica insulator between triac and heatsink, so heatsink won't be live, but even then I'd still be careful not to touch the heatsink or get my fingers near the triacs)

author: redgear
author_rank: Frequent Contributor
timestamp: July 11, 2020, 12:33:56 pm
content: Quote from: mariush on July 11, 2020, 10:32:14 amYes, I understand that.QuoteIn my circuit, what I am trying to achieve is control the components using Arduino with the help of relays. The switch SW1 must be closed in order for the relays to be latched(on). Initially I thought of connecting the relay directly to ULN2003A/Arduino. But to be extra safe I routed the power for components through a switch, so even if the microcontroller fails, the components are switched off as soon as SW1 is open.I made a stupid mistake in my schematic. I haven't powered the relay coils. I realized it only after I saw your Circuit Diagram. I will make the changes and post the updated schematic.Once again, thank you so much.Edit: Is it necessary to use need to use a TRAIC/opto coupler. Would a fuse between AC live and each component be enough?

author: redgear
author_rank: Frequent Contributor
timestamp: July 12, 2020, 10:18:56 am
content: Here is am update. Thinking to replace the relay with a Triac+optocoupler. Read about both but I haven't decided on one yet.

author: redgear
author_rank: Frequent Contributor
timestamp: July 16, 2020, 11:32:35 am
content: Quote from: mariush on July 07, 2020, 04:24:10 pmI am wanting to use this, but there isn't much info about this. Is it as simple as designing a PCB with the electrode area recommended in the datasheet, hookup the capacitor and connect the IC to a MCU?