This article has almost nothing to do with a promised series of articles. Instead, this is a continuation of motor control using audio amplifiers.
I previously discovered that a commonly available PAM8403 stereo audio amplifier board is sufficient to control two small motors. This is possible because the amplifier is intended to drive speakers with 4 Ohm or 8 Ohm windings. A speaker is a special case of linear motor and many small motors similarly have 4 Ohm or 8 Ohm windings.
The major advantage of this scheme is that *any* headphone output may be sufficient to control two motors. This includes pre-recorded sound or any programming language which can play sounds. That includes programming languages aimed at kids, such as Scratch and Squeak.
In some regards, a PAM8403 is an overkill for hacking. Regardless, it has advantages over an H-Bridge. For example, a linear amplifier allows forwards and backwards operation of two motors at variable speed. The major catch is that audio amplifiers expect an RTZ [Return To Zero] signal and therefore sending a continuous positive or negative signal fails to have any sustained impact. This can be overcome by sending a square wave of arbitrary amplitude and arbitrary duty cycle. A quirk of this encoding is that the square wave frequency isn't hugely important. We'll be using that property next.
A member of my makerspace asked if it was possible to control four motors using two audio channels. (Specifically, he's obsessed with quadcopters, drones and suchlike.) After some false starts, I found that an audio channel can be partially split into two by using an analog low-pass filter.
In this arrangement, the majority of an audio channel's amplitude is allocated to a low frequency square wave. This is directed to one pair of motors and allows the pair to be driven at almost maximum speed. The remainder of the audio channel's amplitude is allocated to a high frequency square wave which may have a complimentary or opposing bias. This is directed to one motor of the pair and provides stabilization of the platform in one axis.
For each audio channel, the audio filter consists of one resistor in series followed by one capacitor to ground. The product of the resistor and capacitor in the RC network determines the resonant frequency of the filter in radians per second. (Adjust by 2π to obtain cycles per second.) Optionally, use multiple RC networks in series to increase signal discrimination. However, for this application, it isn't particularly important.
Worked figures are as follows. Low frequency signal is 440Hz. Cut-off frequency is low frequency times four. High frequency signal is cut-off frequency times four. Resistors should be 470 Ohms. Capacitors should be 220pF.
I assumed that two stereo amplifiers would be required. By chance, another member of my makerspace was making an enclosure for stereo speakers and re-chargable batteries. The audio amplifier is a TDA7379 which is a quadraphonic amplifier which can be ganged into stereophonic. As a quadraphonic amplifier, it provides 13W per channel. I haven't gone through figures in detail but that should be sufficient to lift a computer, gyroscope and batteries. This is an extremely dangerous project but it is also shockingly accessible.
(Score: 0) by Anonymous Coward on Sunday July 02 2017, @01:46PM
Keep us updated.
(Score: 0) by Anonymous Coward on Sunday July 02 2017, @05:28PM (1 child)
I can't figure out how this works -- in fact it seems pretty clear that it shouldn't, so I'm trying to understand why it does. (I assume you have built this, but... have you built this?)
If you're using capacitive coupled inputs, as is normal for audio amps in their intended use (because DC offset is wasted power in audio), the DC bias in your high duty cycle square waves shouldn't be getting through at all.
If you're directly driving the amps, then I don't see why you'd need the square wave at all -- seems like you could use straight DC. But even with the square waves, the DC component of the high-frequency square wave is still DC, and thus should be making it past the low-pass filter -- one motor will see a low-frequency square wave, with a DC offset that is the sum of both signals' DC values, and the other will see both square waves, with a DC offset that is the sum of both signals' DC values, and the motors will run the same speed.
So clearly, if this is actually working, I'm missing something. Maybe the original DC value doesn't matter, and the signal is somehow (internal protection diodes?) being anchored by the 5% wide spikes, in something like the process of clamping a TV signal on the sync tips? This would at least allow some difference between the DC levels seen by the two motors, but it doesn't seem like the non-low-pass signal would be a true linear combination of the two inputs -- have you checked your test rig for linearity?
----------------
My thoughts on the more general topic:
Quadcopters (unless you're going for crazy aerobatics) don't need full-bridge drive like you generally do for rolling vehicles, and that means you can simply rectify the output of each amplifier. Now you can stick a high-pass, low-pass, or band-pass filter on the input of each amplifier, and feed them a mix of simple sine waves at each frequency, with no DC offsets anywhere. You could probably control 4 motors on one channel this way, with sufficiently good filters, but I'd still go two motors/channel so you don't have to mess with higher-order filters. (Any bandpass filter is second-order at minimum, and you probably need fourth-order filters to squeeze all four channels in with acceptable separation -- but two channels can easily fit with 1st-order high-pass/low-pass filters.)
BTW, I'm a little curious about your 440Hz frequency. I'm no quadcopter guy, so I have no real knowledge of the actual control bandwidth required to stabilize a typical quadcopter. But I'd be concerned about too low a frequency keeping you from updating it fast enough -- do you have numbers on this?
(Score: 2) by cafebabe on Sunday July 02 2017, @07:27PM
Starting with the frequencies, Tower 9g servos are typically used in model helicopters which are controlled with visual feedback by a human operator. They typically receive pulses at 200Hz or less and the feedback loop is significantly lower. So, 100Hz would be sufficient but additional pulses provide a signal which is more resilient to interference. 440Hz is specifically chosen for debug because it is a standard musical frequency [wikipedia.org] (and also the inspiration for the band Apollo 440 [wikipedia.org]). The other signal is four octaves higher and there should be a minimum of 10dB attenuation. The high frequency is just over 7kHz and may incur additional attenuation over unscreened cable. An additional consideration is that signals are intended to be played as 44.1kHz sound samples and a higher frequency may incur duty ratio rounding error.
I'd really like to have a hexcopter but the extra frequency filtering isn't worthwhile. Four motors per channel is significantly more awkward.
I have yet to purchase a TDA7379 but the PAM8403 has a surprisingly long grace period for DC signals. This is sufficient for a 95% duty cycle square wave to incur a non-zero area-under-curve. Unfortunately, the remaining 5% counts as negative area. It might be possible to drive a TDA7379 without square waves but this definitely doesn't work for a PAM8403 and may not work with other amplifiers. I'll leave it in the description but only because it covers the general case. Although, yes, it is inefficient in specific cases.
The low frequency drives both motors within a pair. The high frequency provides a positive or negative adjustment for one motor within a pair. However, area-under-curve for each motor is complicated by frequency attenuation of the low-pass filter. One motor within a pair obtains the full signal and this may include a high frequency component which would be graphed as bumps or bites. Whereas, the other motor obtains a sum of sine and cosines with progressively smaller co-efficients. This will be a noisy, rounded wave but the area-under-curve remains non-zero.
It didn't occur to me that analog television waveforms provide a template for level-shifting and attenuation. Anyhow, yes, we have a simplified version of this process.
1702845791×2
(Score: 2) by kaszz on Sunday July 02 2017, @07:37PM (7 children)
Ultra-Miniature Digital Amplifier Board 2*3W D-Type PAM8403 [electrodragon.com] for 0.40 US$ Picture [electrodragon.com] with board and illustrative connections, schematic [pinimg.com]. (Seems like a neat board!)
(closeup [sunrom.com])
As for DC, have a look at pin 7 and 10 that are located at the last but one at the input and power end. There you have a capacitor and a resistance in series before the signal goes into the chip. Which suggests that you can bypass these and get around the whole no-DC issue. One issue that may show up once this is bypassed is how much the chip will swing outputs relative to input once there is a direct galvanic connection and how VREF will alter the behavior. Normally a op-amp is feed +/- voltages.
Then there's the thing with constant-voltage, constant-current or with a axle sensor one could accomplish constant rotational frequency.
Will a negative signal on the input result in a reversed voltage output to the speaker?
Btw, why is a 13W project dangerous?
What controller algorithm is used to control the quadrocopter?
(Score: 2) by cafebabe on Sunday July 02 2017, @09:45PM (4 children)
After looking at the same model of board, that was my first idea. On my first attempt, I removed the capacitors and blobbed solder across the gap. That didn't work and it destroyed a board. My second idea was to add a wire behind an input capacitor. That didn't work either but the board continued to work. It may be the case that those capacitors have two or three functions. For example, stopping DC drift and also perform one or more functions at high frequency for the PWM linear amplification.
Yes. Furthermore, an attempt has been made to electrically isolate inputs and outputs. So, if speakers/motors and computer have separate power then electrical noise from speakers/motors shouldn't cause significant power spikes or surges in the computer.
Even an expert using a quadcopter can permanently blind anyone in the vicinity [dailymail.co.uk]. At 13W per motor, it is possible to make a bigger quadcopter and cause more damage.
The quadcopter is host agnostic. It works with any programmable smartphone or credit card computer which has a headphone socket and a digital gyroscope. So, it can be controlled with a Raspberry Pi (with suitable expansion) or an Android phone. This makes the choice of implementation language quite broad.
1702845791×2
(Score: 2) by kaszz on Monday July 03 2017, @08:25PM (1 child)
It may be worthwhile to analyze input vs output and offset issues with the board. Considering it uses only a plus voltage and ground they must have made some basic compromises. The gain would be a cheap platform for full motor control.
But what algorithm? not language..
(Score: 2) by cafebabe on Tuesday July 04 2017, @12:35AM
I haven't got that far. I presume there is an open source implementation for quadcopter stabilization and control. I also presume that it is written by people with minimal understanding of feedback [wikipedia.org] and chaotic effects (due to feedback and external, such as a gust of wind).
I would like to have a completely generic algorithm but I suspect it would have to be stuffed full of emperical constants, such as maximum tilt or an approximate signal amplitude to maintain buoyancy.
Also, closed-loop motor control is preferable but often skipped because it simplifies design and reduces cost. It remains desirable to detect propeller rotation. However, it adds another feedback loop for each detector.
1702845791×2
(Score: 2) by kaszz on Monday July 03 2017, @08:37PM (1 child)
I'll guess I have always found flying meat grinders a bad idea to get nearby ;)
So maybe it's a good idea to use eye protection and keep these things at such distance there will be time to react?
(Score: 2) by cafebabe on Tuesday July 04 2017, @01:06AM
My understanding of the cited accident is as follows. An experienced quadcopter operator flew a quadcopter in a garden for the entertainment of spectators. The quadcopter hit a tree and incurred catastrophic instability or damage. It then spun into the shortest spectator at eye level and caused permenent blindness in one eye. If drone delivery become common then scope for similar incidences is greatly magnified. Proximity sensing may help but this leads to other problems.
Good practice around drones with spinning propellers is similar good practice around woodwork or metal work machines with spinning blades or shafts. Don't wear a tie or loose clothing. Cover eyes, face and hands. Don't work too close to other people. Unfortunately, for drones, the latter is completely useless advice when flying in an urban area. It is also completely useless advice when drones become increasingly common and are more likely to collide with each other.
There's a larger issue of privatized profit and socialized loss. Our tech billionaires would love to have a global, privatized, centralized drone flight booking system and earn a fraction of a cent for every drone photography flight, delivery flight or suchlike. Booked routes would exclude areas such as Seattle lakefronts or any other area favored by billionaires. When a drone goes wrong, the peons are most likely to be injured.
1702845791×2
(Score: 2) by cafebabe on Sunday July 02 2017, @10:08PM (1 child)
It occurred to me that you might be asking about the control signals.
On the host computer, it should be possible to mix three audio signals or have useful combinations pre-mixed. The first signal should be a 440Hz square wave with 95% duty ratio. The first signal should appear at any volume up to 90% of maximum volume on the left channel only. The second signal is the same but should appear at any volume up to 90% of maximum volume on the right channel only. The third signal should be a 7040Hz square wave with either 95% duty ratio or 5% duty ratio at any volume up to 10% of maximum volume across both channels.
To raise or lower the quadcopter, equally increase or decrease the volume of the first two signals. To move the quadcopter left or right, adjust the relative volume of the first two signals. To move the quadcopter forwards, apply the high frequency tone with 95% duty ratio. To move the quadcopter backwards, apply the high frequency tone with the 5% duty ratio.
If you get really fancy, it is possible to reverse the rotors and fly the quadcopter upside-down.
1702845791×2
(Score: 1) by xyz on Tuesday July 04 2017, @02:02AM
Interesting frequency division multiplexing idea.
The frequency division multiplexing somehow reminds me of LLC converters just in the aspect of the controlling the power transfer function to a load vs frequency:
http://www.onsemi.com/pub/Collateral/AND9408-D.PDF [onsemi.com]
Some other very tangential power conversion topology stuff FYI:
http://www.ti.com/lit/an/slua107a/slua107a.pdf [ti.com]
http://thesis.library.caltech.edu/1512/1/Kee_s_2002.pdf [caltech.edu]
http://rfic.eecs.berkeley.edu/~niknejad/ee242/pdf/eecs242_class_EF_PAs.pdf [berkeley.edu]