Author Topic: Design help with basic logic gates for a simple aquarium pump controller.  (Read 8140 times)

0 Members and 1 Guest are viewing this topic.

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
Hello all,

I've gotten a bit stuck trying to design this, as I am beyond noob grade when it comes to circuit design but at the same time I'm massively curious and have plenty of simple electronics (emphasis: simple) experience.

I have built an aquarium pump controller that is as basic as it gets, with 2 float switches in series that will interrupt a low voltage supply for a relay that switches AC240V. If either the tank runs high or the sump (a lower filtration tank, for those non-aquarist) runs low, either will break the relay control circuit and therefore inhibit the pump. There is a status LED that only lights if the entire circuit is closed, so it's a little pointless but I couldn't figure out how to have an LED work for either switch 10 years ago, and just went with a single in-line LED.

Anyway, the circuit's simplicity makes it fantastically robust, and it's still working well nearly 10 years on.

This is the schematic: (screw terminal refers to the pump)


I've designed a better version that now will have an LED that works in line


However I've decided I'd like to make a fancier version. One of the problems with this design is lack of hysteresis: when either switch triggers, the pump is stopped however the water continues to flow. So, if there is a partial blockage of the drain, at some point the water can still flow down to the sump, which will then restore the normal circuit and start the pump again. This results in the pump stopping and starting every minute or so, until the problem is corrected. I would prefer to have the switches latch in the off state, and light up a fault LED (+/- piezo alarm) corresponding to whichever switch was tripped; I would also need a reset switch so as to restart everything once the fault is fixed.

With some homework and reading, I've enhanced the original design with more status LEDs and a rudimentary AND gate. There is also some more feedback lighting with a 3 position switch that can either force the pump on or off.


So I'm thinking that a simple latch eg. S-R will do the trick. If either switch outputs a 0, then the output should switch from the normal running state (Q -> power to relay) to alarm state (not Q -> power to something else) , with a momentary reset button on the front to return to Q state with manual intervention.

Edit I've noticed my mistake with the override, currently working on fixing that. |O
« Last Edit: April 07, 2018, 02:18:42 pm by Enlargee79 »
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Hi,

Can see the idea behind your switches, though cannot say I have seen anyone making such a device before.

Your problem of  the repeated off/on  slow draining needs a small delay which could be built in with caps etc,  but looking at the extra parts already used then I would just use a little $5 Arduino Nano or Uno which allows you total timing control.

Obviously you could do so much more with the Arduino at the same time, temp control, lighting , if you haven't got that already.

Its very easy to use and could give you some float switch code to work with if it seems too daunting to get going.
« Last Edit: April 07, 2018, 02:53:07 pm by picandmix »
 

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
Thank you for your reply.
I have toyed wiht the idea of using an arduino before, but then I thought - let's start with somthing a little more straightforward in a sense using discrete components. Seriously pondering it but I think I'd need to do far more preparation work to understand controlling *things* via software.

BTW the issue with slow draining might not have been clear with my previous explanatin. Perhaps it is best explained with an example.
The pump runs continuously, as long as both of the float switches are closed. Two things can happen
 1. Drain blocks. Water slowly fills the main tank until the upper float switch cuts power, but in order to get to this point ~10 or so litres excess is in the upper tank. If the pump had kept going then it would overflow, but the pump has cut off. The excess water will slowly drain down over, say 30 seconds or so. At this point the level drops and the switch closes again, starting up the pump and overfilling to the point that the upper switch cuts out again.

 2. Sump runs dry - over time and with evapouration eventually the circulating volume is low enough that the pump would run dry. To prevent this, there is a float switch in the lower tank, which cuts power below a certain level. However, similar to above there is some amount of water (eg 10 litres) still draining from the upper tank. The same cycle happens where the pump starts flowing, pushing some amount of excess into the upper tank before the switch cuts out again. This then flows down and starts the pump again, until there is not enough in the lower tank, causing another cut off.


It's not a common approach to this issue, because people usually will have a sump that has at least enough capacity to catch all the excess in the case of a pump failure. I was able to get away with a smaller and simpler sump by creating the cut off circuit, and consequently I can have a much higher water level in the tank without risking an overflow.
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Hi,

Yes , do understand your problem, been reef keeping for many years, though as you say, most overcome such a problem by having good spare capacity in the sump, or are just lucky they don't have a fish  stuck in the return pipe .

For your circuit  I would have thought that you need the float switch configured so that it allows voltage , via a resistor to slowly charge a capacitor, eg 10-30 seconds or so before it built up enough voltage to turn on the transistor, a method use in simple burglar alarms.

 
If you want a few minutes, then probably using a 555 timer would be simpler.

Do you have an Arduino tucked away ?

 

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
No, I don't have one yet. The more I watch videos about this the more it seems like it would be a more efficient way to do this.

Even though I have a pretty sweet PCB designed in easyEDA.
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Hi,

Was just by my little Arduino so just done this simple code for you to look at, its only got the odd user comment ,  so if its not clear let us know, the file opens in Wordpad etc.

You can see whats called the Serial Monitor where you can get it to show the actions in progress while the code is running on the Arduino, a handy feature.

hth

 
The following users thanked this post: Enlargee79

Online tautech

  • Super Contributor
  • ***
  • Posts: 28395
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Have a play with the gate simulators here until you find the gate types and configurations that does what you need:
https://tams.informatik.uni-hamburg.de/applets/hades/webdemos/10-gates/00-gates/chapter.html
(You need Java enabled in your browser.)
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 
The following users thanked this post: Vgkid, Enlargee79

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
Thank you :)

Of course I have to wait a week or so for the arduino to arrive, as well as the relay board. I've also got a plan to have it play various wav files via SD card and this libary https://github.com/TMRh20/TMRpcm/wiki - but first the basics.

I have normally closed float switches, so I might have to change tank state LOW <-> HIGH in a few places, but this is a massive starter.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
Not quite what you are asking about, but on looking at your new circuit it seems to be "upside down". You have Q1 and Q2 as NPN transistors, yet you have them on the high side of the load instead of the low side. When using NPN transistors as switches they work best when the load is on the collector, not on the emitter.

Also, I can't see the difference between SW1 position I and II? To me, both positions look identical?
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
Further hints:

I would be best to have only one transistor instead of two doing the switching, and then have the logic function on the base of the transistor. Basically (no pun intended), you would have a pull-up resistor on the base to turn the transistor on for normal operation, and if either float switch goes into the "stop pump" position it should pull the base to ground and turn the transistor off.
 

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
"Also, I can't see the difference between SW1 position I and II? To me, both positions look identical?"
Yes that was the mistake I was referring to in the edit.

"I would be best to have only one transistor instead of two doing the switching," yep, makes sense :)
"and then have the logic function on the base of the transistor."  umm???
"Basically (no pun intended), you would have a pull-up resistor on the base to turn the transistor on for normal operation," ok now I'm lost  :-//
and if either float switch goes into the "stop pump" position it should pull the base to ground and turn the transistor off.
- I'm sorry, but I don't understand that at all :(

Also while working on this I've made a few changes. I knew that in all likelihood I would have chosen the wrong kind of transistors - that was guaranteed from the outset. The choice for two of them was to work as an AND gate, and also so that each LED can light when the respective switch is on. That's probably clearer in my updated version.


Also, picandmix sure has made a compelling argument to scrap this idea and go with an arduino based approach.

But just look how sexy this PCB is. Never in a billion years would I imagine designing my own PCB.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Once you've designed your first PCB, you can do it again even easier. I would rework most of that circuit, if you want to stick with discrete logic at least follow the advice of using just one transistor, put it on the low side and then use logic to control it. You should also have a diode across the relay coil to prevent spikes from damaging the transistor.
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 28395
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
But just look how sexy this PCB is.
Maybe to you but my mentor would call it gawd awful !

As James said you need a back EMF diode on the relay.
Edit many of the footprints to allow for a larger annular ring around the holes and some of them look oversize too.
0.7mm hole works for many TH components.
Component placement could be improved to allow better/neater routing.
Try to resist placing more than a single trace to any pad and instead route like on the DC1_9V rail.
Even with an overlay try to have important signifiers near an pad and visible even after the PCB is populated. (K, +, (pin)1 etc). In the absence of an overlay they can be done in copper alongside the appropriate pad.
What's with the 2 different LED symbols ?  :scared:
Have a good think about what you need visible in the overlay....the R&C#'s not so much but the value, yes !

Two good things to keep in mind for a PCB.
What could PCB rework (repair) of my PCB be like.....would any components need to be removed in order to access another ? Can I get to it easy with an iron, DMM, test grabber and so on.
Is there enough info on the PCB should I loose my documentation or someone else need to repair it ?

Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us

Maybe to you but my mentor would call it gawd awful !


I think that's a bit harsh. For a first PCB I'd call it rather good, sure there's room for improvement but PCB design takes practice. I've certainly seen worse boards from people who have done more of them.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
"I would be best to have only one transistor instead of two doing the switching," yep, makes sense :)
"and then have the logic function on the base of the transistor."  umm???
"Basically (no pun intended), you would have a pull-up resistor on the base to turn the transistor on for normal operation," ok now I'm lost  :-//
and if either float switch goes into the "stop pump" position it should pull the base to ground and turn the transistor off.
- I'm sorry, but I don't understand that at all :(

OK, you have your one transistor. You need to connect the emitter to the negative supply rail (where you have the ground symbol) and you place the relay coil between the positive rail and the collector. (In simple terms, put the transistor at the bottom, under the relay coil.)

Now, the pull-up resistor is simply a resistor from the transistor base to the positive supply rail, of sufficient value to saturate the transistor and make it fully on.

Next, to turn the transistor off when required you connect its base directly to the negative rail, causing it to be at 0 V. You do this with the float switch contacts. You can put both contacts in parallel between the transistor base and ground. Then either float switch closing will turn the transistor off, and thus interrupt the current through the relay coil.
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4056
  • Country: gb
A few thoughts.... as a beginner myself, so I might have made a few mistakes.

LED 3 can never be lit, or is that a schematic anomaly?  There is a path to bypass it regardless of transistor state so 0V will form across it.  I would remove the bypass trace between D1 and the end of LED3.  Also, no need for R3 as you have already current limited the circuits back at LED1/2 with 360Ohms.   Note this limits the relay ON current also.  The relay resistance might change the brightness of the LEDs as it will drop some voltage.  Probably quite small though.

The path to "ON" has to traverse 2 transistors + 1 diode + 2 LEDs (although one of them currently won't work).  So the total voltage drop could be as high as 5V, More likely 0.7*5 = 3.5V  leaving 5.5V for the relay to engage with.  Actually the LEDs drop much more than 0.7V, blue LED will drop nearly 3V on it's own.

Relay might need a flyback diode across the coil.  The coil acts like an inductor, when energised it will hold charge, so when you suddenly remove the current from it it will might spike a large voltage backwards.  D1 (and LEDs) "might" block it, depending on the coil it can be kilo volts!, but normally you put a diode reverse across the coil so the voltage just spins around in the diode until it decays.  When the relay is powered current will flow through the coil.  When it is off it will discharge itself backwards in a short circuit with itself.
https://electronics.stackexchange.com/questions/146499/relays-flyback-diode-is-it-necessary/146514

R1 and R2, the purpose of these is to stop the large amount of current that can flow from the transistor Base to Emitter.  They need to be speced to be low enough to saturate the transistor, but not much more than that.  It does then beg the question, if you are limiting the current that can flow from Base to Emitter with a resistor, just so the transistor can switch the un-restricted current from the same source.... you don't need a transistor at all.  Transistors are used when you want to use a lesser current source to switch a higher one.  Such as from the pin of a Microcontroller which couldn't power the relay.  In your case you are just using switches, which can easily supply the relay on their own.

I had a play with a schematic and the only difficulty here that can't be done with 2 switches are the LEDs for various states.  However in your circuit LED5 will only light if LED4 is also lit.  This can be done with switches, but I would assume you would want to have TANK_LOW, SUMP_HIGH, PUMP_ON LEDs independently.

The Arduino, being fully digital micro-controller allows you to do all this stuff in software.  Although depending on the relay coil current you might need a transistor to drive it and the flyback diode.  A mosfet is probably easier to deal with, a logic level mosfet will work without current limit as it doesn't pull or leak current through it's gate like a normal bipolar does through it's base.

You would then just need to connect your S1 and S2 to ground when on, floating (disconnected) when off, set the Arduino pins to internal pull up.  Similar for the outputs of SW1, to ground when on.  On output pins, you put current limit resistors for LEDS ( TANK LOW, SUMP HIGH, PUMP ON, RelayCoil ).

Code: [Select]
void loop() {

// Depends on whether these float switches are on (LOW) or off (HIGH) for these states.
// ! means NOT, ie, the reverse, I have assumed the switches pull LOW when on

// Set the tank and sump status LEDs regardless
digitalWrite( SUMP_HIGH_LED, !digialRead( SUMP_HIGH_SWITCH) );
digitalWrite( TANK_LOW_LED, !digialRead( TANK_LOW_SWITCH) );

// Override?  Switch pump relay and it's LED on.
if( ! digitalRead( SW_OVRDE ) ) {
    digitalWrite( RELAY, HIGH );
    digitalWrite( PUMP_ON_LED, HIGH );
    return;
}

// Normal mode, if pump AND sump are on, put pump relay on and it's LED
if( !digitalRead( SW_NORM ) {
    if( ! digitalRead( SUMP_HIGH_SWITCH  )  && ! digitalRead( TANK_LOW_SWITCH ) ) {
       digitalWrite( RELAY, HIGH );
       digitalWrite( PUMP_ON_LED, HIGH );
       return;
   } else {  // switch them off
       digitalWrite( RELAY, LOW );
       digitalWrite( PUMP_ON_LED, LOW );
       return;
   }
}

// Remaining state is Over-ride off.  No action.  Although you could pulse an LED to show this state.

} // end loop

When doing a PCB one of the hardest parts is making absolutely sure your foot prints match your actual components.  For example will that surface mount fuse holder fit the exact one you buy?  LED 3 will never light. ;)

EDIT:  There is a bug in the code, but I'll leave that up to you to find :)

EDIT2:  The other thing you will need is an "anti-short-cycle" to prevent ripples on the water surface and "switch bounce" from toggling the relay rapidly.  Without the flyback diode this would be a good way to make a hipster aquarium switched boost converter to generate high voltage :)  It will also wear out the relay.
« Last Edit: April 08, 2018, 10:45:39 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: Enlargee79

Online paulca

  • Super Contributor
  • ***
  • Posts: 4056
  • Country: gb
Oh, one final thing.

The way you have wired the pump obviously won't work, unless pin 1 and 2 are remote switch pins on the pump.

You will need:

Plug ---> Mains Live -> FUSE --> Relay -> Pump  <- Mains neutral <-- Plug

Though, this opens arguments about mains polarity and depends on which country you are in and mains standards, but it might be better to send the Mains Live to the pump, then neutral via the relay, so that a water leak in the pump will cause a short to earth in the pump and blow the plug fuse or trip your RCD without any voltage going through your board.

I might also consider mounting the relay off board, so you can handle the board without worrying about mains voltage.
« Last Edit: April 08, 2018, 10:54:28 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
Wow that's a lot of info. Clearly this is not straightforward.

Just to get it out of the way - transistors baffle me somewhat. I know *how* they work, what they do, in general terms but the finer point of choosing a correct base current and specing the appropriate limiting resistor is still a bit mystifying.

The only reason I went with two transistors is because that would make an AND gate. The nice part about that is that LED4 and LED5 could then act as a "this switch is currently closed, all's well" independent of each other. That works flawlessly in my EEImagination, although real life is probably in disagreeance.
I can put a diode across the relay, that's no drama - I didn't know that was even an issue.

I messed up with LED3 - it's obvious now. Originally it was in series with the relay, but I can't remember why I put it out parallel like that.

As depicted the pump/fuse circuit probably doesn't represent the connection faithfully. The relay is set up to break/connect the active wire, and neutral simply goes back to the original cord. I do like the idea of having the AC portion completely separate but I was practicing with some of Dave's concepts of AC separation.

This is basically my design philosophy:
 
  • Have two floats that can independently switch off the pump in either an upper tank overflow or sump underrun condition
  • Status indication LEDs showing that either switch is closed
  • A general "things are all good" status LED
  • A big honkin' OFF switch in case there a shit-fan episode
  • Optionally: an override to turn the pump on manually, in times of troubleshooting but this isn't even necessary (just plug the pump into a normal socket).
As it stands, my basic version performs the task adequately. No need for a status LED really since the pump working is evidence enough of the pump working.

I've oredered an arduino and I think that's the best way for me to get a fucntional system as per the above design. I'm not an electronics engineer; my field of expertise is actually in servicing the wetware (I'm a physician), and electronics is a hobby. Naturally I'm time-poor so I don't have a lot of free time to really study the finer points of discrete logic. I was hoping that I could build a functional latch using a reasonably simple approach with a couple of logic gates. With an arduino I can do some other fancy things that wouldn't be remotely feasible (for me) with regular parts.

As for switching a relay with the arduino - that's solved using an off the shelf relay module for $5.

 The electronic components as they are, are sealed in an IP66 container. I've had an overflow a couple of time, which amusingly was not the fault of my unsightly electronics, but rather leaving the refilling hose connected while distracted. It was a regular power board that got wet, and also was a good test of the RCD fault breaker.
 
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
It's not that complicated really.

To use an NPN transistor as a switch, you turn it on by feeding current into the base terminal. Now the current going into the base terminal has to come out again through the emitter (the pointy arrow terminal) and return to ground. For the transistor to work efficiently as a switch there must be no obstacles in this current path. No other transistors, no relay coils, no resistors. The pointy arrow terminal must be connected directly to ground (the negative supply rail). (It must go directly to ground, must not pass Go, must not collect $200 on the way.)

So you have your transistors Q1 and Q2 in exactly the wrong place. There is lots of stuff in the way between the pointy arrow terminal and ground.

Secondly, about the AND gate. You don't need two transistors to make an AND gate. One is enough. Also, an AND gate is equivalent to an OR gate. So you can make your circuit use an OR function instead. Consider:

"The pump is running if float switch 1 is good AND float switch 2 is good."

"The pump stops running if float switch 1 activates OR if float switch 2 activates."

See?

So all you have to do is arrange that the single transistor Q1 is on while both float switches are open circuit, and turns off if either float switch closes. This is what I described in my earlier post. (This requires that you set the float switches to be open when the level is normal and closed when the level is abnormal. But I expect you can do this.)
 
The following users thanked this post: Enlargee79

Online paulca

  • Super Contributor
  • ***
  • Posts: 4056
  • Country: gb
Wow that's a lot of info. Clearly this is not straightforward.

Breadboard, breadboard, breadboard.  Prototype and play.  Soon however the addiction starts with multi-meters (essential), then a scope, then ... then...

If you hadn't ordered the Arduino already I would suggest ordering one with an "Electronics starter kit."  Which will come with a bunch of components and a breadboard.  You can order the electronics kit separately for 20 dollars or so.

"Good" breadboards cost about £10/$18.  Cheap ones look like a bargain and they work "okayish", but can be frustrating when meerly touching your board causes miss-connections and everything has to get wiggled around to contact properly.

On the relay and mains.  The relay will happily switch 5V or 12V too, so while testing things on the bench, until you are 100% sure it's all fine, use a battery and a torch or an LED or something to test it with.  Leave the mains until last.

I think you are right, however it's contraversial in our current audience, but Arduinos make things so much more simple than analogue stuff like NPN transistors.  Things are usually 1 or 0, HIGH/LOW, ON/OFF.  It allows you to get stuff doing cool things without having to learn the nitty gritty of electronics engineering.  You can still work towards the later while getting cool stuff to work in the meantime :)

The $5 relay 5V boards are good, they are "usually" opto-isolated and include the driver transistors.  I used one on a Raspberry PI for years to control a beer making fridge.

Out of interest I nearly made a similar project as a "Auto water changer" based on a large bucket, heater and various valves and level and flow sensors to cycle the water in a tank.  I might at some point return to it.  Sort of like a temporary sump just to do a water change without actually manually doing it with hoses etc.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: Enlargee79

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
*DON'T* trust $5 relay boards for switching mains.  They are often designed by idiots who've never had to follow US or EU rules for safe creepage and clearance distances between mains and low voltage circuits, so may be less safe than a typical dollar store USB charger, and frequently use cheap relays that don't have a snowflake's hope in hell of surviving at the rated current and voltage marked on them.   Also, the optoisolation is often useless because the idiot designer has used a common ground and/or supply rail  for the input and output sides of the optocoupler, and even when they get that right, they often run tracks under the optocoupler, compromising the clearances required for it to meet its isolation voltage rating.   If in doubt, post good closeups of both sides of the PCB here with a ruler in-shot for scale and we can assess its design for you.  Ones that I'd trust at more than 50V and 1/3 of the nominal relay curreht rating are *RARE* like hen's teeth.

If you want a nice boring life where your circuit doesn't electrocute you or blow up in your face,   use an off-board genuine 1st world brand properly rated relay with screw terminals and a DIN rail, or chassis mount - either one piece or socketed, with a plug-in relay.   

If you fit the off-board  relay in an insulating or grounded metal case, with a mains lead in, a fuseholder, two neon indicators, one for power in and the other for load power, and fit a mains socket to the case that meets local safety standards,  then use something like a D connector for the low voltage wiring to the relay coil, and insulate and secure everything inside the case so there is absolutely no way the low voltage wiring can touch a mains connection even if a wire breaks, you can safely control it to switch a mains load from your breadboarded circuit.
« Last Edit: April 08, 2018, 08:33:48 pm by Ian.M »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
When you want to calculate the base resistor, look up the gain of the transistor, 90 is a reasonable guess for most small signal transistors. Then consider the current that your load is going to draw, divide that by the gain and then to make sure you drive it to saturation you might want to double the result, that is the base current you want. The junction is going to drop about 0.6V so use Ohms law (R = V / I) and there you have it. There are other considerations that can matter but for the time being don't worry about that, in practice you might need to tweak the value a bit but that will get you close enough that it will usually work.
 

Offline Enlargee79Topic starter

  • Contributor
  • Posts: 24
  • Country: au
Wow that's a lot of info. Clearly this is not straightforward.

"Breadboard, breadboard, breadboard.  Prototype and play.  Soon however the addiction starts with multi-meters (essential), then a scope, then ... then..."

Got one coming, along with loads of hookup wires. I will definitely be testing out my ideas before ordering any PCBs.

"On the relay and mains.  The relay will happily switch 5V or 12V too, so while testing things on the bench, until you are 100% sure it's all fine, use a battery and a torch or an LED or something to test it with.  Leave the mains until last."
Sound advice, and I already do/did that. In my original design I quadruple checked which terminals were which on the relay and tested with a 9V battery.

"The $5 relay 5V boards are good, they are "usually" opto-isolated and include the driver transistors.  I used one on a Raspberry PI for years to control a beer making fridge."
I ordered one that seems quite popular, and plenty of folks have videos of them switching mains voltage, and continue to post videos - so they appear to still be alive at this point. I'll post pictures once I get them, particularly so Ian can scruitinise the construction.

"Out of interest I nearly made a similar project as a "Auto water changer" based on a large bucket, heater and various valves and level and flow sensors to cycle the water in a tank.  I might at some point return to it.  Sort of like a temporary sump just to do a water change without actually manually doing it with hoses etc."

I may or may not steal your ideas.

So... Integrating the ideas and advice from this thread, I've redesigned and come up with this (below). But even if it works as I imagine, then there's still the issue of hysteresis, and although fancier this design would be functionally equivalent to the original, but with 20% more bling. Bling is nice, but not really the intended design purpose. Basically, if there's something that triggers a shut-off event, then it should latch in that state until manual intervention. That was indeed the driving force behind making this thread in the first place, but we got a bit sidetracked.

I should also point out that I still have the two transistors in the design (at least the thinking is) so that the indicator LEDs can be activated independently. I'm probably doing this wrong but I couldn't get my head around not using two for this objective.
« Last Edit: April 09, 2018, 01:10:13 am by Enlargee79 »
 

Offline BradC

  • Super Contributor
  • ***
  • Posts: 2106
  • Country: au
Why not use a double pole relay and put one pole in series with your float switches. Put a button in parallel with the whole switch chain. That will pull in and stay in when you press the button, and if either float switch opens up the relay drops out and stays dropped out. No transisors, no semiconductors. You could wire it such that the contact that drops out powers the led when the pump is inactive.

 
The following users thanked this post: janoc, Enlargee79

Online paulca

  • Super Contributor
  • ***
  • Posts: 4056
  • Country: gb
I think it's an improvement.

For some reason, mostly I hate working with PNP, NPN transistors, I would consider Mosfets for Q1, Q2.  Mosfets are voltage driven devices.  They have different properties.  You generally don't need to calculate gain and base/gate resistance and stuff like that.  They don't "drop voltage" across them either.
 Although you would probably need pull up resistors, but then calculating R1 and R2 just needs them to be significantly lower than the pull up resistors.. or just remove them.  The pull ups "pull" the gates of the P-Channel mosfets to 9V (in your case), so they say fully off.  Until you pull the gates to ground with the switches when they come fully on.

You need to move your load (relay) before the transistors though.

Your next step is trawling datasheets.  I'd start with the relay.  Determine it's voltage, current etc.  Then start picking transistors, based on the current and voltage requirements.  Work out if they will need heatsinks etc.  Then buy a handful of components and test things out on a breadboard.

Finally, when you have decided on the components and have a prototype working, you can again check the datasheets for the footprints and layout a PCB.
« Last Edit: April 09, 2018, 06:40:36 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf