Show Posts
Pages: 1 [2] 3 4 ... 91
16  Using Arduino / Programming Questions / Re: Is it possible to re-#define something? on: July 01, 2014, 02:25:19 pm
Anyway why you want to do that modification to the library? Can you do the same thing without that modification?

I explained why in my first post.
17  Using Arduino / Audio / Re: Discrete Multichannel Audio (Synthesis, not PCM) using Arduino? on: July 01, 2014, 03:42:59 am
I'm afraid I misunderstood your question.  I thought you wanted to read multiple audio files off an SD card at the same time and mix them.

The Mozzi library appears to synthesize effects.  And I noticed you wrote in the subject line "not PCM". 

You refer to wavetable synthesis though, which is the mixing of "samples", ie, an instrument recorded for a short period and looped, played back at different speeds to create the various notes.

As for whether you can get four channels of PWM audio going at the same time, I'm afraid I haven't done anything with PWM audio on the Arduino.  My work with audio has been with DACs.  I'm not sure how much work the PWM requires of the processor.  Or how much work it has to do to generate those samples, or if it's even generating them in realtime.

I suspect my advice about it being too much for the processor though is still accurate.  You may have more PWM channels available on the Mega, but I suspect that PWM audio is fairly cpu heavy and you don't get more CPU power on the Mega.
18  Using Arduino / Programming Questions / Re: Is it possible to re-#define something? on: July 01, 2014, 03:25:11 am
Why not save the modified file under a different name, such as mywiring.c, so that it doesn't overwrite the original wiring.c and affect other projects?

How would the IDE know to use that instead of wiring.c?  I would imagine if I tried to include it I would get all kinds of duplicate function/variable definition errors.
19  Using Arduino / Programming Questions / Is it possible to re-#define something? on: June 30, 2014, 05:56:28 pm
http://playground.arduino.cc/Main/TimerPWMCheatsheet

At the bottom of that page, it suggests a way to keep the Milliseconds() timer functioning properly when increasing the PWM frequency of Timer 0:

Code:
For Phase-correct PWM of 31.250 kHz (prescale factor of 1)
Use these two lines in the setup function:

TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
TCCR0B = _BV(CS00);

And modify the line in the wiring.c function in the Arduino program files
hardware\arduino\cores\arduino\wiring.c :
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 510))

My question is, can I just throw that #define in my main program after my includes, possibly #undef -ing it first, and have the compiler use that new definition everywhere, or am I going to have to alter wiring.c, which I'd prefer not to do because the modification will affect other projects and will inevitably be lost and forgotten when I back up my project folder?

I'm aware there are other timers I could use, but Timer 1 is in use by the audio library, and both Timer 1 and Timer 2 share pins with the SPI interface, and I want to drive a motor controller with PWM and that means I need two PWM pins for forward and reverse control, and if I used pins from two different timers then both have to be set to the higher PWM speed, and I'm sure I'd regret that decision later if I need Timer 2 for something else.
20  Using Arduino / Motors, Mechanics, and Power / Re: Do you think this relay driver could handle 20khz PWM for a small motor? on: June 29, 2014, 01:04:35 pm
It's more than fast enough but where did you get the 20khz PWM spec ?  That's not an arduino PWM frequency so where is it from ?

20khz is a typical PWM speed when controlling motors.  It's fast enough that the PWM won't cause the motor to buzz at an audible frequency.  While it's true that the default PWM speed on the Arduino is 490hz you can change a few registers to get much higher PWM speeds.
21  Using Arduino / Audio / Re: Discrete Multichannel Audio (Synthesis, not PCM) using Arduino? on: June 29, 2014, 06:33:04 am
As far as I know the Teensy audio and neopixel code is pretty stable.  I did encounter some bugs when I used it several months back, but the developer is really fast about fixing stuff and he fixed the issues I reported within a week or so and added some features I requested to allow for looping audio seamlessly.

As for the Mega, just because the board costs a lot more and has a lot of pins and a lot of ram, doesn't mean it's much more powerful than an Uno.  It's still 16mhz, still an 8 bit mega processor.   The Teensy runs at up to 96mhz, is 32 bit, and has a DMA controller which greatly speeds up the transfer of data from the SD card and to the audio circuity. 

You should be able to read at least 600K a second off an SD card with SDfat.  That's what the author said he got on a Mega anyway:
http://forum.arduino.cc/index.php?topic=128335.0

And 44khz 16bit is 88K bytes per second... x4 = 352K bytes per second.

So could you do it?  I don't know.   There are seek times to deal with when changing files, though I think it's possible to store the index to jump straight to the file. 

I didn't say it was impossible, but it's not going to be easy. smiley

PS:

I know a fair bit about wavetable synthesis - I grew up creating MOD files on my 386, which also ran at 16mhz.  It could just barely handle 4 channels of 8 bit audio at a low sample rate, and that was with highly optimized code, and a full 640K of ram to work with. smiley
22  Using Arduino / Motors, Mechanics, and Power / Do you think this relay driver could handle 20khz PWM for a small motor? on: June 29, 2014, 06:04:30 am
http://www.diodes.com/datasheets/DRDC3105.pdf

Not sure what I should be looking for on the timing specs, but the worst number I see there is 800ns which I think means the switching speed can be faster than 1mhz.

Seems like a nice chip.  Might have to be careful in motor selection even if it will work though.  I notice one motor I just checked has a stall current of 2A.  It would be bad if the part were to blow if the motor was prevented from turning.
23  Using Arduino / Audio / Re: Multichannel Audio using Arduino? on: June 29, 2014, 12:51:19 am
Oh wait, are you asking for 4 channel audio?  As in four speakers, each with one channel?  The Teensy audio library doesn't handle that I don't think.  You could of course, use two boards.  And you should be able to feed the audio from each sound file to only one of the stereo outputs. 
24  Using Arduino / Audio / Re: Multichannel Audio using Arduino? on: June 29, 2014, 12:48:21 am
I don't think you'll be able to get a Mega outputting 4 channels of audio.  WaveHC maxes out at 44khz 16bit mono.  I suppose if you dropped the sample rate to 22khz  8 bit and added three more buffers, you MIGHT be able to accomplish it, but for your one off project it probably wouldn't be worth the effort.

A Teensy 3.1 however would easily handle 4 channels at 44khz stereo with it's own specialized audio library. And, if you're using Neopixels, as I suspect you are, then it has a shield available for controlling those and a library that can drive up to 4000 of the things:

https://www.pjrc.com/store/teensy3_audio.html
https://www.pjrc.com/teensy/td_libs_OctoWS2811.html
https://www.pjrc.com/store/octo28_adaptor.html

You can't however, do both with the same Teensy.  The pinout of the Teensy's audio shield and the Neopixel sheld are incompatible.  I imagine it would not be too hard to get two boards communicating with each other though with some of the unused pins, and you could run the audio board on a separate power supply so as not to have any potential issues with noise from the massive power usage of the Neopixels.

25  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 28, 2014, 02:55:18 pm
Quote
Daisy-chained power isn't a series connection. Hmm... if you have ever done house wiring, outlets are daisy-chained.

So you mean parallel then, but are asking if I have a single 5V rail which the amplifier and LEDs are branching off of.

Not exactly.  I have a 5V plane on top, and a ground plane on the bottom which are broken up by traces, and the analog portion of the circuit is isolated from these except at a single point about a quarter of an inch from where power is siphoned off for the LEDs.


Quote
Anyway. Yes, you'll have to use a large bypass capacitor with a low value resistor on power running to your audio circuits.

These boards are the size of a credit card.  They have to be small to fit where they need to fit.  I can't stick a giant 4700uF capacitor on there, and that seems like a horribly inelegant solution anyway.
26  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 27, 2014, 12:01:41 pm
You misunderstand me. You don't want to put a lowpass filter on your speaker. You want a lowpass filter on the Vcc line providing power to your audio section.

The audio section of my original circuit contains a DAC and a 3W amplifier.  Sometimes the 3W amplifier is used, sometimes an external amplifier is connected to the line out.  The fact that the 3W amplifier is there though means that the supply for the analog circuit has to be sufficient to supply the speaker, unless I ran the on board amplifier off the unfiltered supply, which would likely wreak havoc. 

(I say 3W because that is how TI refers to the part, but since the speaker is 4 ohms, not 3 ohms the output should be more like 2.5W with this amplifier.)

So yes, I get that the lowpass filter should be on the Vcc line.  But the Vcc line has to supply 2.5W to the audio portion of the circuit to drive that small amp when it is in use.


Quote
Power should not be daisy-chained, either. If you run Vcc to the LEDs and then to the audio amp, all the voltage noise on the LED's power wire appears on the audio section's Vcc line. If you run Vcc to the audio amp and then to the LEDs, some of the voltage noise and all of the current noise appear on the audio section's Vcc line.

My original post linked at the top of this thread has my board's schematic.  The power is not daisy-chained, if by daisy chained you mean wired in series.
27  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 27, 2014, 02:34:14 am
I didn't fully explain, however I did post the transfer function, do you know how to derive the transfer function I posted?

I'm afraid not.  My math skills are extremely rusty.

Quote
I can show you how I worked out the transfer function, how we solve the equations and just how complicated this can be

If it's that complicated, I probably won't understand the math.  That page on maxim however made it seem fairly easy to calculate the capacitor needed for a Pi filter though, so I'm curious why you're indicating the math is very complex.


Quote
I I were you I would use an RC filter, very easy to design, very easy to work with, no resonance but it will still filter good enough for you, we can even do the same thing to get the equations for that and its a nice learning curve

That sounds good, but if it's that simple why didn't Maxim do that?  And why would anyone ever use an expensive inductor that would be prone to resonance?

I have used this calculator in the past for RC filters:
http://sim.okawa-denshi.jp/en/CRtool.php

For 1000hz and a 47uF capacitor, it says my resistor should be 3.3 ohms.  That seems high.  I don't know for certain, but given my speaker is 4 ohms, I think if I stuck a 3.3 ohm resistor in series with it not only would the resistor have to dissipate half the power which  think would be something like 1.25W, but my volume would also be halved.  Neither of those is desirable.  I'd have to use a huge 4700uF cap to get the resistor value down to where it wouldn't affect my volume much and where it wouldn't dissipate too much power for a large surface mount resistor to handle.

Of course I could be way off here.  But I think I've got the numbers right.
28  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 27, 2014, 12:09:33 am
That article seems to cover exactly what I need.  It's even calculated the values for the 1khz noise that DC42 said I likely had in my circuit, and the capacitors are fairly small.  I also don't think that diode there is actually necessary for the filtering, it's probably just a reverse voltage protection diode.

I should probably still increase the capacitance on my LED modules and at the power input on my board because they are probably woefully inadequate.  I assume that shouldn't affect the design of this filter.
29  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 27, 2014, 12:02:59 am
I found this interesting article just now:
http://www.maximintegrated.com/en/app-notes/index.mvp/id/4713

It's talking about essentially the same issue I'm having with an audio circuit and LED driver running off the same supply, and shows the use of a Pi filter between the analog supply and the digital signals.  I was going to put the filter on my LED drivers, but if I can just put a single filter before the audio circuity, that would be much less expensive and allow my boards to be as small as possible, which is important for my applications. 

Is that a schottky, or a zener diode between the analog supply and the digital circuit?  And is that necessary?

30  Using Arduino / General Electronics / Re: How do I calculate the values for an LC or PI filter? on: June 26, 2014, 11:54:13 pm
Is the noise coming in on the power supply lines?
Or are the audio input lines picking up emissions from the LED switching?
2 different solutions. One is to filter the power supply better where it feeds the audio amp.

I don't know, nor do I know how to determine this. 

I assume the amplifier has sufficient filtering on its input.  It happens with both the Lepai2020A+ and the DTA-2, both available on Parts Express.  The issue does not seem to affect the 3W amplifier I have integrated into the board itself.  Well, it may, but it's so quiet that it doesn't matter.  The issue with the external amps is an extremely loud high pitched buzzing noise that increases in volume as more LEDs light up.  It's louder than the audio itself.

If I connect a servo to the board, or dim an automotive LED driven by a  12V boost converter using PWM I also get varying amounts of static.  If I recall correctly, this does affect the 3W amplifier on the board, but again, the effect is lessened.  By which I mean, on the 3W amplifier, the noise is much quieter than the audio, while on the 20W amplifiers, the noise ends up being much louder than the audio... unless they are powered from a wall adapter instead of the same battery (D cells or LiPo - should be plenty of juice).  Then they behave like the 3W amp where noise is minimal.
Pages: 1 [2] 3 4 ... 91