relay timing and suppression issues

Status
Not open for further replies.

rotabox

Well-known member
hy im working on kind of complicate project that drives 28 relays of R2R net witch is 2 balanced audio channels.
7 relay for each phase for 128 binary steps like an adc.
im using teensy 3.5 to control them and im connected to pins 40 > 46.
in beginning i start to run a simple code to test is but i got some fast peaks and drops in some same steps on the binary series.
i played with the code and read some info about speed an interrupts so i take down the priority of interrupts from example

in that way: SCB_SHPR3 = 0x20200000; // Systick = priority 32 (defaults to zero).

i hope i did it right... allso im using FASTRUN and i rise up the cpu to max speed.
it gives me a better precision for the relay timing action and i see it on my scope.
i still got some peaks but less with this code im using now and about 13 nf cap between phase and gnd. theres is still peaks for example when switching step 63 to 64.
6 relays r getting closed and the 7 is opened there is still peaks on those steps that switching few relay at onece.
with this code i m getting half of the peak levels with minimum drops.
i tryd to use some micro delay between actions to see if its helps but i figure out the any delay or timing should but different for the noizy
steps and i try to avoid using delay till i figure out the right method.
im using reed relays of 3ms time switching. im using resistor and transistor nets to control the relays and suppression diode for every 2 relays.
i read in few placed that adding a zener diode back to back to the suppression diode... it should work better for fast closing relays.. this can solve the problem?
here is the part code im using for drive the relays now
tnx for any help or suggestion to solve it.

Code:
// Relays Binary Postion Pins Control
FASTRUN void RelayBinNumber(int num) {
// order of pin on buses
// pin 42
// pin 40
// pin 41
// pin 43
// pin 46
// pin 44
// pin 45

if(num > PrvNum){
      Serial.println("UP");
      PrvNum = num;     
      for (int i = 0; i < 7; i++) {        
      digitalWriteFast(RelayVolpins[i], LOW);       
      if (num % 2){
      digitalWriteFast(RelayVolpins[i], HIGH);
      }
      num /= 2;    
      }
    }
    
      else if(num < PrvNum){
      Serial.println("DOWN");
      PrvNum = num;
      
      for (int i = 0; i < 7; i++) {   
    
      if (num % 2){        
      digitalWriteFast(RelayVolpins[i], HIGH);
      }else
      digitalWriteFast(RelayVolpins[i], LOW);  
      num /= 2;       
      }
    }
}
IMG_20210307_101421.jpg
 
im using resistor and transistor nets to control the relays and suppression diode for every 2 relays.
Every relay coil must have a snubber diode - otherwise you risk blowing up a transistor. Can you share your
circuit for the relay driving? Perhaps you have commoned up the relays in pairs? That would allow a single
diode.

The supply for the relay coils needs good decoupling, especially as you are switching several relays at once - you
haven't mentioned decoupling.

I don't understand what you mean by "about 13 nf cap between phase and gnd" - phase is live mains normally.

Yes you can use a diode back-to-back with a zener for faster turn off - or simpler just use a bipolar TVS diode with a
voltage rating somewhat higher than the supply voltage.
 
hy markT thanks for your replay.
every 2 relays commend buy 1 resistor and 1 transistor and 1 snubber/suppression diode like in schem i added.
im using isolated TRACO 220v AC DC convertor to 12v -->isolated DC DC 12v 2.5A convertor to drive all relays.
i got 10uf X7R cap and 1000uf from 12V line to gnd. what do you mean by saying The supply for the relay coils needs good decoupling?
the 13nf i used is between the output of the relay to the gnd thats make small low pass filter cos the line is for audio lines i cant put higher cap to keep
full scale from 0 to 22000kh the 13 nf cap cut a litel bit the hard peaks but my goal is to removed them and solved it in better way,
i measured the negative side of the coils and i noticed that the coils that switch the small resistance steps working smooth.
but the relays of higher resistance cos got peak and drops and peaks when voltage changed.
TVS diode should be the solution for that?

here is 1 of the relays sections schematic:
Screen Shot 2021-03-07 at 6.12.05 PM.png


here is my measure on the negative side of the coils of the first 2 relays:
IMG_20210307_183954.jpg


here is my measure on the negative side of the coils of the last 2 relays:
IMG_20210307_184122.jpg
 
I don't quite understand the application here but do the relays have the same make and break times? If not, it is likely that when you go from, say, 0110000 to 0001000 there is a period of 0111000 or 0000000? It makes sense that higher values are more pronounced - 0111111 to 1000000 might have a 1111111 in it. I think you will need a pretty aggressive LPF to filter those spikes out.

Why are you using relays for this? I would think you are better off powering an R2R network directly from your processor into a rail to rail op amp set up with a gain that gets you to 12V at full scale. Still needs an LPF though. But then, I don't understand the application, like I said earlier...
 
i read in few placed that adding a zener diode back to back to the suppression diode... it should work better for fast closing relays.. this can solve the problem?

I can't say whether it will solve all the problems you're seeing. But generally speaking, yes, if you want the relay coil to switch off at approximately the same speed as it turns on, you do need to add a zener diode. Or you can use multiple regular diodes in series.

With only a single regular diode, you'll only have about -0.7V across the coil while it is discharging (or dis-currenting or dis-fluxing). The inductor voltage to current relationship is V = L * di/dt. If you have different V, you get different di/dt rate of change in current. Well, of course that's assuming L is fixed and doesn't vary with self heating, and the coil follows an ideal inductor model, rather than the wire resistance, eddy currents, winding-to-winding capacitance and other non-ideal properties playing a significant factor.

So you want to choose your zener diode to be approximate Vcc - 0.7V, if matching on and off switching time is important.
 
The other thing you can do is drive the coil with much higher voltage while it's changing current, so the relay switch much faster. There are at least 3 established way to do this.

1: The simple & safe but inefficient way is to add a resistor in series with each coil, and increase your DC power supply voltage. For example, you might measure the DC resistance of those windings and choose a resistor that's 3X that number. Then you'd increase the voltage from 12V to 48V. Also use 48V zener diodes. The coils switch 4X faster. But you burn a lot of power in those resistors while they're on.

2: The almost-as-simple but risky way is use 2 power supplies. You drive the coil with a high voltage for a short time to get it to turn on fast, then switch to the lower voltage. The tricky part is tuning the drive time.

3: The safe & efficient but complex way involves PWM and a fancy control circuit which sense the inductor current.
 
In UP mode you always turns relays off before setting them to correct value, that will cause spikes

Code:
if(num > PrvNum){
      Serial.println("UP");
      PrvNum = num;     
      for (int i = 0; i < 7; i++) {        
      digitalWriteFast(RelayVolpins[i], LOW);       
      if (num % 2){
      digitalWriteFast(RelayVolpins[i], HIGH);
      }
      num /= 2;    
      }
    }

should probably be
Code:
if(num > PrvNum){
      Serial.println("UP");
      PrvNum = num;     
      for (int i = 0; i < 7; i++) {        
        if (num % 2){
          digitalWriteFast(RelayVolpins[i], HIGH);
        } else {
          digitalWriteFast(RelayVolpins[i], LOW);
        }
        num /= 2;    
      }
    }

or simply use
Code:
      digitalWriteFast(RelayVolpins[i], num % 2);
 
thank you for your replay PhilB
the relay path is for in line audio signal so any LPF must be 13nf related to 600ohm standards.
ill prefer to avoid them. its a passive control volume path for stereo balanced analog signal.
 
thank you paul for your quick replay.
ill try go for the zener method first (with a tvs diode) instead the regular diode to see how its improves the closing relay time and if it reduce the switching peaks in signal path .
about method 1 you mentioned im not quite understand how to calculate it but ill figure it out and ill try it if the tvs diodes alone will not give improvement in the relay timing.
for the 2 other methods you mentioned they are to complicated and expensive for this project and im trying to keep it simple as possible but ill keep them in mind if ill not gonna find any good other solution.
also another extra way to improved the timing is by adding some zero crossing detection to those methods . but if im understand things right still must be good suppression net for fast switching otherwise the relay will still response in some delay and the relay will miss the zero crossing.
tnx for your great help.
 
In UP mode you always turns relays off before setting them to correct value, that will cause spikes

Code:
if(num > PrvNum){
      Serial.println("UP");
      PrvNum = num;     
      for (int i = 0; i < 7; i++) {        
      digitalWriteFast(RelayVolpins[i], LOW);       
      if (num % 2){
      digitalWriteFast(RelayVolpins[i], HIGH);
      }
      num /= 2;    
      }
    }

should probably be
Code:
if(num > PrvNum){
      Serial.println("UP");
      PrvNum = num;     
      for (int i = 0; i < 7; i++) {        
        if (num % 2){
          digitalWriteFast(RelayVolpins[i], HIGH);
        } else {
          digitalWriteFast(RelayVolpins[i], LOW);
        }
        num /= 2;    
      }
    }

or simply use
Code:
      digitalWriteFast(RelayVolpins[i], num % 2);

thank you mlu for your replay
you right.
im guessing that right now its working better with my code that close all relay in UP mode before its opens the the others
its because the suppression diode not closing the relay fast enough so when i closed all of the relays before open other give some more time to the relay to be (real) closed
before the others r opened that way my code in this situation reduce a little bit the peeks.
 
The other thing you can do is drive the coil with much higher voltage while it's changing current, so the relay switch much faster. There are at least 3 established way to do this.

1: The simple & safe but inefficient way is to add a resistor in series with each coil, and increase your DC power supply voltage. For example, you might measure the DC resistance of those windings and choose a resistor that's 3X that number. Then you'd increase the voltage from 12V to 48V. Also use 48V zener diodes. The coils switch 4X faster. But you burn a lot of power in those resistors while they're on.

2: The almost-as-simple but risky way is use 2 power supplies. You drive the coil with a high voltage for a short time to get it to turn on fast, then switch to the lower voltage. The tricky part is tuning the drive time.

3: The safe & efficient but complex way involves PWM and a fancy control circuit which sense the inductor current.

hi paul
i tryd other solution for the audio passive path relay peaks and i add 1 more relay that control 1uf LPF in the r2r path for each phase.(im testing now only 1 phase)
the relay short 1uf cap from + or - (phase) to gnd 1ms before the r2r relays change to the new position. and after that i give 1ms delay and then it release the LPF relay.
so its about 2ms LPF between steps.
here is the result when im rise up the encoder
IMG_20210310_175934.jpg

all major peaks and drops r gone but i still need to test it with my studio sound monitor to see hows it feel.
i hope it will help others.
rota
 
info update:
I'm still reading about switching relay technics and I found this article. Cose no one mention it here I think its importent to add this info to this thread.
The point about relay speed related to current load. I use bjt transistors witch r current operated devices.
Quate: "the MOSFET switch is ideal as an electrical switch as it takes virtually no Gate current to turn “ON”, converting a Gate voltage into a load current. Therefore, a MOSFET can be operated as a voltage-controlled switch.

In many applications bipolar transistors can be substituted with enhancement-type MOSFETs offering faster switching action, much higher input impedance, and probably less power dissipation. The combination of a very high Gate impedance, very low power consumption in its “OFF” state, and very fast switching capability makes the MOSFET suitable for many digital switching applications. Also with zero Gate current its switching action can not overload the output circuit of a digital gate or micro-controller."

Here is the artical with the switching relays schematics methods.
https://www.electronics-tutorials.ws/blog/relay-switch-circuit.html

I'll try to replace all bjt's with mosfets to see the deference in the relay action. Any recommendations for fets for that propose beside irf610?
Rota
 
A mechanical relay is 3 to 5 orders of magnitude slower than a MOSFET or BJT, thus makes no difference at all
to swap BJT for MOSFET. And its not true that MOSFETs take "virtual no gate current", as for fast switching the
instantaneous gate current must be high (its only as DC the current is vanishing).

The switch-off speed is an issue that can be addressed by more advanced snubbing circuits than a
single diode, and switch-on can be speeded up by a short-term excess of voltage at turn on. Basically
the inductance of the winding is one limiting factor to the speed, as is the mechanical inertia - the inductance
can be compensated for somewhat, the mechanical inertia is a given.

The speed of the semiconductor switch is always going to be fast enough
 
A mechanical relay is 3 to 5 orders of magnitude slower than a MOSFET or BJT, thus makes no difference at all
to swap BJT for MOSFET. And its not true that MOSFETs take "virtual no gate current", as for fast switching the
instantaneous gate current must be high (its only as DC the current is vanishing).

The switch-off speed is an issue that can be addressed by more advanced snubbing circuits than a
single diode, and switch-on can be speeded up by a short-term excess of voltage at turn on. Basically
the inductance of the winding is one limiting factor to the speed, as is the mechanical inertia - the inductance
can be compensated for somewhat, the mechanical inertia is a given.

The speed of the semiconductor switch is always going to be fast enough

OK so please explain why when i messure the voltage drop when relay close with a bjt it's about 150ns drop in my scope and when I remove the bjt and drive the relay only with diode the voltage drop is about 100ns in my scop? If the the path to gnd is the time factor and fet do the work faster why it should not speed up the relay closing? It's not related to the bjt or fets rise and fall time when you want same speed for open closing relay? That not gonna improve the switching timing?
 
The difference between 150ns and 100ns is 50ns. A space vehicle only moves on the order of 1mm in that time. Typical relays
switch in around 5000000ns to 10000000ns (5--10ms) If you were able to switch the relay in 50ns its internal parts would have
to move about 100 times faster than a bullet.

The speed the relay closes depends on the force, which depends on the current, and the inertia of the parts. The current rises from
zero after switch on limited by the inductance of the coil and the voltage across it, and decreases back to zero on switch off again
dependent on the inductance and voltage across the coil. The electrical switch-on time-constant may be somewhere around 1ms
or so, the mechanical time constant more like 5 to 10ms.

The electrical switch-off time-constant depends on the voltage across the coil (with a simple free-wheel diode this is 0.8V or so),
and this can be a lot larger than the switch-on time-constant as this voltage is so small.

Compared to all this the speed of the switch is thousands of times faster or more - makes absolutely no difference - its all about
the mechanicals and the inductance.
 
Status
Not open for further replies.
Back
Top