DIYstompboxes.com

DIY Stompboxes => Building your own stompbox => Topic started by: ElectricDruid on December 29, 2020, 08:02:54 AM

Title: Kemet EC2-5NU relay problem
Post by: ElectricDruid on December 29, 2020, 08:02:54 AM
Hi all,

Can I get a sanity check, please?

I'm trying to get a uP to switch a Kemet EC2-5NU relay on and off. Should be fine - it's a 5V coil, switches at 3.75V:

https://docs.rs-online.com/865e/0900766b81719676.pdf (https://docs.rs-online.com/865e/0900766b81719676.pdf)
https://docs.rs-online.com/b92d/0900766b817166b9.pdf (https://docs.rs-online.com/b92d/0900766b817166b9.pdf)

I've got an LED+470R resistor in parallel with the coil, and a 1N4148 diode in reverse parallel. The LED lights up so I know the uP output is switching ok. Without the relay in place, I get 4.89V from the uP pin. With the relay in place, that drops to 3.2V and the relay doesn't switch since that's lower than 3.75V.

It looks like the relay coil is dragging the output right down, but that doesn't seem much use!

What am I doing wrong? I'm feeling like a right idiot not being able to get something this simple working...

Thanks!
Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on December 29, 2020, 08:13:08 AM
Just checked the datasheet and the coil resistance is only 178R. With 5V across it, it'll draw 5/178=0.028 = 28mA. The PICs output can only provide 25mA  max, so no wonder the output gets pulled down.

Do I honestly need a driver transistor to drive the relay coil? What's the point of having a 5V coil then?!? I might as well use a 12V relay if I'm going to have to use a transistor to drive it. I only bought these ones because I thought I could drive them directly.

Title: Re: Kemet EC2-5NU relay problem
Post by: amz-fx on December 29, 2020, 08:31:34 AM
It is interesting that the non-latching relay requires 28ma while the latching version only needs 20ma. Could you switch to the latching version?

regards, Jack
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on December 29, 2020, 09:19:43 AM
You could double up the port pins if you have one spare.
I'm inherently wary of using logic to directly handle any real-world loads - relay/motor/speaker/filaments even if it should handle it.
Title: Re: Kemet EC2-5NU relay problem
Post by: iainpunk on December 29, 2020, 10:21:04 AM
in school i was taught to never drive things directly with an output pin form a uP or uC, always let it drive a transistor in between.

cheers
Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on December 29, 2020, 11:05:23 AM
Jim, doubling up the port pins might work, but it's still putting a good load on the chip package. I notice all the "real world" examples you provide are inductive loads. Presumably you'd have no problem driving LEDs directly?

Iain, I don't see why you'd be taught that you should never drive things with a uC. Maybe in the days when uCs were expensive it made sense to always have a nice cheap transistor between the uC and the outside world, but when the uCs cost pennies now, it's just a question of power handling and so on. Plus sometimes the transistor in-between can screw up the edges of the signal, if you need speed.

Ultimately, I either need a lower-switching-power relay  or I need to stick the transistor in there. I suppose I should have read the datasheet in more detail instead of seeing "5V" and thinking it'd do. Incidentally, Benoit at Coda Effects describes the process of finding such a low power relay in his article: https://www.coda-effects.com/2016/04/relay-bypass-conception-and-relay.html (https://www.coda-effects.com/2016/04/relay-bypass-conception-and-relay.html)

Thanks all, I think I'll go for the transistor. It has the advantage of making the whole thing much less fussy about which relay it uses.



Title: Re: Kemet EC2-5NU relay problem
Post by: iainpunk on December 29, 2020, 11:24:31 AM
QuoteIain, I don't see why you'd be taught that you should never drive things with a uC. Maybe in the days when uCs were expensive it made sense to always have a nice cheap transistor between the uC and the outside world, but when the uCs cost pennies now, it's just a question of power handling and so on. Plus sometimes the transistor in-between can screw up the edges of the signal, if you need speed.
you are right and i should have been more clear, they told me to always drive heavy loads like filaments, lamps, relays etc with a transistor or FET, not just anything

cheers, Iain
Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on December 29, 2020, 11:37:51 AM
Quote from: iainpunk on December 29, 2020, 11:24:31 AM
you are right and i should have been more clear, they told me to always drive heavy loads like filaments, lamps, relays etc with a transistor or FET, not just anything

Sorry, that's me being literal-minded and somewhat pedantic, not your fault.
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on December 29, 2020, 04:32:05 PM
Yeh, I don't call a LED a load - we just use a larger CLR and pick a high efficiency LED.

If a pin can sink more current than source, can you invert everything? Though most of these MCU now have equal capability.

If you don't mind wasting some power when the relay is off, you could use a resistor fed helper supply that directly puts a starting voltage on the coil but not enough for it to pick. The port pin will either add to or shunt away the helper current, but it'll have to be able to pull the coil below 1v to make it drop the contacts and the larger the helper resistor can be, the better.
Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on December 29, 2020, 09:32:58 PM
Quoteyou are right and i should have been more clear, they told me to always drive heavy loads like filaments, lamps, relays etc with a transistor or FET, not just anything


QuoteSorry, that's me being literal-minded and somewhat pedantic, not your fault.

Driving relays directly off the micro does increase the chances of glitching the micro and getting unexplained resets (or even damage).

Title: Re: Kemet EC2-5NU relay problem
Post by: PRR on December 30, 2020, 01:24:06 AM
I've always felt that logic should not drive "real" loads directly. This actually goes way before LEDs: one incandescent turn-on is MUCH more load than hundreds of 2N404 logic bases. Lamp drivers were a separate (added cost) board. This is still often true in industrial gear, where the relays may dwarf your wee clacker and it can be expedient to swap-out a dumb driver board than to re-program a replacement logic board.
Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on December 30, 2020, 03:44:08 AM
QuoteThis is still often true in industrial gear, where the relays may dwarf your wee clacker and it can be expedient to swap-out a dumb driver board than to re-program a replacement logic board.
I've worked on machine projects where *everything* had optos even in the same box.   You can't afford the thing to glitch.

I also worked on a project which had clock monitor that could detected missing clock cycles on the micro's clock.   It was a small mostly low voltage board not unlike a typical micro.   As it turned out the detector would occasionally trip.    The cause was very infrequent coupling of general digital signals into the micro's crystal oscillator when then glitched the micro's clock.   I've never worked on a project which had a means to detect such a thing.   It was very much an eye opener.   It drives home the point that even very simple circuits have some degree of "failure" and that's one reason why some things fail or glitch inexplicably - it just comes down to how frequent the failures occur.  It also highlights why you need robust coms protocols between devices which have error checking and retries.
Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on January 02, 2021, 07:43:12 AM
I've got this working now with the transistor, so everything's fine.

I wanted to mention one other thing that caught me out though, in case anyone else has the same problem and comes looking for an answer.

This Kemet EC2 relay coil *has a right way around*!! I assumed that a coil is a coil of wire and it doesn't matter, but the datasheet does show "+"and "-" symbols for the ends of the coil and if you ignore that it doesn't work.

I don't quite understand how or why, but that's how it is. Perhaps they integrated a flyback diode inside the relay? The datasheet doesn't mention anything like that, and I really *have* read it now... :icon_confused:
Title: Re: Kemet EC2-5NU relay problem
Post by: composition4 on January 02, 2021, 10:35:09 AM
It's because they make the coil out of the same wire as those directional speaker cables that you see on eBay.

It helps towards a more realistic soundstage, you're a lucky guy.
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 02, 2021, 10:42:49 AM
Could it have a small permanent magnet inside? The release voltage is quite low at 0.5v. The magnet will be too weak to latch, but it will help it pick. Also it could remian picked in a low-power standby situation.
I'm not entirely convinced -  you'd think the datasheet would have something to say - but a permanent magnet would explain polarized behaviour. This is how safety-critical relays are polarized. A diode can fail short circuit which could be seriously unsafe. A permag is much more reliable.


Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on January 02, 2021, 05:07:57 PM
QuoteCould it have a small permanent magnet inside?
I'm fairly sure they have magnets.   I'd expect any built-in diode protection to be shown on the relay schematics.   The latching relays need a polarity to define the "set" condition.

In the datasheet (second link in Reply 1) on page 15 under "Notes on Using Relays" the second last point of section 3 says "Permanent magnets are used in polarized relays"  and it warns of not placing the relays close to transformers and speakers.

Good explanation here,
https://www.omron.com.au/service_support/technical_guide/general_purpose_relay/classifications.asp
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 02, 2021, 05:27:42 PM
So the headline is that the non-latching is still polarized. So if you have two relays needed in a remote location and wire them inverse parallel, you can control either of them with just 2 wires by selecting the polarity although you can't have both picked which might otherwise be an unsafe condition for whatever job they're doing (you can't tell a motor to go forward & reverse at the same time!).
Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on January 02, 2021, 05:39:26 PM
QuoteSo if you have two relays needed in a remote location and wire them inverse parallel, you can control either of them with just 2 wires by selecting the polarity although you can't have both picked which might otherwise be an unsafe condition for whatever job they're doing (you can't tell a motor to go forward & reverse at the same time!).
Probably not wise to run them like that.    The magnet helps reduce the pull-in current.    You can't rely on the magnet to block the reverse polarity since you don't know what percentage of help it gives the coil (could vary)
Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on January 02, 2021, 09:57:12 PM
Ok, thanks people. That might explain what I'm seeing.

I definitely thought it was worth pointing out, since (as far as I was concerned) it's not something you'd *expect* and it works one way around and not the other and had me scratching my head for a good while before I twigged.
Title: Re: Kemet EC2-5NU relay problem
Post by: Ripthorn on January 28, 2021, 08:32:22 PM
I'm using these relays on a project, and am using a micro to drive a bit base connected between relay - coil and ground. When engaged, I get a distinct whistling noise. Have any of you experienced this? Terrible for a circuit with gain.
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 29, 2021, 04:51:16 AM
Do you mean the relay coil is making the noise like the inductors in some old switchmode PSU's do?
Is the micro output pulsing? Are you using an analog_write instead of digital_write to switch the BJT?
Do you have a flyback diode across the coil (can kill the BJT if no diode).
Schematic! Code snippet!


Title: Re: Kemet EC2-5NU relay problem
Post by: Ripthorn on January 29, 2021, 09:13:35 AM
Hi Jim, you are right that I was a little light on details. I don't have the schematic on this computer at the moment, but here are some notes:

- microcontroller is using a digital write to energize the transistor
- flyback diode is in place
- The noise on my signal line is the same noise as is heard on the relay coil contacts using an audio probe, just at a reduced level
- I realized after posting that my signal input trace is routed between the relay coil contact pads on the PCB. I have cut the track and soldered in a jumper wire from the source point on PCB to test, but haven't had a chance to plug it in yet.
- I'll post schematic snippet after I get home.
Title: Re: Kemet EC2-5NU relay problem
Post by: Ripthorn on January 29, 2021, 05:46:29 PM
As promised, here is a schematic snippet of how I have the relay coil contacts configured. Anything look amiss here?


(https://i.postimg.cc/0bhn1pGk/Relay.png) (https://postimg.cc/0bhn1pGk)
Title: Re: Kemet EC2-5NU relay problem
Post by: Ripthorn on January 29, 2021, 06:05:25 PM
Below is a more complete picture of the situation. I found that if I short R12, the hissing goes away. The point marked L2 is the +5V from the microcontroller pin. Unfortunately, I am trying to also use this pin for turning on an LED, but when I short R12, the LED essentially turns off. I am assuming this is because the base of the transistor gets pulled to the B-E voltage, which is low enough that my LED with CLR doesn't have enough juice to shine. Any ideas?
(https://i.postimg.cc/BjYKGsfx/Relay.png) (https://postimg.cc/BjYKGsfx)
Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on January 29, 2021, 11:12:32 PM
QuoteBelow is a more complete picture of the situation. I found that if I short R12, the hissing goes away. The point marked L2 is the +5V from the microcontroller pin. Unfortunately, I am trying to also use this pin for turning on an LED, but when I short R12, the LED essentially turns off. I am assuming this is because the base of the transistor gets pulled to the B-E voltage, which is low enough that my LED with CLR doesn't have enough juice to shine. Any ideas?
Shorting R12 is essentially shorting the output of the micro through the BE junction.   It's going to be a low impedance.   It loads the micro pin down and that's why the LED goes out.  Not a good test, wiring R12 to +5V better.

Try putting a cap across the BE junction of the transistor.  Start with 100n, then 1uF, then 10u.  Make sure the cap is discharged before soldering.

I'm with Jim in that I suspect the micro output is not a stable 5V.    The software might be doing something weird like toggling the pin state or toggling between an input and output definition.  One way that can happen is writing bytes which sets the bit you want but destroys the other bits on the same port.   In this case you need to keep a mask of set bits in a variable then output the whole lot at once at each location.
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 30, 2021, 05:00:07 AM
Depends on the platform.
Arduino I/O is designed around the hardware in the MCU so it doesn't present so much pin contention. When you start to use library code, then you need to be careful as it can then have to use a standard I/O pin for another purpose.

I wonder is the controller has an active USB connection? This can carry a 1kHz whine due to polling every 1ms (the bane of cheap soundcards). Having USB in an audio system obviously can be done, but needs better filtering.

If you want USB for a debugging serial monitor of your code, all might be well when you take that out and disconnect the USB.

(https://i.postimg.cc/BjYKGsfx/Relay.png)
This looks ok to me. One thing I don't see is a larger cap on the regulator output. I'd fit at least 100uF in addition to the 100nF (keep that). Regulators can be unstable without enough capacitance (should be some on the regulator input too).
Title: Re: Kemet EC2-5NU relay problem
Post by: Rob Strand on January 30, 2021, 05:16:22 AM
Quote(the bane of cheap soundcards). Having USB in an audio system obviously can be done, but needs better filtering
FWIW,  the PC front panel connector has both USB and audio. They shared the same ground wire which is a total disaster for noise.   You can split the USB and audio ground wiring to the front panel.  You also have to cut the common ground tracks between the USB and audio on the small PCB behind the front panel of the PC.  Using USB connectors at the rear of the PCB and not on the front panel helps enormously.
Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 30, 2021, 02:06:31 PM
I was thinking of the cheap (really cheap) single-chip USB soundcards. Codec & USB in one. They are generally useless for recording due to noise. You can cut the whine with extra filtering, but line input has the same preamp gain as the mic and relies on digital volume control to reduce the level. Sound quality is hideous!

All that said, we don't yet know if USB is relevant yet. But another USB issue is that it has no ground isolation from the host device, so there are common ground induced noises too.

Title: Re: Kemet EC2-5NU relay problem
Post by: ElectricDruid on January 30, 2021, 02:24:14 PM
Rather than driving the LED from the micro's output pin, you might be better off putting it in parallel across the relay coil with whatever series resistor it needs for 4.4V (about what it'll get once you take the BE drop off). The transistor can handle loads of current, so there's no problem there, and it avoids the load on the micro's pin.

Plus I know it works, cos I tried it! ;)


Title: Re: Kemet EC2-5NU relay problem
Post by: anotherjim on January 30, 2021, 05:02:30 PM
I didn't see the LED on the scheme. It would be better run off the transistor switch with the relay, but it should work off the micro's pin IF it has its own series resistor. Without a resistor, the LED will clamp the digital output to its forward voltage drop and overload the pins drive circuit in the micro. If fitted across the relay, the LED still needs a series resistor.

On an Arduino, one of the pins is already driving a LED on the board (pin13?) - avoid that pin if you want to drive any kind of load off it.

Title: Re: Kemet EC2-5NU relay problem
Post by: Ripthorn on January 30, 2021, 08:18:37 PM
Good suggestions, guys. I'll give them a try!