Does a 14M2 deliver more current than an 08M2?

wapo54001

Senior Member
I use Picaxe chips to build control circuits for the audio preamps, volume controls, etc, that I design.

For some time now I have successfully been using a 14M2 chip to drive 5V telecom latching relays to switch line-level inputs and outputs. The coil resistance is 250 ohms and the 'must switch' voltage is around 3.7 volts. I parallel two pins to double the current (though I don't use load balancing resistors) so theoretically I get 50mA capability to deliver 20mA. When switching relays between high and low states I always set both pins first to 'input' and then both to high or low depending on need.

The relay specs say it switches in 4ms, and I use a 120uF capacitor and tried 220uF between the relay and ground to provide the drive when I want to reverse the relay. With a 14M2, this works very well using combinations of C.4 & B.1, and C.0 & B.5, but I can't get this method to work with an 08M2 using C.4 & C.1. I have tried a number of different routines with no luck -- the terminal shows the 08M2 is switching high/low as I command as does voltage output from the chip on the drive pins but the relay does not move. I have tried two different relays (same type) and two 08M2 chips without success.

I am down to the idea that the 08M2 cannot deliver the power needed to move the relay, I can't think of anything else. Wonder if anyone has an opinion.


Code:
;Delay and Mute 12 PCB

; When relay is ON the audio is NOT muted.
; Change SYMBOL "Delay_Value" to set startup delay time in milliseconds

;Picaxe 08M2 Pinout
;Pin1 = +V
;Pin2 = C.5 (In, Serial In)
;Pin3 = C.4 (Touch/ADC/Out/In)
;Pin4 = C.3 (In)
;Pin5 = C.2 (In/Out/ADC/pwm/tune/SRQ/hi2c sda)
;Pin6 = C.1 (In/Out/ADC/hserin/SRI/hi2c scl)
;Pin7 = C.0 /Serial Out/Out//hserout/DAC)
;Pin8 = 0V

#Picaxe 08M2
#No_Data
SETFREQ m4

'Make all I/O pins inputs initially
Input C.4
Input C.2
Input C.1

'****************************************************************
'Set startup delay period here
SYMBOL PAUSE_Duration = 3500 'time in milliseconds 1/1000 second
'****************************************************************

;Pin assignments
;Control Inputs
SYMBOL Power_Good = pinC.3 '1=good 0=low
SYMBOL Mute_Switch = pinC.2 '0=muted 1=unmuted
;Audio Output (Relay1) Control
SYMBOL Rel_CtrlA = C.4
SYMBOL Rel_CtrlB = C.1

;variables storage
SYMBOL Power_State = b0 '24V Power 1=good 0=off
SYMBOL Muted = b1 'Muted Switch 0=muted 1=unmuted

'Delay for turn-on thumps and bumps to subside then enable output
PAUSE PAUSE_Duration '(NOTE - set duration above)

;Initialize relay position
'Cycle Output relay and start unmuted
GOSUB Rel_Ctrl_ON
PAUSE 50
GOSUB Rel_Ctrl_OFF
PAUSE 50
GOSUB Rel_Ctrl_ON


'Start main program loop to control input select and monitor power.
Main:

'check to see if power has been removed; if yes, shut down preamp
Power_State = Power_Good
IF Power_State = 0 THEN 'power is OFF
    GOTO POWERFAIL 'restart the program including initial delay
ENDIF

'check position of "Mute" switch
Muted = Mute_Switch
IF Muted = 0 THEN
    GOSUB Mute_Audio
ENDIF

'Troubleshooting send data to terminal only if needed
'SERTXD ("Power & Mute Status ",#b0," ",#b1,13,10)

'Loop
GOTO Main


'Restart control chip if power fails
POWERFAIL:
'Troubleshooting send data to terminal only if needed
'SERTXD ("Power Failed!!! ",13,10)
GOSUB Rel_Ctrl_OFF 'immediately mute the output
PAUSE 3000 'avoid dealing with rapid power changes if present
RESET        'Restart the program


'Mute switch ON routine
MUTE_AUDIO:
GOSUB Rel_Ctrl_OFF
DO WHILE Muted = 0
    Muted = Mute_Switch
'Troubleshooting send data to terminal only if needed
'SERTXD ("Audio Muted ",#b0," ",#b1,13,10)
LOOP
GOSUB Rel_Ctrl_ON:
RETURN

    
'Relay switching subroutines
'Always make both pins "input" before changing their output state to avoid conflicting states

Rel_Ctrl_OFF:
Input Rel_CtrlA
Input Rel_CtrlB
PAUSE 10
Low Rel_CtrlA
Low Rel_CtrlB
RETURN

Rel_Ctrl_ON:
Input Rel_CtrlA
Input Rel_CtrlB
PAUSE 10
High Rel_CtrlA
High Rel_CtrlB
RETURN
 

Attachments

AllyCat

Senior Member
Hi,

AFAIK, the often quoted "25 mA" is an Absolute Maximum Rating, not a Guaranteed (Measured) Parameter . Also, there appears to be a lot of "Cut and Paste" in the Microchip data sheets, so there might be some practical differences between "Real" chips.

Note that the Output pin drivers (FETs) always have a "Stronger" Pull-Down current compared with Pull-Up and the maximum available currents fall dramatically below the nominal 5 volts supply rail. Personally, I nearly always use the Output Drive characteristic graphs from Section 31 of the relevant Microchip base data sheet, for example here are the graphs at Vdd = 3 volts, which I have posted previously. Not much sign of 25 mA there, unless you want to Pull-Down at -40 degrees C. ;)

PICaxeOutputs3v.jpg

Normally, I would have expected the 08M2 to be comparable or even slightly better than the 14M2 in current-drive capability, but I do note that the minimum supply voltage for the 08M2 is rated at about 2.2 volts, compared with 1.8 volts for the other M2 chips. So it does appear that the "Diffusion" (manufacturing process) or "Design Rules" (and thus FET parameters) may be rather different between these two families of chip ?

Cheers, Alan.
 

wapo54001

Senior Member
Hi,

AFAIK, the often quoted "25 mA" is an Absolute Maximum Rating, not a Guaranteed (Measured) Parameter . Also, there appears to be a lot of "Cut and Paste" in the Microchip data sheets, so there might be some practical differences between "Real" chips.

Note that the Output pin drivers (FETs) always have a "Stronger" Pull-Down current compared with Pull-Up and the maximum available currents fall dramatically below the nominal 5 volts supply rail. Personally, I nearly always use the Output Drive characteristic graphs from Section 31 of the relevant Microchip base data sheet, for example here are the graphs at Vdd = 3 volts, which I have posted previously. Not much sign of 25 mA there, unless you want to Pull-Down at -40 degrees C. ;)

View attachment 25395

Normally, I would have expected the 08M2 to be comparable or even slightly better than the 14M2 in current-drive capability, but I do note that the minimum supply voltage for the 08M2 is rated at about 2.2 volts, compared with 1.8 volts for the other M2 chips. So it does appear that the "Diffusion" (manufacturing process) or "Design Rules" (and thus FET parameters) may be rather different between these two families of chip ?

Cheers, Alan.
Alan, as always a wonderfully concise and precise analysis -- way beyond my limited knowledge, so thank you for expanding my understanding.

Somewhere along the way I think I learned that the Picaxe published per-pin current capability was 20mA with 25mA the absolute maximum.

My power is an LM340LAZ-5 delivering a measured 4.93V so voltage should not be a problem. The relay coil is a measured 260 ohms so current draw should be 18.96mA. I've replaced both the relay and the 08M2 with no change, I've replaced the 120uF capacitor in the circuit with a 220uF, also without effect. My code is a simplified version of what I use with the 14M2 (the 14M2 handles some input switching as well), so it feels like the 08M2 (first time use this way) is not capable of delivering 20mA for 4ms with two pins participating. I have also played with the PAUSE timings between operations and that didn't help either. I guess I will build a second PCB with all new parts to see if that fixes the problem, nothing to lose and it feels like a last resort. Space is always at a premium and I'd rather not use a 14 DIP for this simple application.
 

inglewoodpete

Senior Member
The problem you have is associated with the dymanic performance differences between the (silicon of the) two chips. To see what is actually happening, you would need to look at storage oscilloscope traces of the voltages and implied currents.

The parameter missing from the static theory is time.
 

wapo54001

Senior Member
The problem you have is associated with the dymanic performance differences between the (silicon of the) two chips. To see what is actually happening, you would need to look at storage oscilloscope traces of the voltages and implied currents.

The parameter missing from the static theory is time.
I used a capacitor time-to-charge calculator to determine if the voltage would be high enough for long enough to provide the appropriate voltage/current for the requisite (specified) time and exceeded the requirement by three or four times at 120uF and much more at 220uF. Of course, I did assume a 'reasonable' switching time for the 08M2 pins. With voltage and current, the relay should switch in 4ms. Sadly, I don't have a storage 'scope to confirm the theoretical values.
 

hippy

Technical Support
Staff member
I would have expected the 08M2 to be comparable with the 14M2, both capable of delivering 20mA through an output pin.

In fact the 08M2 seems to be better than the 14M2 in that the datasheets show its output high voltage drops to just over 4V at 20mA, 4V5 at 10mA, the 14M2 to just 3V at 20mA, just over 4V at 10mA.

So why it works with a 14M2 but not an 08M2 is something of a mystery.

It would be interesting to hear what output voltages you are seeing with both chips.

When setting two outputs high or low sequentially, as in your code, one will have to take the burden of full in-rush before the other takes up half of it. The time between sequential setting should be short but could prove problematic in some cases. The solution there would be to uses 'OutPinsC=' to set the pins simultaneously - but one has to ensure other output pins are left as desired.

That you were using C.4 and B.1 suggests this isn't however the problem because those can never be set simultaneously. If sequential works for 14M2 it should work for 08M2.

It could come down to current rating per port, the 14M2 sourcing through two, the 08M2 through one, but the datasheets suggest not.

As it's a latching relay - "No idea". The 'capacitor inline' theory seems fine but I have no idea what will be happening in practice, how the relay will actually behave as voltage and current varies.

I don't think there's going to be any easy way to figure out what is happening without a storage scope, and even if it can be explained there may be no easy solution.

Rather than try and figure it out, it might be easier to drive the latching relay through a H-bridge as would normally be recommended.
 

hippy

Technical Support
Staff member
Somewhere along the way I think I learned that the Picaxe published per-pin current capability was 20mA with 25mA the absolute maximum.
That 25mA is the absolute maximum per pin as stated in the datasheets. There are other per port and per chip ratings collated here -


Whether that 25mA is an absolute maximum is hard to say, one would need to read the small print in the datasheet, but more likely an absolute maximum for sustained current.

Higher current for a very short period of a time is unlikely to observably affect a chip as it is internal heating, power dissipation, which causes the damage. That's what LED and 7-seg multiplexing without current limiting resistors rely upon; huge current but only for a short time.

Likewise the relay probably requires some 'oomph' which isn't exactly as described by voltage and current when one is using a capacitor instead of a fixed power rail. That 'time domain' mentioned and other effects may come into play. If an output is delivering a low voltage at high current for a while it will charge up the capacitor and may ultimately take it to fully charged without ever having put the necessary differential voltage through the coil, never supplying enough 'oomph' or not for long enough.
 

inglewoodpete

Senior Member
As an experiment, short circuit the series capacitor to see if the 08M2 has enough drive to latch the relay. Of course, not allowing the capacitor to charge will not allow you to unlatch it, as the capacitor's charge would normally be used to do this.
 

wapo54001

Senior Member
OBE.

With the assurances from hippy that the 08M2 was just as capable as the 14M2, I built another board using new components exactly as originally designed and it works exactly as expected and as the 14M2 boards work.

One thing I did not troubleshoot with the first board was the (obviously impossible!) possibility that the negative side of the capacitor was not connected to the ground plane. Well, it wasn't. :( It's a tiny pad and I can't see it now due to solder but the other four boards in my order all show the requisite tiny four fingers connecting the pad to the plane. Either I somehow destroyed the connection when soldering or they weren't connected even though they are on the other boards.

I killed parts of two days fighting this, but am so glad that ultimately it works. I very much appreciate the help I got on this -- the feedback and confirmation that it probably wasn't the chip pushed me in the right direction to figure it out. Thanks to all.
 

erco

Senior Member
Glad you got it sorted out. I'm also a fan of using direct-drive low current relays and also latching relays. I noticed that your latching relay relay uses one coil, which uses reverse polarity to latch/unlatch. Doesn't that preclude using flyback diodes across the coil? If so, you may have zapped your 08M2's output pins with a high voltage spike.

Alternatives are using a latching relay with 2 coils with flyback diodes, or a standard relay with a flyback diodes using a mosfet switch. 50X 2N7000s are cheap and easy to use.
 

tmfkam

Senior Member
Glad you sorted it finally.

I might have tried putting a 14M2's top eight pins in the 08M2's place, then trying to perform the same function with that. I've had to do "reality" checks like this way to often. It is the Sherlock Holmes method of fault finding, first eliminate the possible causes, then you're left with the impossible ones.
 

wapo54001

Senior Member
Glad you got it sorted out. I'm also a fan of using direct-drive low current relays and also latching relays. I noticed that your latching relay relay uses one coil, which uses reverse polarity to latch/unlatch. Doesn't that preclude using flyback diodes across the coil? If so, you may have zapped your 08M2's output pins with a high voltage spike.

Alternatives are using a latching relay with 2 coils with flyback diodes, or a standard relay with a flyback diodes using a mosfet switch. 50X 2N7000s are cheap and easy to use.
When I first learned about using a capacitor with a latching relay in this way, it was my understanding that a diode was not required because the non-instantaneous charge/discharge time of the capacitor through the DC resistance of the coil prevented the magnetic field from suddenly collapsing which is what generates the damaging pulse. Thus, no diode is required and actually would prevent the circuit from working properly.

A mosfet switch won't work here because it can shut off current but cannot reverse it which is a requirement. Using a mosfet is actually the situation where a protection diode is required due to the sudden cutoff of current resulting in magnetic field collapse and the exposure of the semiconductor to the high voltage spike. At least that's my limited understanding of it.
 

AllyCat

Senior Member
Hi,
Doesn't that preclude using flyback diodes across the coil?
Yes, it precludes connecting external diodes directly across the coil, but there are already "electrostatic protection" diodes inside the PICaxe package, to supply and ground, across all I/O pins. It is actually these diodes that are rated at up to 20 mA, whilst the FETs are rated at 25 mA, both "Absolute Maximum", so driving the above relay coil does look "safe".

However, the 120 uF capacitor is not exactly "generous"; it has a time constant with the relay of 120u * 250 = 30 ms, so in 4ms the voltage across the capacitor will change by about Vdd / 7.5 or approaching a volt. Then you must remember that the pins are not driven by "perfect" (e.g. metal) switches, but by FETs which are effectively a "variable resistor". That resistance can be calculated from the data sheet curves as above, e.g. Ron = 1.5 v / 15 mA = 100 ohms). Also, do the relay "must switch voltage" and "4 ms operating time" apply under the same test conditions, i.e. at the same time? For example, a transistor might be "specified" to 50 volts and 2 Amps, but applying 50 v at 2 A = 100 Watts may well Release the Magic Smoke. ;)

As you are using two pins anyway, an alternative arrangement could drive the coil in an H Bridge, as suggested by hippy, and remove the need for the capacitor, but the operation is again quite "marginal". The coil actually requires 3.7 v / 250 ohms = 15 mA, but some of the supply voltage is "lost" across both one pin Pulling-Up and the other Pulling Down. Note that the PIC data sheet shows the Output Voltage characteristics at 5.5 volts, but the "Typical High" output voltage is shown relative to Ground (4.5v @ 15 mA), so the upper FET drops around 1 volt (i.e. Vout = 3.93v at your measured Vdd = 4.93v). The "Typical Low" pin at 15mA appears to be about 0.25v, so the actual voltage across the relay coil might be as low as 3.68 volts.

Stop Press: Ah yes, the capacitor decay of the relay current should prevent "voltage spikes", but I wouldn't rely on that alone, for example in case the PICaxe spontaneouly Resets for any reason. :(

Cheers, Alan.
 

wapo54001

Senior Member
Hi,

Yes, it precludes connecting external diodes directly across the coil, but there are already "electrostatic protection" diodes inside the PICaxe package, to supply and ground, across all I/O pins. It is actually these diodes that are rated at up to 20 mA, whilst the FETs are rated at 25 mA, both "Absolute Maximum", so driving the above relay coil does look "safe".

However, the 120 uF capacitor is not exactly "generous"; it has a time constant with the relay of 120u * 250 = 30 ms, so in 4ms the voltage across the capacitor will change by about Vdd / 7.5 or approaching a volt. Then you must remember that the pins are not driven by "perfect" (e.g. metal) switches, but by FETs which are effectively a "variable resistor". That resistance can be calculated from the data sheet curves as above, e.g. Ron = 1.5 v / 15 mA = 100 ohms). Also, do the relay "must switch voltage" and "4 ms operating time" apply under the same test conditions, i.e. at the same time? For example, a transistor might be "specified" to 50 volts and 2 Amps, but applying 50 v at 2 A = 100 Watts may well Release the Magic Smoke. ;)

As you are using two pins anyway, an alternative arrangement could drive the coil in an H Bridge, as suggested by hippy, and remove the need for the capacitor, but the operation is again quite "marginal". The coil actually requires 3.7 v / 250 ohms = 15 mA, but some of the supply voltage is "lost" across both one pin Pulling-Up and the other Pulling Down. Note that the PIC data sheet shows the Output Voltage characteristics at 5.5 volts, but the "Typical High" output voltage is shown relative to Ground (4.5v @ 15 mA), so the upper FET drops around 1 volt (i.e. Vout = 3.93v at your measured Vdd = 4.93v). The "Typical Low" pin at 15mA appears to be about 0.25v, so the actual voltage across the relay coil might be as low as 3.68 volts.

Stop Press: Ah yes, the capacitor decay of the relay current should prevent "voltage spikes", but I wouldn't rely on that alone, for example in case the PICaxe spontaneouly Resets for any reason. :(

Cheers, Alan.
Through trial-and-error I have found that although the relay might switch in 4ms, the state of the capacitor must be considered, it needs to be adequately charged or discharged to prepare for the next activation and to be entirely reliable a PAUSE is needed after each activation so that the Picaxe has adequate time to set the capacitor for the next action. In particular, in the initialization sequence I switch the relay ON then OFF then ON again to be sure the relay and Picaxe are in sync. Doing that too quickly leaves the relay in an uncertain state so I PAUSE 50 after each command.

Question re the 'not exactly "generous"' 120uF -- what value capacitance would you recommend in this case? The 120uF was a guess & trial-and-error decision, not calculated (I don't do math!).
 

wapo54001

Senior Member
Stop Press: Ah yes, the capacitor decay of the relay current should prevent "voltage spikes", but I wouldn't rely on that alone, for example in case the PICaxe spontaneouly Resets for any reason. :(

Cheers, Alan.
I don't understand this -- how would a reset be hazardous to the Picaxe?
 

AllyCat

Senior Member
Hi,

When the PICaxe switches the Relay ON, the pulse of current that it (or the Relay Load) might put on the supply rail could cause a "spike" and cause the PICaxe to Reset. The Reset switches all the PICaxe Outputs OFF, so the current flowing in the Relay coil (Inductance) would need to find an alternative path, and will generate a large voltage spike to create one, if necessary ! The protection diodes within the PICaxe should be sufficient, but an "unprotected" external FET or Bridge might fail. The protection diodes only need to feed the inductive energy (e.g. 15 mA current) back into the supply decoupling capacitor (so dissipate around 10 mW), whilst a Transistor breaking down at say 70 volts could be hit by over a Watt. :(

The full design of your "boost capacitor" circuit is quite complex, particularly as data sheets rarely give the actual operating voltages/currents that you're using. The "Typical" (Green) curves in the graphs in #2 above at only 3 volts are too pessimistic for use at 5 volts, so for simplicity here, I'll use the Red line for VOH and Blue for VOL and then we can also ignore any variations caused by temperature and component tolerances, etc.. With two drive pins in parallel, the required (minimum) drive current is about 8 mA through each pin, so the HIGH switch level might be about 5v - 0.7 = 4.3 volts and the LOW switch level about 0.3 volts. Thus there is about 4 volts effective drive (voltage swing) for the Relay coil.

The "Time Constant" basically indicates how long the capacitor would take to fully charge (or discharge) IF the current continued at its initial value (but it doesn't, because the effective voltage changes). However, it's useful if we use time periods which are "quite small" or "quite large" compared with the Time Constant, where "quite" means typically 5 times smaller or larger, as appropriate.

Therefore the (4ms) pulse is sufficiently short compared with the 30 ms TC that we can assume that the capacitor will charge (or discharge) by only about 4/30 = 12% of the supply rail, so the average driving voltage will be about 6% lower than the starting (i.e. "fully" charged or discharged) voltage. Thus the 4 volts drive from the paragraph above becomes about 3.76 volts, which appears to be sufficient to drive the Relay, provided that the capacitor starts at its fully charged or discharged state.

However, to reach a "final" state of charge/discharge needs at least five times the Time Constant, or say 150 ms (for the 120 uF capacitor), which is probably the more critical condition in this application. Therefore, a PAUSE 50 appears to be too short and I would recommend at least a PAUSE 150 (ms), or equivalent, with the 120 uF capacitor, and PAUSE 250 with a 220 uF capacitor.

Cheers, Alan.
 

wapo54001

Senior Member
Wow, lots to think about.

Up to now, I've assumed the bigger the capacitor the more reliable the circuit's switching will be. Over this conversation I've come to realize that the change in capacitor charge level over time is also important when activation duration is time limited. Mostly, in real life a relay state is changed and then doesn't change again for a considerable time and that allows the Picaxe to completely charge or discharge the capacitor long after the relay has moved and capacitor size is not important as long as it is big enough. However, at one point at system initialization I switch the relay three time in rapid succession -- ON-OFF-ON -- to ensure the relay status is in line with switch positions. At this one moment in the process there are two requirements, first that the switching happen as fast as possible to avoid an annoying start-stop-start of the audio through the system, and second that the switching happen as intended with great reliability. At this one point I think the size of the capacitor is important and bigger is not necessarily better.

Over the past decade I have used this circuit with 14M2 chips extensively and the 120uF value has been very reliable but the rapid switching described above has been a bit of an annoyance (you can hear the on/off/on in the audio) and I've just put up with it. At this point I'd like to experiment with smaller capacitor values with the goal of keeping switching reliability where it is now while minimizing the PAUSE duration required after switching. So, the capacitor must be big enough to reliably switch and yet small enough to reach full charge or discharge as soon as possible after switching.
 

AllyCat

Senior Member
Hi,

Do you have a data sheet link for the Relay? It seems strange that it can get "out of phase" with the PICaxe, but perhaps it uses a permanent magnet that is strong enough to "Hold" (if closed) the Relay's armature (which moves the switched contacts), but not to "Operate" it (from the open state). Then the electromagnet (coil) assists the magnet to Operate the Relay, or cancels (reduces) the magnetic field to release the armature.

A way to allow the Relay to be operated at the fastest rate would be to use an H-Bridge driver as in #13, since no time delay (capacitor) is involved. Although I described the design as "marginal", it does appear to be within the probable "worst case" tolerances. However, if the 120 uF Capacitor-Coupled circuit (with a 30 ms Time Constant) is operated with only a 50 ms "recovery" PAUSE, then the capacitor will be (dis-)charged to only about 80% of its "final" value, which appears to be significantly outside the "guaranteed" (or must) operate region:

If we assume that the Relay requires a 4 ms pulse with an amplitude of 3.7 volts (from #1), then we can afford to "lose" 1.3 volts from a 5 volt supply rail. I believe 3 elements contribute to this voltage drop: Firstly, the PICaxe pins' Pull-Up FET is specified to drop up to ~0.7 volt at 8mA (assuming two pins are used as in #16). Secondly, if we make the Time Constant 5 * 4 = 20 ms, then the voltage across the capacitor drops by 1 volt (i.e. 20%) after 4 ms, so the average loss would be 0.5 volt. That leaves only 0.1 volt (or 2% of the supply) for the third loss, which is the voltage remaining across the capacitor at the end of its "recovery" period, or the PAUSE, time. To reach 98% of the final (target) value takes approximately 4 * the Time Constant, or 80 ms, which would be my minimum recommended period.

To achieve a nominal 20 ms Time Constant in association with the 250 Ohm Relay resistance would use an 80 uF capacitor, or maybe slightly lower capacitor (e.g. 64 uF) if we take into account that the PICaxe output pin drivers add about 700 mV / 16 mA = 40 Ohms to the series resistance. However, a 100 uF capacitor will probably make little difference, because the average pulse amplitude will be slightly larger, but the residual voltage (loss) across the capacitor at the end of the Pause also will be greater. There are further factors which I haven't described, but they probably also cancel each other out, a matter of "Swings and Roundabouts".

To summarise, for "guaranteed" operation, it looks as if the PAUSE should be at least 20 times the required pulse width (i.e. 80 ms), with the Time Constant set to about 5 - 8 times the pulse width (i.e. C = 80 to 120 uF), or you should use the H-Bridge idea. ;)

Cheers, Alan.
 
Last edited:

wapo54001

Senior Member
Hi,

Do you have a data sheet link for the Relay? It seems strange that it can get "out of phase" with the PICaxe, but perhaps it uses a permanent magnet that is strong enough to "Hold" (if closed) the Relay's armature (which moves the switched contacts), but not to "Operate" it (from the open state). Then the electromagnet (coil) assists the magnet to Operate the Relay, or cancels (reduces) the magnetic field to release the armature.

A way to allow the Relay to be operated at the fastest rate would be to use an H-Bridge driver as in #13, since no time delay (capacitor) is involved. Although I described the design as "marginal", it does appear to be within the probable "worst case" tolerances. However, if the 120 uF Capacitor-Coupled circuit (with a 30 ms Time Constant) is operated with only a 50 ms "recovery" PAUSE, then the capacitor will be (dis-)charged to only about 80% of its "final" value, which appears to be significantly outside the "guaranteed" (or must) operate region:

If we assume that the Relay requires a 4 ms pulse with an amplitude of 3.7 volts (from #1), then we can afford to "lose" 1.3 volts from a 5 volt supply rail. I believe 3 elements contribute to this voltage drop: Firstly, the PICaxe pins' Pull-Up FET is specified to drop up to ~0.7 volt at 8mA (assuming two pins are used as in #16). Secondly, if we make the Time Constant 5 * 4 = 20 ms, then the voltage across the capacitor drops by 1 volt (i.e. 20%) after 4 ms, so the average loss would be 0.5 volt. That leaves only 0.1 volt (or 2% of the supply) for the third loss, which is the voltage remaining across the capacitor at the end of its "recovery" period, or the PAUSE, time. To reach 98% of the final (target) value takes approximately 4 * the Time Constant, or 80 ms, which would be my minimum recommended period.

To achieve a nominal 20 ms Time Constant in association with the 250 Ohm Relay resistance would use an 80 uF capacitor, or maybe slightly lower capacitor (e.g. 64 uF) if we take into account that the PICaxe output pin drivers add about 700 mV / 16 mA = 40 Ohms to the series resistance. However, a 100 uF capacitor will probably make little difference, because the average pulse amplitude will be slightly larger, but the residual voltage (loss) across the capacitor at the end of the Pause also will be greater. There are further factors which I haven't described, but they probably also cancel each other out, a matter of "Swings and Roundabouts".

To summarise, for "guaranteed" operation, it looks as if the PAUSE should be at least 20 times the required pulse width (i.e. 80 ms), with the Time Constant set to about 5 - 8 times the pulse width (i.e. C = 80 to 120 uF), or you should use the H-Bridge idea. ;)

Cheers, Alan.
The only time that this is an issue is at startup when I move the relay on-off-on in rapid succession, all other times there naturally will be very long pauses between relay movements and the size of the capacitor and the pause time can be overkill without affecting operation. At startup, however, if the music source is already playing and the power amp is already on, a long delay between operations causes the audio to stutter for a moment which is not desirable.

By 'out of sync' I mean the possibility that due to a too-fast (for the capacitor to charge adequately) switching of the Picaxe between states the relay could wind up in a state that differs from that of the Picaxe. I have been using 120uF and 100ms in past iterations of this circuit and that has worked reliably but with the noticeable momentary stutter in the sound at startup.

I also tried 75ms and it seems to work well and there is an improvement in the stutter. I'd love to take it further but I share this circuit with fellow audio DIYers who are not programmers and so the program needs to be reliable as-is so I guess I'll keep it at 100ms for sharing and play with shorter pauses in my own system.

Wait! Talking this through has been very useful. It struck me that I could make other changes -- have now divided the three relay actions into two parts -- first a high-low sequence with 100ms after the high, then the speaker-protecting 3800ms pause between the low and final high. This pretty much makes the whole issue go away. I'm now a happy camper and again appreciative of the help in thinking this through. And also appreciative for the better understanding of the impact of the RC calculation. :)
 

hippy

Technical Support
Staff member
The only time that this is an issue is at startup when I move the relay on-off-on in rapid succession
One solution might be to wire the relay coil so when power is first applied the capacitor will be discharged, a high on the controlling output pins will force the raly it to its off position or do nothing if already there, charging the capacitor, then making those outputs input.

Turning the relay on would mean taking the output high, charging the capacitor which won't change the relay from off, holding until the capacitor is charged, making output low, discharging the capacitor which should turn the relay on, then making the outputs input.

It seems to me that could work.
 
Top