Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Using CD4011BE (NAND) to automate a heating system

FaneDuru

New Member
I would like to create an electronic circuit able to switch ON a relay (12V dc) when two contacts are open and switch it OFF only when both of them are closed. When this relay is switched on it starts heating of water in a buffer. And, of course, it stops heating when switches off…

I mean, one thermo-regulator closes its contact at a (lower) temperature (let us say 30 Celsius degrees – in the bottom part of the buffer) and remains closed until the temperature decreases below that temperature (it is set for cooling, and temperature is increased after relay is switched ON). A second regulator (set on heating – measuring a the middle buffer height) closes its contact at a higher temperature (let us say 50 Celsius degrees) and stays closed for a hysteresis period (some set degrees).

I need a relay (12V dc) to be switched on when both regulators have their contacts open (below 30 degrees), remaining on when first regulator closes its contact and switch it off when both regulators contact are Closed. After switching the relay Off the heating is stopped and temperature starts decreasing. So, the second regulator contact closes, but this must not determine switching the relay on, to restart heating. The heating must start again only after the first contact is open, too.

As a brief, the relay will be switched on when both contacts are open (below 30 degrees), remaining ON when the first regulator contact is closed, switching the relay OFF when both regulators contact are closed and stay OFF until the first regulator is open, when it should change the status (ON again). It must change its status only when both contacts are closed or open.

I try simulating the behavior of an existing heat pump automation system, for a backup one.
Probably, too many words but I only wanted to clearly describe the need...

I tried a schema using DC4011BE which does only the first part. After the second regulator contact is Open it closes heating, but it starts it again when the second regulator contact becomes open. And it must wait until the first regulator contact is also OFF…

Thanks in advance!
 

Attachments

  • CD4011.jpg
    CD4011.jpg
    105.1 KB · Views: 39
  • NAND Behavior.jpg
    NAND Behavior.jpg
    53.4 KB · Views: 37
Here's one way of doing the logic part, using a couple of CD4011's :-
1742385721922.png
 

Attachments

  • onoff.asc
    2 KB · Views: 21
Here's one way of doing the logic part, using a couple of CD4011's :-
View attachment 149347
Very interesting, indeed...
So, input b and c are simulated to be the same and their output treat only the case of both inputs being 1 or both being 0. Then, Out2 and Out1 influence each other input for both cases of heating (allowing 1 and 0) and cooling, reversing somehow the behavior of outputs. A kind of bistable, I would say...
Now, the global output to be sent to the relay coil should be Out1, I think. Am ai wrong?
Then, since CD4011 has only 4 gates, I need to use two such ICs supplied from the same source. I have plenty, anyhow...
I will better digest its logic and replay (again) if it is something more to be clarified.
I am not an electronist, I only understand well and made some automations using mechanical relays, also believing that my logic is usually good... ;)
Thanks a lot!
It looks to do what is necessary to be done. If not, at least, I have a different approach to understand and cultivate my imagination in using the IC gates.
 
Last edited:
Then you should debounce mechanical contacts.

Using 8 pin ATTINY85 something like this with mBlock

1742393900240.png


mBlock takes your block configuration and converts it into Arduino code you can
either program a small Arduino board, like NANO or program an ATTINY85

Of course if you want this to read a T sensor thats easy to add to block code.


Regards, Dana.
 
The two contacts in discussion are part of the used thermo-regulators. Professional once...
How do you suggest to debounce their mechanical contacts?
Thanks, anyhow!
 
Now, the global output to be sent to the relay coil should be Out1, I think. Am ai wrong?
It depends on (1) how the switches are connected to the rest of the equipment, i.e whether they share a common ground connection (as shown in my schematic) or share a common high side connection and (2) whether the relay coil is being switched high side or low side.
Because U2a and U2b form a bistable latch, switch bounce should not be an issue; but if it were, then a respective capacitor across each switch could mitigate against that.
 
The two contacts in discussion are part of the used thermo-regulators. Professional once...
How do you suggest to debounce their mechanical contacts?
Thanks, anyhow!
The code mBlock solution shown debounces, it looks for stable reading to reading, 100 mS delay between, for same
contact reading to qualify.
 
It depends on (1) how the switches are connected to the rest of the equipment, i.e whether they share a common ground connection (as shown in my schematic) or share a common high side connection and (2) whether the relay coil is being switched high side or low side.
Because U2a and U2b form a bistable latch, switch bounce should not be an issue; but if it were, then a respective capacitor across each switch could mitigate against that.
The switches can be connected exactly as shown in your schematic. They are mechanical contacts of two thermo-regulators. I am not sure that I correctly understand what you mean by "the relay coil is being switched high side or low side"? Only one NO contact of the relay will be used to command another electronic circuit supplied at 12V dc (the same as the relay to change it status coil).
Related to the logic of your schematic, it looks easy to be followed/understood up to the last two gates (U2a and U2b). I mean, I tried understanding without writing and followed the inputs against outputs only in my mind. Initially, I supposed that the logic can relay of the assumption that you can count on the previous output of Out1, but the state change takes some nano seconds and, probably, that last part rapidly switch until it founds a stabile state. (0 and 1 inputs returns the same output as 1 and 0 or 0 and 0). When I will be at home I will deeply dig on the issue...
Related to this my previous assumption, is it a way to delay the superior part of the schematic, returning in Out1 against the other one? Just to be able to relay on the previous state of Out1. Maybe, using some small capacitors to maintain Out1 state a millisecond more than the new state of U1d. Does this way of thinking make any sense?
Thanks again!

Edited: I also clarified the bistable part (the last one). I found an eloquent clip here. I was thinking that maybe somebody else needing something similar will find it useful...

Second edit: Related to "the relay coil is being switched high side or low side" issue the relay coil is switched in low side.


It looks that your proposed solution works great!
 
Last edited:
The logic polarity depends on if the relay is AC or DC as DC coils can be enable by grounding low side or pulling up the high side. But since HVAC uses AC, can you say if these are 24Vac relays? or what?
Regardless, an extra reed or other relay can be added using 5V logic.
i

Otherwise the is inputs A,B are closed =1 the logic is simple.

A =B = 1 SET heat =1 (both closed active)
A=B = 0 RESET heat = 0 ( both open off)

This is exactly as alec_t has designed it using De Morgan's Rule and 5V DC logic.

The only minor reliability thing I would add is a DC wetting caps. to each dry contact sensor for low current DC to prevent oxidation. using 22 uF 16V Tantalum Caps and TVS or RC transient protection to prevent CMOS latchup from long sensor wires from ESD, EMI etc.
Relay driver is TBD depending on specs..
 

Latest threads

New Articles From Microcontroller Tips

Back
Top