Can the 14m2 directly control a latching relay with a 5V 20ma coil?

wapo54001

Senior Member
I found a post that describes the maximum current capability of pins on the various Picaxe chips here: http://www.picaxeforum.co.uk/showthread.php?11963-PICAXE-I-O-Current-Capability

However, in other posts I have found discussions of a maximum current at 20 milliamps instead of 25 milliamps.

At the moment I am interested in the 14M2, and I would like to drive this latching relay http://www.digikey.com/product-search/en/relays/signal-relays-up-to-2-amps/1049448?k=kemet+relay&k=&pkeyword=kemet+relay&pv675=3&pv72=1&pv1410=13&pv69=80&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25 directly from a Picaxe pin set high, using a capacitor on the low side of the relay coil to store energy to return the relay when the pin is set low.

The post above states that each pin can source or sink 25 milliamps, and this relay draws 20 milliamps at 5vdc (coil resistance = 250 ohms) only long enough to charge the capacitor. When the capacitor is charged, current draw drops dramatically and is no longer an issue. I expect the 20 milliamp draw will be very transitory.

Question I have is, is it safe in the long term to run this relay directly from the 14M2 pin? If 20ma is the maximum, this is working right at the edge, if it's 25ma, then I believe that is adequate headroom for this circuit.

If this isn't going to work I can go to a non-latching relay but I would prefer not to run 20ma continuously through the relay which will be mostly in a steady-state ON.
 

premelec

Senior Member
I'm not entirely clear on your proposed circuit - capacitor etc - since the relay actuates in a few milliseconds seems like something should work fine...
 

eggdweather

Senior Member
Latching relays are pulsed to change their state, so your output pin driving the coil would be pulsed high for a short duration say 10mS so power dissipation is very low and keeping the Picaxe well within its limits. l cannot see any need for a capacitor, what is the circuit arrangement your intending to use?
 

wapo54001

Senior Member
Latching relays are pulsed to change their state, so your output pin driving the coil would be pulsed high for a short duration say 10mS so power dissipation is very low and keeping the Picaxe well within its limits. l cannot see any need for a capacitor, what is the circuit arrangement your intending to use?
The relay delay is 2ms, so the duration of current flow is determined by the size of the capacitor to be charged. The level of current is determined by the DC resistance of the coil, which is 250 ohms. I thought I'd read somewhere that even an instantaneous over-current through a pin is deadly for the chip, so was concerned about that 20ma for the time it takes to charge the capacitor which I believe needs to be around 30uf.

I want to keep the Picaxe chip small, and so want to use one pin per relay (I have multiple relays). Using two pins and reversing logic on the pins to switch would also work, but by using a single pin to charge a capacitor on the negative leg of the relay coil, you can use the stored energy in the capacitor to switch the relay back by switching the pin from high to low.

Upon re-reading, I see that the 25ma number is posted by hippy and taken from the microchip documentation. I think I'll take that as gospel!
 

fernando_g

Senior Member
I see what you are doing.....use a single I/O pin, instead of the two which are normally required to drive a latching type relay. Clever!


I believe that the Picaxe should be perfectly capable of driving those pulses. The coil resistance is 250 ohm, so at 5 volts the peak current is 20 mA and will decay from there.

The only problem that I see is that, unless you plan to unlatch the relay within a minute or so, the capacitor's voltage will bleed of on its own, and there won't be enough charge to unlatch the relay.
 

wapo54001

Senior Member
The only problem that I see is that, unless you plan to unlatch the relay within a minute or so, the capacitor's voltage will bleed of on its own, and there won't be enough charge to unlatch the relay.
I plan to leave the pin high to keep the capacitor charged. This should not require a great deal of current, I think. Anyway, much less than the 20ma-plus of a non-latching relay.
 

fernando_g

Senior Member
I plan to leave the pin high to keep the capacitor charged. This should not require a great deal of current, I think. Anyway, much less than the 20ma-plus of a non-latching relay.
You are correct...once that the capacitor charges, the current drops o zero. You can still keep the pin high and here will be no current consumption at all.
I feel your plan will work.
 

srnet

Senior Member
This should not require a great deal of current, I think
It wont be zero current with an Electrolytic, there will be a leakage current, but its very low and of little consequence.

Mullti Layer SMT caramic capacitors at 47uf are not expensive, and the leakage current should be even lower.
 

AllyCat

Senior Member
Hi,

The post above states that each pin can source or sink 25 milliamps,
The post dates back to 2009 and the (14M2) chips appear to be more accurately characterised in their data sheets now. Note that the 25 mA is an "Absolute maximum" rating which the designer should ensure is not exceeded. It does not mean that any particular chip is actually capable of sinking or sourcing that current (which they certainly can't at low supply voltages).

If you download the "base Microchip" datasheet from the Advanced Technical Details link here, the I/V characteristics of the output pins (FET drivers) is shown around Figure 31-41/2 on page 400. That indicates that the typical source (pull-up) output voltage at 25 mA is only 1 volt (i.e. 4 volts are dropped across the FET) at room temperature. The output is about 3 volts at 20 mA, so the relay might operate as intended.

Some aspects of the Microchip data sheets are notoriously pessimisitic, so the relay might work perfectly well in practice, it may depend if you just have a "one-off" project or a more commercial application.

Cheers, Alan.
 

wapo54001

Senior Member
I see that on page one (summary) of the data sheet that it states that the chip "source/sink 25ma." Since the relay can't draw more than 20ma at 5V (and I assume that the 14M2 'high' is not going to reach a full 5V) I feel pretty safe. Actually, I'm planning on low to be .5V and high to be 4.5v and I think 22uf will be enough. I will try it with much smaller caps to make sure there is a decent safety margin and the current will stay high enough for long enough to latch the relay with a smaller capacitor. The relay spec guarantees latching at 3.75v differential.
 

AllyCat

Senior Member
Hi,

IMHO you can't design around a "highlights" page, some aspects are often mutually exclusive, e.g. you will never get even close to 20 mA I/O with a supply rail at 1.8 volts.

Note the statement on page 347 of the 14M2 dats sheet (where the 25 mA is actually specified):

"Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. Exposure above maximum rating conditions for extended periods may affect device reliability."


The "operation listing" of the I/O pins is in section 30.4 on page 357. Microchip only "guarantee" to source 3.5 mA (at 0.7 v), which might reasonably be doubled to 7 mA for a 1.4 volt drop (i.e. 3.6 volts output).

Cheers, Alan.
 

eggdweather

Senior Member
I see that on page one (summary) of the data sheet that it states that the chip "source/sink 25ma." Since the relay can't draw more than 20ma at 5V (and I assume that the 14M2 'high' is not going to reach a full 5V) I feel pretty safe. Actually, I'm planning on low to be .5V and high to be 4.5v and I think 22uf will be enough. I will try it with much smaller caps to make sure there is a decent safety margin and the current will stay high enough for long enough to latch the relay with a smaller capacitor. The relay spec guarantees latching at 3.75v differential.
Regarding the C value, I'm thinking:
Power needed to switch relay = 4.5v x 20mA for 10mS = 0.0009Watts
Charge Q held by C = 1/2xCxV^2 (Joules(*per second) or Watts), therefore:
0.0009=1/2 x C x V x V where V = 4.5 and solving for C = 0.0009 x 2 / 4.5 / 4.5 = 88uF, but maybe the relay does not need a full power pulse (for the 10mS) to be activated and a lower value could be used.
 
Last edited:

erco

Senior Member
Interesting concept and well worth trying, please advise your findings. Latching relays are great to save energy in battery powered thermostats etc. That said, if battery life is not of primary concern, this method has no huge advantage over a traditional (non-latching) relay controlled by a driver transistor and bias resistor. Depending on the application, the latter may be cheaper in high volume and offer a wider variety of relay types.
 

eggdweather

Senior Member
I've been trying to figure out how this will work, so far I think it is wired and works like like this:

PICAXE Pin----Capacitor---Relay Coil---GND

The relay needs +/- polarity to turn it on, so to switch on bring the PICAXE Pin high, assuming (5v/20mA the relay has DC resistance of 250R) and the capacitor is gradually charged, initially it's charge is zero, so the relay gets a full 5volts, then as the capacitor charges the voltage across the relay drops to zero and C is at 5volts, or thereabouts.
PICAXE Pin(Vdd)---+Capacitor---Relay Coil---GND

To turn the relay off, bring the PICAXE pin low, then the positive end of the C is grounded instantaneously reversing the voltage on the relay and current flows through the relay giving these conditions:

PICAXE Pin(Gnd*)----Capacitor+--Relay Coil---GND

And if the capacitor holds enough energy to make the switch, voltage across the relay has been reversed as required and it turns off.

In the ON steady state with the PICAXE pin high, the only current to flow will be the C leakage and should be negligible and when turned off (PICAXE pin low), when the energy in the C has been discharged, no or negligible current will flow too.

On switch off, the PICAXE pin has to be able to handle the discharge current, which will be limited by L.Di/Dt and build up to a maximum, limited by the assumed internal impedance of 250R, which would keep the PICAXE pin within specification on either switch on or off.
 

hippy

Technical Support
Staff member
While it sounds like it should work; are there any potential issues with back EMF etc ?

Probably the best way to find out is to try it. If the current is below 25mA the PICAXE should survive though probably best to consider it sacrificial just in case. A current limited bench supply will help limit the potential for damage.

One would probably need to test a variety of capacitors and relays to make sure anything which works does work with them all.
 

wapo54001

Senior Member
I've been trying to figure out how this will work, so far I think it is wired and works like like this:

PICAXE Pin----Capacitor---Relay Coil---GND
The way I see it, it's picaxe -> relay -> capacitor -> ground.

With the relay in 'reset' position and the picaxe pin low, set the pin high. That will charge the capacitor through the relay and in the process send enough current through the relay to 'set' it. The capacitor fully charges and stores energy; when the picaxe pin is set low, the stored energy flows back through the relay and returns it to 'reset' position. That's what I'm thinking, haven't tried it yet because my workshop is all torn up (new carpet). Although the picaxe pin will not hit either +5 or true ground, the relay is supposed to operate with 3.75V max, so hopefully will work.
 

wapo54001

Senior Member
While it sounds like it should work; are there any potential issues with back EMF etc ?

Probably the best way to find out is to try it. If the current is below 25mA the PICAXE should survive though probably best to consider it sacrificial just in case. A current limited bench supply will help limit the potential for damage.

One would probably need to test a variety of capacitors and relays to make sure anything which works does work with them all.
I have included a 4148 across the coil.

With the coil at 250 ohms and voltage at 5V regulated, I think the current cannot go above 20ma. Also, with the pin not reaching true +5 or true ground, the actual current should be less. My main worry is to ensure the capacitor is big enough to set and reset the relay.
 

Jeremy Harris

Senior Member
The back EMF protection diode needs to go from the Picaxe pin to the 0V rail, rather than across the coil. If it is across the coil it will conduct when the Picaxe pin goes low, effectively shorting the relay out and causing the capacitor current to flow directly into the Picaxe pin, probably exceeding the sink current capability of it by a large margin.
 

AllyCat

Senior Member
Hi,

In my opinion you're unlikley to damage the PICaxe (with pull-up current), I'm more concerned that the (pull-up) FET output stage will be unable to drive the relay with sufficient current to reliably operate it. But it is worth noting that although the I/O pin Absolute Maximum Source and Sink currents are 25 mA, the maximum Clamp Current is only +/-20 mA (data immediately above on page 334). So, if the PICaxe were able to source 20 mA+ then pulsing the relay could cause the clamp rating to be exceeded (since you can't use an external clamp diode across the coil). Therefore the series capacitor idea may be quite a good solution as there is then no need to break the current flow.

The method I would use to calculate the capacitor value is to ensure that the average voltage across the coil exceeds the "must operate voltage" for at least the the operating time of the relay. Unfortunately, the operating time is not specified below the nominal drive power (page 10 of the EC2 data sheet) i.e. 100 mW = 5v * 20 mA gives ~ 2.5ms, but we can assume that it will be significantly more than 3 ms.

The PICaxe data sheet suggests that the Typical output voltage is almost exactly 3.75 v at 15 mA, but if we assume that it might be 4 volts, then we could allow the capacitor to droop to 3.5 volts. That's around 14% of the time constant, so assuming a 4 ms operate time then the time constant should be ~ 30ms. With a 250 ohm resistance that would make the required capacitor a little above 100 uF.

Of course a full analysis should take into account the slow(er) rise of current (due to the coil inductance) and that the amount of force (current) required becomes less as the relay armature starts to move. So in summary, there really isn't enough data, but probably a reasonable chance that the relay will work (and continue to do so over time and temperature). But I wouln't want a factory production line, or store room, full of PCBs to that design. ;)

Cheers, Alan.
 

eggdweather

Senior Member
The way I see it, it's picaxe -> relay -> capacitor -> ground.

With the relay in 'reset' position and the picaxe pin low, set the pin high. That will charge the capacitor through the relay and in the process send enough current through the relay to 'set' it. The capacitor fully charges and stores energy; when the picaxe pin is set low, the stored energy flows back through the relay and returns it to 'reset' position. That's what I'm thinking, haven't tried it yet because my workshop is all torn up (new carpet). Although the picaxe pin will not hit either +5 or true ground, the relay is supposed to operate with 3.75V max, so hopefully will work.
It should not matter on the placement of the C and Relay as it's a series circuit, but current has to flow, so it will always flow through the PICAXE pin regardless, it has to otherwise it would not work.

Recalculating the stored energy requirement using 3.75volts and taking the nearest preferred value C will need to be nearer 150uF than 100uF.
 

Jeremy Harris

Senior Member
I've ordered some single coil latching relays to experiment with, after reading this thread, as I can see some significant advantages in having a very low quiescent current bidirectional switch like this.

The relays I've found are 5V ones that only need 14mA (they are part number V23079C1101B301, datasheet here: http://www.farnell.com/datasheets/1717898.pdf?_ga=1.48145959.1660925541.1459785100 ) and have a 357 ohm coil. I bought a pack of five DPDT ones with 2A rated contacts for under £10 delivered, they should arrive in the next day or two.

I can't see why a circuit where a Picaxe pin is connected to the relay coil, with a series capacitor to 0V, plus a back EMF protection diode from the Picaxe pin to 0V, shouldn't work OK. From the data sheet, this latching relay is specified to operate at 3.75 V, so it should be well inside the Picaxe source and sink current and voltage spec.

The only thing to watch is timing, as this circuit arrangement won't allow for rapid on/off switching of the relay, there has to be a few tens of ms to allow the capacitor to charge and discharge after each state change. Probably not at all a limiting factor in practice, it just means ensuring that the Picaxe pin is held high or low for long enough to allow this.

It's a very interesting idea, as I currently have a remotely operated switch set up that uses an ordinary relay operated by a transistor from a Picaxe pin. This relay controls an electric actuator to open and close a door and at the moment the relay stays on all day whilst the door is open. The unit is powered by a solar panel and battery, and that's sized to provide enough power for the relay, as that uses more energy over the course of a day than the actuator for the door (which has limit switches, so uses no power once it has cycled).
 

eggdweather

Senior Member
I think you have uncovered the perfect solution as that manufacturer also sells a mono-stable latching relay requiring just a single pulse to switch it on/off, but I wonder how relay position is determined or set out of the box, other than measuring or observing circuit action until it is correct, it quotes a random position post production. That's the advantage of the dual coil types as they can be set or reset to the desired initial conditions.
 

wapo54001

Senior Member
I think you have uncovered the perfect solution as that manufacturer also sells a mono-stable latching relay requiring just a single pulse to switch it on/off, but I wonder how relay position is determined or set out of the box, other than measuring or observing circuit action until it is correct, it quotes a random position post production. That's the advantage of the dual coil types as they can be set or reset to the desired initial conditions.
In my application, I was just going to switch back and forth a few times at startup and then stop at 'reset' and go from there.
 

erco

Senior Member
My favorite standard (non-latching) 5V relay is this NAIS/Aromat TF2-5V. Tiny DPDT in DIP format. A bit pricey individually, such as http://www.ebay.com/itm/NAIS-TF2-5V-ATF209-ELECTROMECHANICAL-RELAY-NNB-/390881565723 but occasionally I find bulk batches and stock up.

This relay can be driven directly by a Picaxe pin since the coil is 312 ohms and it only draws 16 mA at 5V. Driven directly by a Picaxe pin, there is lower current (minus the Picaxe pin impedence). Since pins can sink more than source, that's a better way to go. Note that this low-current relay has a polarized coil and has an internal flyback diode.

Off-spec, they do operate lower than 5V. I build a lot of Picaxe circuits powered by Li-Ion cells (3.7-4.1V) and these relays work fine driven directly by a Picaxe pin.

Datasheet at https://www.digchip.com/datasheets/parts/datasheet/614/TF2-5V-pdf.php
 

Jeremy Harris

Senior Member
I think you have uncovered the perfect solution as that manufacturer also sells a mono-stable latching relay requiring just a single pulse to switch it on/off, but I wonder how relay position is determined or set out of the box, other than measuring or observing circuit action until it is correct, it quotes a random position post production. That's the advantage of the dual coil types as they can be set or reset to the desired initial conditions.
Whether or not it's perfect remains to be seen! I'll admit to having bought these simply because I found an ebay seller offering packs of five for £9.99 and at 2A contact rating they will operate the chicken coop door actuator, I have already built, directly.

The double coil versions would be simpler, at the expense of using a second Picaxe pin, but I'm attracted to being able to operate a latching relay with just a single pin, primarily because the existing ciruit uses an 08M2, with two pins taken up by the HC-12 433 MHz transceiver and one which drives an outside light on the chicken coop, so there's only one spare output (excluding the programming serial output pin).

The problem of determining the state initially could be either to do this before connecting the relay, do as suggested by wapo54001 and just switch a few times initially, or just switch to the "on" state once at initialisation, then start from there. If the relay is already "on" then it will just stay where it is, if it isn't then it will switch to the "on" state and stay there.
 

eggdweather

Senior Member
I followed the manufacturers links and they say the relay will be supplied in an indeterminate state (mono-stable type) and there is no way of getting to a determined state other than by inspection (and test), if you get it at the on state; pulse it and it will of course be off and vice-versa, it changes state with each pulse. It would need to be initialised prior to fitting in the final circuit. Plus now I wonder what would happen in reliability terms if a pulse was marginal and it did not switch, then the resultant logic state / operations would not be synchronised with the programme intentions. Still a useful product though.
 

Jeremy Harris

Senior Member
As I understand it, the state is determined by the direction of the current pulse through the coil. My assumption (which may well be false) is that current flowing from coil pin A to coil pin B will put the relay into a known state, if it's not already in that known state. Similarly, current flowing from coil pin B to coil pin A will always put the relay into the known opposite state.

Perhaps this is wrong, I've assumed that the coil is always wound in the same direction for every relay and that the latching magnet is always fitted with the same orientation. If the manufacturer doesn't control one, or either, of those component orientations then I can see that there would be a need to test every relay individually to determine the state it switches to for a given current pulse direction. I can see that causing major production problems, as you have the potential to have two different types of relay with the same part number, and would need to have two circuit boards to allow for the change in connection sense with each type. It was this that convinced me that the manufacturer might well supply them in a random position, but that a given current pulse direction through the coil would put them into the same known state.

I'll do some testing when mine arrive and let everyone know how they behave, as I have five coming, so there is a reasonable chance that I will get some in different states on arrival.
 

wapo54001

Senior Member
Whether or not it's perfect remains to be seen! I'll admit to having bought these simply because I found an ebay seller offering packs of five for £9.99 and at 2A contact rating they will operate the chicken coop door actuator, I have already built, directly.
Are relays not counterfeited like ICs and transistors?
 

Jeremy Harris

Senior Member
Are relays not counterfeited like ICs and transistors?
Probably, but the price is pretty close to the normal price from the bigger suppliers (the list price is £2.08 + VAT each from Farnell), but with free postage, and it's a UK seller. Also, the relay part number is shown and looks to be spot on, together with the manufacturers logo, so I suspect the parts are genuine. This is the ebay link if anyone wants to check: http://www.ebay.co.uk/itm/2A-DPDT-IP67-Latching-PCB-Relay-5V-dc-1-Coil-Gold-Clad-AgNi-Contacts-Multi-Qty-/302022979912?var=&hash=item4651f8f148:m:mN4ox2cnSQkApzfqHF8OaWg
 

eggdweather

Senior Member
The manufacturer makes specific reference to relay states being affected during transportation; we are talking about the mono-stable types, but probably applies to both. I know first hand that packages are subject to g-shock, today I watched with bemusement the DPD delivery driver throw all manner of boxes around his van today before finding mine, those other packages would have endured much mechanical shock or G-force, they might have been relays, what was he doing... :)
 

Jeremy Harris

Senior Member
The relays arrived today and they seem to behave as I expected. Although they can be in either state as delivered, if they are pulsed to put them into, say "state A", and the relay is already in "state A", then nothing happens. When pulsed to put the relay into "state B" it changes state as expected. This means that the strategy I outlined in post #27 above, of initialising the relay into a known state with a single pulse of the right direction should work fine.

I'll try and breadboard up a Picaxe test circuit over the weekend to see what the limits are, and also to test using two Picaxe pins to drive either side of the coil, rather than a single pin and a large capacitor. As long as I fit back EMF diodes from the Picaxe pins to 0V then I think this should work, for applications where there are two spare pins available to drive the relay.
 

Jeremy Harris

Senior Member
I've just knocked up a breadboard and done some testing with an 08M2 and can confirm that both the single pin and two pin drive direct options work well for this relay type.

For the single pin test I used a 150uF capacitor (probably larger than needed, but it was to hand) in series with the relay. I used a single 1N4148 diode for back EMF protection from the Picaxe output pin to 0V. Setting the output high latched the relay into one state, setting it low latched it into the opposite state. Operation was very reliable and the quiescent current when the relay was in either state seemed to be just that of the 08M2, as far as I was able to measure (within about 1uA).

For the two pin test I connected the relay coil between two output pins, with 1N4148 back EMF protection diodes from both pins to 0V. I set both outputs low initially, then pulsed one to put the relay into a known "off" state, using the pulsout instruction. By sending a short pulse from either output pin I could set the relay on or off. As before the quiescent current when the relay was not operating seemed unchanged from that of the 08M2. I tested how short a pulse I could get away with, and the relay doesn't operate at 1ms, but gently clicks, it just about operates OK for 2ms pulses, but makes a much more "solid" sound when the pulse width is 2.5ms or greater. I would suggest that 2.5ms is the minimum pulse width needed for reliable operation at 5V.

If I can find some smaller capacitors later I'll see how small a capacitor can be used in the single pin version, as I'm sure that it could be a fair bit lower in value than 150uF and still work OK.

I've had the test circuit cycling every 2 seconds for around an hour now, and it's 100% reliable, so I am confident that this is a neat and reliable way to directly switch a high current (up to 2A) load directly from a Picaxe pin, with a minimum number of components and a low quiescent current.
 

AllyCat

Senior Member
Hi,

Thanks for the update. Beware that my analysis suggests that the "minimum" capacitor value might be anything between about 20uF and infinity, depending on the (undefined) characteristics of the PICaxe's pin-driver FETs. :(


... with a minimum number of components ....
For the minimum number of components you might omit the 1N4148. ;)

As I noted in #19, the Data Sheet Abs. Max. ratings include a 20 mA "Clamp" current, but I could find no clarification if this is a (repetetive) "pulse" or a "dc" rating. Of course it can be argued that it's better to be safe than sorry and install a 1p (penny/cent) diode, but Murphy's Law says that somebody will install it backwards. :)

I happen to be working on a "minimalistic" project myself at the moment and can't decide whether to rely on the internal clamp diode or not. :confused:

Cheers, Alan.
 

Jeremy Harris

Senior Member
It seems to be working fine on 10µF, no different to the 150µF that I first tried. I shall have to dig around and see if I can find anything smaller; I may have some 4.7µF capacitors around.

I'm not sure about leaving the back EMF diodes out or not. In theory the internal clamp current may be enough to damp any reverse spike, but for the sake of a really cheap and tiny component it's probably worth adding the diode to be safe.

I have it running with a 1 second "on", 1 second "off" cycle at the moment, with an initialisation bit of code that just sets the relay to the one state very briefly then to the off state, to make sure it's in a known state at start up.

Here's the test code:
Code:
;Single pin latching relay test
;tested with 10µF capacitor and works OK at 5V

#picaxe08M2

;set up relay output

symbol relay = C.2								;set latching relay direct drive output pin (active high)

init:

	pause 100									;100ms pause to allow power to settle
	high relay									;set relay high to charge capacitor
	pause 50									;hold charged for 50ms
	low relay									;turn relay to notional "off" state
	pause 4000									;pause is only there to check this has run OK band the green LED connected to the
											;relay "off" contact is illuminated to show it's in the "off" state 
	
main:

	high relay									;turn relay "on" and switch the red LED on with the contact to show this
	pause 1000									;leave relay on long enough to be able to measure quiescent current when capacitor has charged 
	low relay									;turn relay off by allowing capacitor to discharge through relay coil in the opposite direction
	pause 1000									;leave relay off for long enough to be able to measure quiescent current when capacitor has dicharged
	
	goto main									;loop back to run sequence again


END
and here's the schematic:

Test schematic - 1pin.JPG

The LEDs driven by one of the pair of relay DPCO contacts are only there to show the relay's state. I've also left out the programming connection and the needed serial input pull down, as I knocked this up on the AXE091 prototyping board (a very useful bit of kit indeed - mine was acquired as a project prize some years ago and has proved to be invaluable).
 
Last edited:

eggdweather

Senior Member
Now Jeremy has done some real-world measurements, the power needed to switch relay = 4.5v x 20mA for 2.5mS = 2.25mWatts

Charge Q needed to be held by C = 1/2xCxV^2 (Joules(*per second) or Watts), therefore: 0.000225=1/2 x C x V x V and where V = 4.5 and solving for C = 0.000225 x 2 / 4.5 / 4.5 = 22uF and allowing for C tolerances, it is probable that smaller values will work in individual cases, either that or the amount of power required to activate the relay is a lot less that specified. The 1mS pulse is an interesting boundary condition where the relay was receiving and beginning to respond at ~90uW (@ 4.5volts), requiring a C value of 10uF, so I suspect the 20mA is a nominal coil current and practically it requires say 10mA, reducing the C to 11uF, so 10uF would have been my revised value for a reliable switch, now validated through experimentation.
 

wapo54001

Senior Member
I've just knocked up a breadboard and done some testing with an 08M2 and can confirm that both the single pin and two pin drive direct options work well for this relay type.

For the single pin test I used a 150uF capacitor (probably larger than needed, but it was to hand) in series with the relay. I used a single 1N4148 diode for back EMF protection from the Picaxe output pin to 0V. Setting the output high latched the relay into one state, setting it low latched it into the opposite state. Operation was very reliable and the quiescent current when the relay was in either state seemed to be just that of the 08M2, as far as I was able to measure (within about 1uA).
I've just come across this thread and have a question regarding the 1n4148 diode for back EMF protection.

As I understand it, a conventional relay has continuous current flowing through the coil and, when power is removed, the magnetic field collapses causing back EMF. In the case of a latching relay, there is no currernt flowing through the coil when the power sourced is switched between +5 and ground and therefore no magnetic field to collapse and cause the EMF. Also, the resistance of the coil will limit current flow to a maximum of 20ma.

Is a protective diode still required?
 

AllyCat

Senior Member
Hi,

A "latching" relay still uses a magnetic field which will generate a back-emf when the field collapses (i.e. the current is broken). It's just that this can occur earlier (as soon as the relay has operated) and not when the relay is to be released. So in principle a flywheel diode is still required. It might be unnecessary if a capacitor is used in series with the coil (so that the current decays slowly) but its risky in case the driver "accidentally" turns off early (i.e. before the current flow has ceased).

However, if it's a single-coil latching relay (which is released by applying a reversed voltage to the coil) then you can't use a diode across the coil, so should use diodes on each "H bridge" output pin and/or another damping method (typically a R or R + C across the coil).

Cheers, Alan.
 

wapo54001

Senior Member
Hi,

A "latching" relay still uses a magnetic field which will generate a back-emf when the field collapses (i.e. the current is broken). It's just that this can occur earlier (as soon as the relay has operated) and not when the relay is to be released. So in principle a flywheel diode is still required. It might be unnecessary if a capacitor is used in series with the coil (so that the current decays slowly) but its risky in case the driver "accidentally" turns off early (i.e. before the current flow has ceased).

However, if it's a single-coil latching relay (which is released by applying a reversed voltage to the coil) then you can't use a diode across the coil, so should use diodes on each "H bridge" output pin and/or another damping method (typically a R or R + C across the coil).

Cheers, Alan.
Thanks for the reply, I've been using a single 08M2 pin with a single coil latching relay with a rather large capacitor -- 100uF -- and it works perfectly. It seems to me that charging of the series capacitor happens gradually through coil resistance and also discharges gradually through the same resistance. Couldn't see the point of a diode and also couldn't see how a diode could be inserted and still have the circuit work . . .
 

StefanST

New Member
... So in principle a flywheel diode is still required. It might be unnecessary if a capacitor is used in series with the coil (so that the current decays slowly) but its risky in case the driver "accidentally" turns off early (i.e. before the current flow has ceased).
... so should use diodes on each "H bridge" output pin and/or another damping method (typically a R or R + C across the coil).
Diodes are in the internal structure of the picaxe output pin
PICAXE_LATCH_RELAY2.png
 
Top