Designing a Time Delayed Relay

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Sorry for the really slow reply!
No problem, this project has had some design creep, LOL

But with them commoned like that, if he changed the wires round at the electrical panel, he could short out a phase.
That is what I concluded too, there is a short in that diagram that I can not reconcile, so two circuits it is.

I guess the best solution would be to have two independent current detecting circuits on the board. That would require two Allegro chips. The signal from the second Allegro chip could feed into pin 2 of the micro, and R5 could move to pin 6 or pin 7, so the only extra components would be the connector(s), one Allegro chip and two capacitors.
Agreed, however, the relay is common to the two circuits - how do I ensure that two loads are not used simultaneously - other than simply remembering not to power two devices at once? Do you see a simple way of accomplishing this or will the circuitry require a lot more components or large switches?

The connectors on my layout are Phoenix Combicon types. I gave links in post #55.

The board is exactly 4 inches horizontally, and 2 inches vertically, between the mounting holes. My PCB CAD package does both metric and imperial, but it's best to use one or the other, and all of the other components were imperial, so I used imperial spacing for the mounting holes as well.
I used imperial on my board as well (ic pin pitch convention). What was the method you used to discern all the common planes between parts on your board? That would really help me redesign my attempts!

C4 is the decoupler for U2. C5 is a filter capacitor for the signal inside U2. C6 is the decoupler for U3. C7 is a filter capacitor for the mains frequency signal that feeds into U3.
Thank you, that clears it up.

Either the PIC12F675 or the PIC12F1571 can be used, with a slight change in the firmware.
I asked because the old PIC was in the schematic again, are we still using the 675 for ease of programming?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
That is what I concluded too, there is a short in that diagram that I can not reconcile, so two circuits it is.
Two independent Allegro chips?
Agreed, however, the relay is common to the two circuits - how do I ensure that two loads are not used simultaneously - other than simply remembering not to power two devices at once? Do you see a simple way of accomplishing this or will the circuitry require a lot more components or large switches?
I don't understand the problem. Tell me where this explanation goes wrong.

You will have a 220VAC connection from your distribution panel to a 220VAC socket on your wall-mounted box. One side (doesn't matter which) will feed through one Allegro chip on the board, which will monitor the current flowing out of the 220VAC socket and into a 220VAC machine.

You will have a 110VAC connection from your distribution panel to a 110VAC socket on your wall-mounted box. One side (doesn't matter which) will feed through another Allegro chip on the board, which will monitor the current flowing out of the 110VAC socket into a 110VAC machine.

The signals from the Allegro chips will feed separate pins of the microcontroller on the board. Either or both machines can be used. The microcontroller will process the signals from both Allegro chips, and when either (or both) of them are active, it will regard the monitored load(s) as active.

The microcontroller will activate the output relay while the monitored load(s) are active, and for 30 seconds afterwards.The output relay will control another socket on the wall-mounted box that may be 110VAC or 220VAC.
I used imperial on my board as well (ic pin pitch convention). What was the method you used to discern all the common planes between parts on your board? That would really help me redesign my attempts
I'm not sure what you mean. For the high-current sections, I did the top layer first, aiming to keep the width of any neck of copper as wide as possible, then I duplicated it onto the bottom layer and deleted the gaps around pins 1~4 of the Allegro chip on the underside. For the other section, I did about half the routing on the top, and half on the bottom, and filled all the significant gaps with grounded copper (well, not grounded; just the negative rail of the circuit), using vias to keep the two sides connected together.

The tracks are mostly 65 thou because there was plenty of room. They don't need to be that thick for electrical reasons; it just makes the board more resistant to rework. Also, I like to leave as much copper as possible on the board because any copper that gets etched off when the board is manufactured goes into the waste stream.
(re the PICs)I asked because the old PIC was in the schematic again, are we still using the 675 for ease of programming?
Yes, might as well. There's no other advantage to either of them. Are they both equally easy for you to get hold of? Is there a price difference?
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Two independent Allegro chips?
Yes.
The signals from the Allegro chips will feed separate pins of the microcontroller on the board. Either or both machines can be used. The microcontroller will process the signals from both Allegro chips, and when either (or both) of them are active, it will regard the monitored load(s) as active.
Sorry, I didn't follow at first, but now realize that the PIC's logic control capabilities serves as the switch and the means of controlling the relay's outcome. In this case it would be an OR statement, when either outlet is loaded, switch on. Thanks!
Yes, might as well. There's no other advantage to either of them. Are they both equally easy for you to get hold of? Is there a price difference?
The first PIC is 1/2 the cost of the newer pic, but it's not significant. I was just checking as the last schematic had the older one again.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
I redid the schematic as you suggested with the second Allegro chip, but had some questions:
Pin 7 of the 2nd Allegro (U3) is the ratiometric output which needs to go to the ADC of the PIC - If I use pin 5 of the PIC, do I keep C7 and R4 or do those get omitted?
Can the C4 decoupling capacitor be shared between both Allegro IC's? I assumed the C5 filtering capacitor should remain separate to prevent crossing signals.
Increasing C1 to 2.2microF will allow for more current available to the circuit to allow for the 2nd Allegro IC, how will it affect the jumpered LED marked J2 (by diode stack)? (My guess is that it will pass too much current at too high of a potential and would need an additional resistor in series and capacitor in parallel to adjust for it)

Am I on the right track?


secondallegro_zps25720019.png
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
I redid the schematic as you suggested with the second Allegro chip, but had some questions:
Pin 7 of the 2nd Allegro (U3) is the ratiometric output which needs to go to the ADC of the PIC - If I use pin 5 of the PIC, do I keep C7 and R4 or do those get omitted?
Pin 5 is used as a mains-frequency signal input for timing. Without it, timing accuracy is determined by the accuracy of the on-chip clock oscillator, which is typically a few percent, worst case ±5%. That's why I suggested using pin 2 of the micro for the signal from the second Allegro chip, and moving the connection to the relay driver transistor to either pin 7 or pin 6. Those pins are used for in-system programming, and you can't connect the Allegro chip to one of those pins.
Can the C4 decoupling capacitor be shared between both Allegro IC's? I assumed the C5 filtering capacitor should remain separate to prevent crossing signals.
Right, you'll need two filtering capacitors. I would stick with a separate decoupling capacitor for each chip too.
Increasing C1 to 2.2microF will allow for more current available to the circuit to allow for the 2nd Allegro IC, how will it affect the jumpered LED marked J2 (by diode stack)? (My guess is that it will pass too much current at too high of a potential and would need an additional resistor in series and capacitor in parallel to adjust for it)
Just decrease the value of the resistor in parallel with the LED. I'll do some calculations, and also give you a definite value for C1.

Looks good :)
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
I had completely missed this!!! :oops:
"I guess the best solution would be to have two independent current detecting circuits on the board. That would require two Allegro chips. The signal from the second Allegro chip could feed into pin 2 of the micro, and R5 could move to pin 6 or pin 7, so the only extra components would be the connector(s), one Allegro chip and two capacitors."

Pin 5 is used as a mains-frequency signal input for timing. Without it, timing accuracy is determined by the accuracy of the on-chip clock oscillator, which is typically a few percent, worst case ±5%. That's why I suggested using pin 2 of the micro for the signal from the second Allegro chip, and moving the connection to the relay driver transistor to either pin 7 or pin 6. Those pins are used for in-system programming, and you can't connect the Allegro chip to one of those pins.
Ok, got it :) Can you explain why you can't connect the Allegro to one of those pins, but you can connect the transistor? When I looked at the chip for an analog channel, I passed up on pins 6 and 7 because they were programming pins and I didn't think you could put anything else with them.

Just decrease the value of the resistor in parallel with the LED. I'll do some calculations, and also give you a definite value for C1.
I take it that you mean the new resistor that would be thrown in parallel with the led? My best guess on the resistors value from a spice model is 62 ohms.

Also, can you look at how I have J2 drawn on the schematic? Should I continue the trace below the jumper pins? The way I have it drawn now, the circuit must pass through the jumper to complete, when the LED fails the circuit will be inoperable. (J2 is the jumper being used to allow leads to the front of the outlet plate where the LED will be placed) See below:

Thanks again :)

j2_zps514a7f31.png


j2a_zps955c7270.png
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Ok, got it :) Can you explain why you can't connect the Allegro to one of those pins, but you can connect the transistor? When I looked at the chip for an analog channel, I passed up on pins 6 and 7 because they were programming pins and I didn't think you could put anything else with them.
When the device is being programmed in-circuit, the programmer supplies voltage onto the VDD rail, and uses pins 6 and 7 to communicate with the device. R5 is 33k and this is so high that it will have almost no effect on the signals being communicated over those pins. All that will happen is that during the time when the pin is high, the relay driver transistor will turn ON, but since there is no relay supply (the programmer only powers up VDD, not V24), the relay won't activate; even if it did, it wouldn't matter.

But if the output from one of the Allegro chips is connected to a programming pin, when VDD is powered up, the Allegro chip will drive that pin with a voltage according to the detected current. With no current present, this voltage will be around 2.5V. This will prevent the programmer and the micro from using that pin to communicate properly.

So it's because the signals from the Allegro chips are driven by the external circuitry (they are inputs to the micro) that you can't use pins 6 and 7 for them. R5 is an output from the micro to the external circuitry, and it doesn't affect that pin much, so it can be shared with a programming signal.

If there wasn't an I/O line like the relay drive control, we could have added a jumper between the Allegro chip output and pin 6 or 7, so the Allegro chip could be disconnected from the programming interface during programming, but luckily, there is, so we don't need to add a jumper.

I take it that you mean the new resistor that would be thrown in parallel with the led? My best guess on the resistors value from a spice model is 62 ohms.
I'm having second thoughts on that method of connecting the LED. I think we should use a high-efficiency LED running at 1~2 mA. These are pretty bright - the one I've used before is the Avago HLMP-D150 (see http://www.digikey.com/product-detail/en/HLMP-D150/516-1323-ND/637587) which is a 5 mm cherry red LED with a diffused lens and a wide viewing angle. It's specified to produce 3 mcd (millicandelas) at 1 mA. You can get LEDs that are a lot brighter, but only because they have a narrower viewing angle. Here's the search I used on Digikey: http://www.digikey.com/product-search/en?FV=fff40008,fff801b9,1140050,114016f,11402b2,1140343,4d4006c,4d40250,87c0011,87c0012,87c0028&ColumnSort=-206&stock=1&quantity=1

That search is limited to LEDs that are designed to run on 1~2 mA. The LED would be connected in series with a current limiting resistor (around 24k for 1 mA, or 12k for 2 mA) across C2, and the LED, reverse diode, and parallel resistor would be replaced with a direct connection.

The reason for this change is the fairly wide variation in current drain between minimum quiescent current for all components and relay OFF, to maximum quiescent current for all components and relay ON. Also the relatively high LED current at turn-on, which is made worse by the increased value of C1.

Also, can you look at how I have J2 drawn on the schematic? Should I continue the trace below the jumper pins? The way I have it drawn now, the circuit must pass through the jumper to complete, when the LED fails the circuit will be inoperable. (J2 is the jumper being used to allow leads to the front of the outlet plate where the LED will be placed)
That's no longer relevant. Can you choose an LED and a series resistor value, and change the circuit to be like I described above? I'll upload an updated schematic sometime in the next few days anyway.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
A 2.2 µF 10% capacitor will be suitable as C1 with the increased load due to the second Allegro chip. Here are three options available from Digikey:

P15514-ND: 2.2 µF ±10% 275VAC Panasonic ECQ-UAAF225K USD 1.58 stock=675
http://www.digikey.com/product-detail/en/ECQ-UAAF225K/P15514-ND/3182273

399-5469-ND: 2.2 µF ±10% 275VAC Kemet R46KR422000M2K USD 1.82 stock=111
http://www.digikey.com/product-detail/en/R46KR422000M2K/399-5469-ND/1930823

495-4787-ND: 2.2 µF ±10% 305VAC Epcos(*) B32924C3225K USD 2.72 stock=1220
http://www.digikey.com/product-detail/en/B32924C3225K/495-4787-ND/3492521

These all have pin spacings of 1.083" nominal, and body size of 1.26" x 0.571" or slightly smaller.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
The LED would be connected in series with a current limiting resistor (around 24k for 1 mA, or 12k for 2 mA) across C2, and the LED, reverse diode, and parallel resistor would be replaced with a direct connection.
I think I understand, see schematic below: J2 would be the cathode side of the LED.
Thanks for the explanation on the PIC programming/pin layout as well as the reason why the LED placement change!
Can you choose an LED and a series resistor value, and change the circuit to be like I described above? I'll upload an updated schematic sometime in the next few days anyway.
LED - Do you know if its a T1 3/4 size? It mentions 5mm and the specs match a similar LED marked as a T1 3/4. I want to be sure as I need to order a holder for mounting it. Spec sheet states 2mA (7 mA max) so that would be the 12k ohm resistor, 207 size.
10c_zpsb344d1f4.png
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
I think I understand, see schematic below: J2 would be the cathode side of the LED.
Yes, that's right. You haven't deleted the other components that were in parallel with the old LED position yet though.
LED - Do you know if its a T1 3/4 size? It mentions 5mm and the specs match a similar LED marked as a T1 3/4. I want to be sure as I need to order a holder for mounting it. Spec sheet states 2mA (7 mA max) so that would be the 12k ohm resistor, 207 size.
Yes, it's the standard T1 3/4 package, 5 mm diameter. I thought you might choose one of the 3.7 mcd green ones. This one has a diffused lens which gives it a wide viewing angle which is good for this application.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Yes, that's right. You haven't deleted the other components that were in parallel with the old LED position yet though.

Yes, it's the standard T1 3/4 package, 5 mm diameter. I thought you might choose one of the 3.7 mcd green ones. This one has a diffused lens which gives it a wide viewing angle which is good for this application.

I took them off :) Thanks for catching that, I forgot where I was in the schematic!!
Hehe, green is go, red is stop ;-)

Thanks again - I will try to find a different connector and then redo the layout. I am looking for the screw down type terminals, fewer components and lower cost. Once assembled, the only time this board would be taken out would be for rework, i.e. blown resistor, or cap going bad so I don't need the convenience of a plug/header for those connections. I might even nix the connector for the LED and just leave two pads to solder extensions.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
I agree green is a better colour. Green LEDs aren't as efficient as red LEDs but that's less important than having the right colour.

While I was working on the updated schematic I noticed that we can't use pin 2 of the MCU for the second Allegro signal - it doesn't have ADC input capability so the MCU can't measure the voltage on that pin. It can be used as a digital input though. So I've moved the mains-frequency signal from pin 5 to pin 2, freeing up pin 5 for the second Allegro chip signal. The relay control signal I've put on pin 7. (Pin 6 would have been suitable too.)

I've also renumbered the components so they flow from left to right.

268425.006.GIF
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
That's was a good catch - only pin 3,5,6,7 of both pic's have ADC inputs!
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
I was looking at building a bench supply and got to thinking about voltage regulators. Will the current LM78L05 be able to supply enough current to the circuit now that we have expanded and added another sensor and some discretes? I read the datasheet and it indicates a max of 100mA.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
The load current will be about 30 mA, so that's not a problem, but it will be dissipating about 600 mW, so a 78L05 will get pretty warm - especially a through-hole one.

I think it would be better to use an SMT device so the board copper can act as a heatsink. The 78M05 is available in SMT and would be suitable: http://www.digikey.com/product-detail/en/L78M05CDT-TR/497-1203-1-ND/586203

Good on you for raising this issue!
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
The load current will be about 30 mA, so that's not a problem, but it will be dissipating about 600 mW, so a 78L05 will get pretty warm - especially a through-hole one.

I think it would be better to use an SMT device so the board copper can act as a heatsink. The 78M05 is available in SMT and would be suitable: http://www.digikey.com/product-detail/en/L78M05CDT-TR/497-1203-1-ND/586203

Good on you for raising this issue!
Thanks, I'm trying to learn and monitor details better!! :)

I see the new part - so create a ground plane for the tab and solder the tab to it as the sink.

I understand how you came up with 30mA (each Allegro states 13mA for ~26mA total) but lost you on the 600mW calculation. The Allegro chips are working off of the 5v rail, the PIC consumes negligible micro amps, the internal resistance of the Allegro is high enough to ignore (i believe) so I can see 150mW of heat - what else is contributing to create the other 450mW?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
The amount of power dissipated by a component is equal to the voltage ACROSS it multiplied by the current through it. The regulator will be dropping about 22V (27V - 5V) so every milliamp it passes causes 22 mW of power dissipation. 30 mA x 22V is 660 mW.

The regulator itself consumes some operating current - the STMicroelectronics 78M05 data sheet says 6 mA maximum. So that's 13+13+6 = 30 mA maximum. The regulator's quiescent current goes to 0V so its power dissipation is actually 6 mA x 27V = 162 mW. Add the regulator power dissipation due to the Allegro chips (26 mA x 22V = 572 mW) and the total is 734 mW. But those are maximums; you'd be unlucky to get all three components at their maximum limits on any one circuit board!
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Awesome explanation, thanks! I see what was missing now :) To that point, should we devise a way to reduce the voltage regulators input?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Maybe. The reason I chose 24V (initially I wanted to use 48V) is that the relay coil needs a certain amount of power, and power is voltage multiplied by current. The higher the voltage, the lower the current. And with a capacitor-fed power supply, you want to keep the current low, because that means a lower input capacitor value.

Originally the design didn't have ANY Allegro chips in it, and used a 48V relay. The main current consumption was from the relay coil and the operating current of the regulator. With the simple transistor regulator, the current consumption would have been only a few milliamps, plus the relay coil current, which for a 48V coil was only 4~8 mA.

Changing to a PIC instead of a CD4040 required a proper regulator which adds up to 6.5 mA. Standard regulators don't like 48V so I dropped it to 24V. This doubled the relay coil current (half voltage --> double current, for a fixed amount of power). Regulators with lower operating current and higher input voltage are available but are more expensive.

Changing to one Allegro chip added 10 mA typical, 13 mA maximum. And changing to two doubled that. So as the design features have crept up, so has the current consumption.

Dropping the unregulated rail to 12V would double the relay coil current again. I think the present compromise is OK. A bit of heat dissipation in the regulator isn't a big deal.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Thanks for the detailed reply - a substitution in a circuit is a never a simple thing. The entire system needs to be looked at! - a very good lesson :)
 
Top