I will try and keep it short. I have a linear actuator (a motor basically), which I am trying to run in one direction for 1 second and then run in the other direction for a second. The issue is, I am doing this with a relay module which has two SPST relays, and I have just gone through 3 relay boards and somehow destroyed all three boards! The way that the boards fail is one of the relays (always the same one) will not switch to the NC position. Either these are all faulty boards or something about my setup is killing the relays.
Now, I have seen a few people online draw up a polarity switching diagram, and some people will have the input power going to the NC and NO pins on both relays and the motor input going to the common pin. I have also seen others draw the diagram with the motor pins going to the NC NO pins and the input power going to the common. In my head this is the same thing, but maybe this is where I am going wrong? This to me seems like exactly the same thing, just slightly different. I drew 2 diagrams to show the difference (excuse my MSpaint drawing, but it gets the point across).
Does anyone know why these modules keep failing after running for an hour? Maybe I just bought cheap ebay parts, or is there some sort of quick moment of short circuit burning up the inside of the relay?
Please post the code.
All relays have a limited life, a number of operations. Exceeding that the relay will stop working.
Post a link to the datasheet of the motor, and if possible, for the relay. Sales sites are uninteresting. Is the motor current exceeding the relay specs?
Thanks for that! I will try an H-bridge. Any idea why the relay solution was failing? It would work perfect for about an hour, then the relay would fail to return to the NC position, even with no power connected (so basically, a physical failure).
Know that the reaction time of the relay switching to "On" very likely is faster than switching to "Off". That makes Your create a short short circuit when switch both relays at the same time! Depending on the power this will give short mmoments of full power supply current passing the relay contacts.
That "another method" does not.
Depending on the load the stall current will likely be higher then the rating of the relay spec. Know that Chinese ratings are often too high, like double the actual capacity.
With both relays off (coils not energised), the motor will run forward.
With both relays on (coils energised) the motor will run reverse.
With one relay off and one relay on, there will be a short-circuit from +12 to -12 through the relay contacts.
You have no way to stop the motor, except by causing the short-circuit.
With this code
There will be a brief moment (a few microseconds) where one relay is on and the other is off, causing the short circuit. Even if you can change both pins at the same instant, there is no guarantee that the relay contacts will move at the same speed.
So what do you suggest I do? Wire it up in the "another method" configuration, use an H-bridge, or something different which will support the 3.2 amps? Thanks for all the help guys!
That other method is actually an h-bridge. It's a mechanical H-bridge but you can also get electronic ones.
The electronic ones have the advantage that there is no clicking noise, they don't wear out as relays eventually do (even when wired correctly) and you can also use them to control both the direction and the speed of the motor.
There are many models of electronic h-bridge available. Pololu have a good range. Avoid those based on L293 or L298 chips, which are an old and inefficient design.
when you pass a current through a wire you generate a magnetic field. this magnetic field is like a can around the coil
when you open the current path the magnetic field collapses, inward. this inward collapse is a motion of the magnetic field
when you pass a magnetic field through a wire you generate a current
this current is opposite in polarity from the current that generated it
the voltage produced by the current induced is not proportional to the voltage that created the magnetic field. It is proportional to the current developed by the collapsing magnetic field, and the rate of collapse, with an open circuit, there is nothing to snub the discharge of the current, and the rate of collapse is colossal
the reverse voltage caused by a 6 volt 1968 Triumph ignition coil primary magnetic field collapsing is -321 volts
that 321 volts jumps the gap and burns the contacts when the points open.
see youtube videos about DC circuit breakers for solar systems
an H bridge provides a current path for the spike induced by the collapsing field. the semiconductor is a resistor, and that slows the collapse and absorbs the shock.
Relay can't handle the stall current of the motor.
or
You forgot to use diodes across the motor.
The resulting back-emf spikes of the motor could weld the contacts together.
You can probably get relay function back by hitting them with e.g. the handle of a screwdriver.
Adding a bridge rectifier across the motor kills the back-emf spikes.
AC terminals to the two motor contacts, + to motor supply, - to motor supply ground.