Go Down

Topic: Arduino Uno as Amplifier and Speaker protection (Read 5745 times) previous topic - next topic

brlmat

Hello everyone!

I am extremely new to this topic. I have never had an arduino. My only coding experience is Pascal. I am coding in that @ school.

I am building a 250w stereo amplifier and i need some guidance regarding the protections. The main power button will switch both the amplifier and the arduino protection module on at the same time.

What i want to control with arduino:

- Power transformer softstart. Pretty much a relay (Relay1) should be switched on after ~ 1 sec after power on;
- Short circuit protection. This will be Relay2 which will switch off if current sensed on a current sensing resistor goes over a value using a comparator (Logic protection. The auxiliary circuit will pull the Sense_pin1  to ground in case of over current; else it's pulled to 5v) + LED1 flash @ 15Hz. This will not recover only after complete amplifier power off.
- Power on mute. Relay2 will only switch on after 5 sec after power on. + LED1 flash @ 1Hz during muting period.
- DC protection. If the auxiliary circuit detects DC in speaker wires then it will pull Sense_pin2 up to ground; else 5v. If there's DC in speaker wires then Relay2 will switch off. + LED1 flash @ 10Hz. This will reset if Sense_pin2 is pulled back to 5v.
- Over temperature protection. This will be done using a thermistor. Analog input. Sense_pin4 to ground at 0*C; to 5V at 70*C. Temperature goes up, Sense_pin4 goes higher. At 4v across Sense_pin4 the arduino should flash LED2 at 0.5Hz indicating high temp. At 5 v across Sense_pin4, Relay2 will turn off. This will reset when Sense_pin4 goes under 3,5v. When the circuit is in over temperature protection the LED2 should stay on.
- AC monitoring.  If there is AC then Sense_pin4 will be low. If there isn't any AC then Sense_pin3 will be high. As long as AC is present the arduino should continue normal operation and monitor for DC, Over temperature and Short circuit. LED1 should stay on as long as everything is in normal operation mode. If AC falls and comes back the arduino should reset. When Sense_pin4 is high (5v) then the arduino will switch Relay2 off and when the Sense_pin4 is pulled back low (gnd) the protection should reset.

All protections (DC, over current, over temperature, AC monitoring) should start checking right away and keep on checking until everything is powered off. Everything should function with no delay right from when power is applied.

Is this doable? I think this means multitasking. Can arduino do that? I know something similar to this has been done with a PIC (minus soft start and short circuit) but there's no code available.

If this is doable, i'll buy an arduino uno. And also, could someone please guide me through the process of thinking and coding this?

Thank you very much!
Your's sincerely,
Radu Matei Birle

SirNickity

I've done a lot of this, and have future projects in mind to do a lot more of it.  Yes, the Arduino can do this.  It's "multi-tasking" in a sense.  Basically, you're just polling the events in series at a very fast rate.  It takes very little time to read a pin state, so the protection is "almost" immediate.  Still, because code isn't perfect, a better option might be to take some of your protection circuits into the analog domain and just monitor them with the microprocessor for user feedback.

Let's go over these one at a time:

Soft-start
Personally, I would abandon the idea of using a timer here.  Instead, switch from your current-limited cap charge circuit to your full-current one based on the voltage level of the caps.  I.e., use a comparator to trigger a logic level.  This way, if power fails (or the user cycles power) for a short enough time that the caps have not discharged, you're not effectively power-cycling the load circuit or waiting for an arbitrary period of time while everything's well within limits.  Similarly, you're not removing the current limit in the case of faults or low line voltage.

I assume you're familiar with how to generate stable reference voltages?  (Typically, a Zener or precision reference fed to one side of a comparator...)

Current limit
IMO, this should be analog.  You don't want to "wait" for the micro to detect this and react, just in case it isn't responding (e.g., low rail voltage or input spikes cause it to lock up.)  Feed your output relays via the comparator output and sample this from the micro for alarm feedback.

Power-on mute
I would combine this with the current-limit driver.  Use a normally-open relay (to ensure the output is disconnected on power loss or faults) and a logic IC (OR/AND depending on signalling) to close it when both the current-limit is within spec, and a few seconds after the micro powers up and sets a pin high (or low).

DC protection
How did you intend to detect DC?  I've found a few circuits, and simulated one in particular that I plan to use, but I'm curious what you came up with.  The thing I struggle with is that DC faults are necessarily time-delay sensors.  DC is absence of AC, which takes time to measure.  By then, you may already be damaging your load -- particularly with high output amps and/or bi-amping (tweeters).  For that reason, this should probably also be an analog circuit monitored by the micro, and fed into another input on the relay drive logic IC.  You might want to calculate if the current-sense protection is sufficient to protect the load just in case.

Over-temp protection
Again -- analog.  If it gets particularly hot, you may not be in stable running conditions.  Particularly if the abnormal temperature is caused by power faults.  You will also want to design your power rails such that you can turn off your output transistors while leaving the logic (analog and digital) running.  A separate thermal fuse in the PSU is a good idea.

AC loss detection
My favorite solution to this is to tap the AC input (after the trans of course), rectify it via a small diode into a cap (say, 10uF) and provide a drain resistor to form an RC constant that is read by a comparator.  You'll have to tune the RC to ensure this will drain to below the threshold before the bulk caps get too low.  OTOH, rather than worry about how the AC input is doing, it might just be best to monitor the PSU rail voltage(s) to ensure it/they are above some threshold.  When they're not, you shut down the amp.  Loss of AC isn't the problem in an amp PSU anyway.  Loss of DC is.  ;)

brlmat

#2
Oct 04, 2013, 10:16 am Last Edit: Oct 04, 2013, 01:59 pm by brlmat Reason: 1
This is where my inspiration came from: http://sound.westhost.com/project111.htm
I thought of using the circuits he projected as dc detection, ac monitoring. I thought of using a thermistor as temp sensor as they are cheap and easy to implement. In case of short ac loss the core might get demagnetized and therefore might need the soft start to trigger again. I thought of breaking the power rails but the problem is there will be a fat 80v spark. Relays able to break this kind of dc are very expensive. I'd like all protection to be on one board because of the small form factor. The arduino will be powered off a 5 volt regulator with an input voltage of 18v rectified from the main transformer. Worst case scenario, the 7805 will regulate from 10v dc which is still plenty of headroom.

SirNickity

#3
Oct 04, 2013, 10:17 pm Last Edit: Oct 04, 2013, 10:19 pm by SirNickity Reason: 1
Are you sure core magnetizing is a problem?  Its own inductance (and the impedance of the AC mains) naturally alleviate some of that burden.  For the few amps I've built, empty caps seemed to be the long-term current hog that caused the most problems.  YMMV.  Naturally, you still have to use a slow-blow fuse in high-power PSUs to avoid nuisance trips.

I would think twice about feeding a linear regulator from a 10-18v input.  Even for low current consumption, that will put off some heat.  If you do it this way, you'll have to put some effort into thermal management of the regulator.  Switching regulators, additional secondary windings, or an additional small transformer may be better suited.

Think about using solid-state switching on the power rails.  I built an amp that uses P and N MOSFETs on the power rails for soft-off, triggered by a 5v logic input.  (attached)

Thermistors are adequate for fault protection, but there are plenty of easy-to-use, inexpensive thermal probes that can be read via a microcontroller.  (Check out Adafruit's temperature sensor page for some examples.

brlmat

Yes, core magnetizing is a pretty big problem, especially with toroids. I've fried over 15 slowblow fuses with a brand new 1kw toroid with no load attached (not even rectifier; bare wires with a multimeter measuring voltage). And then most of the time i saw all the lights dim for a second when i connected the toroid to the mains. As a reminder, the transformer was good, new and still running in a amp of one of my friends with aftermarket softstart on; still dims the lights a little, but doesn't burn strictly selected normal-blow fuses.

I once fed two regulator in parallel of a 20v supply in order to get 2 amp of current ("max rating") capacity. I loaded it with approximately 3 amps (3 smartphones charging. 2.85amps measured with multimeter) and yes, it did get a little hot. And by a little, i mean i could still keep my hand on the radiator (junk radiator). I don't think that 200-300mAmps will much bad. After all, the dissipated power would be around 2.6w. This could easily be dissipated by one of the many PC chipset coolers i have lying around.

Yes, solid state switching on the power rails would be a good compromise. Yet i don't see a need for that. In case of DC it is a lot quicker to disconnect the load than to disconnect the power rails as I have filtering on the amplifier board too. Same in case of short circuit.

Thermal probes are pretty expensive, especially at mouser (where i'll get all my parts from). I am looking for max. 40 euros on all protection. The cheapest thermal probe is 18 euros and the cheapest arduino is 20. So thermistors are a good bet. I don't need to know the exact temperature anyway.

brlmat

#5
Oct 06, 2013, 06:57 pm Last Edit: Oct 07, 2013, 10:28 am by brlmat Reason: 1
Can someone help me with this?

LE: Thanks for moving my post to the correct category. Sorry for the inconvenience.

SirNickity

Looks like you've got your mind pretty much made up on what you want to do.  What do you still need help with?

I see your point on the transformer.  1kW is a pretty tough load.  You're building a tough PSU there.  Usually I don't see people looking to continuously supply enough current to run sine waves at full power.   ]:D

brlmat

I need help with the coding.

to recap:

-softstart 1sec. relay 1 set high after 1sec
-power on mute 5sec. if t<5sec then led0 1hz. if t>5sec then relay2 set high; led0 on
-dc protection from t=0sec. normal sense_dc=high. fault sense_dc=low; relay2 set low; led1 on. no recover only if amp power cycled.
-short circuit protection from t=0sec (it will actually only work from t=5sec because relay2 will be open). normal sense_sc=high. fault sense_sc=low; relay2 set low; led2 on. no recover only if amp power cycled.
-temperature protection from t=0sec. normal pwm_temp<=150. warm amp 150<=pwm_temp<=220; flash led3 on. fault pwm_temp>=220. recover if pwm_temp<=150.
-ac monitoring. If there is AC then sense_ac=low. no ac then sense_ac=high. As long as AC is present the arduino should continue normal operation and monitor for DC, Over temperature and Short circuit. led0 should stay on as long as everything is in normal operation mode. If AC falls and comes back within 300ms (as the arduino will still be powered for another 3-4) the arduino should reset and rerun all code except for the softstart part and the power on mute is reduced to 1.5sec. If ac fall for more than 300ms then the arduino should power off (if this is possible) as this means the power has been completely interrupted.

I have no idea how to code this without multi tasking. And even so i am not sure i'll do it 100% right.

Please, if you can, help me with this.


Paul__B

Basically, this is the sort of job for which a microcontroller is not required and only "prettifies" the design.

Worse, there is some risk that the microcontroller will itself fail (crash - due to power glitches or code errors), and in doing so will fail to protect what it is purposed to.

What you describe can perfectly adequately be performed by an AND gate.  As in the circuit you cite, virtually all the important interfacing and timings are performed by other components, diodes, transistors, capacitors and such.  An AND gate itself can be implemented using diodes (or even resistors and a transistor) though there is an advantage of using a CMOS device with high input impedance.

The only thing the MCU in the circuit you cite, does, is to implement the fancy flashing of the LED.  If that is important to you, rather than simply using multiple LEDs to indicate various fault conditions then by all means use an Arduino - by coding each individual function one-by-one from example code (avoiding any calls to the "delay()" library function) and adding it to the project.  If you are going to use an Arduino to do this, you might just as well add a LCD and have it state the fault condition or else have it as default indicate "System good" like the ones in the hospital corridor (medical gases supply), and scroll an interesting pattern.

brlmat

Basically you are saying that i am underusing the mcu and it's not really worth it.
I started to think about a fully analog protection because it kind of feels that the arduino is a little too expensive for it's use here, tho my problem is that i completely forgot about using AND and OR gates. As for the LEDs, i can use multiple, that's not a problem, even an RBG one so i can signal fault based on color. Although, i find it kind of difficult to implement timers in analog circuits. What i mean is that for example the Soft start should reset to exactly t=0 on power off within 50 ms. I don't know how this could be possible without using some kind of complicated timer.

Btw: Is a 3 dollar PIC with no arduino bootloader loaded programmed using the same language? (i will have to get a programmer but i think some phone repair shops around have that.)

Go Up