Show Posts
Pages: 1 [2] 3 4 ... 56
16  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: June 01, 2012, 07:40:50 pm
GRRRR...  I can unplug the arduino entirely except for the MIDI cable and the audio output cable.  And I still get the noise, but quieter.  Something must be wrong with the breakout?

With the MIDI cable disconnected is there any noise?

If it is connected but you don't connect the wire to the Rx pin of the board is there noise?

If you remove the serial reading (and the begin call) of the sketch is there noise?

If the MIDI device is powered down is there noise?

The noise is lots of short clicks, like in the screenshot of the waveform, one click I would assume for each MIDI message sent.  Turning the mod or pitchbend wheels sends a ton of messages, so the clicks turn into a buzz.  But there are also clicks at note on's and note off's.  So yes, no noise without a MIDI cable connected, but that's irrelevant, since the noise only happens when a MIDI message is sent.

I have the breakout board mounted as a shield, so I can't physically disconnect a wire.  But there is a switch that disconnects Rx, so the MIDI circuit doesn't interfere with programming the board.  And yes, the clicking/buzzing still happens with that switch disconnecting Rx.

Yep.  Assuming the DAC is already in active mode, i.e. not floating, I can upload the bare bones sketch with the empty setup and loop, and I still get the clicking/buzzing noise.  So absolutely an electrical issue.

Again, no, but not relevant, since the clicking only occurs when a message is sent.


I'm still puzzled...  I tried measuring the resistance between the MIDI connector pins and various points on the board, but nothing unusual.  It seems to be isolated.
17  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: June 01, 2012, 06:57:42 pm
MIDI inputs are always opto isolated, it is part of the spec.

The data pins are opto-isolated. There is a third pin (ground) which is supposed to be connected at one end but not the other. Maybe noise is bleeding into that?

Nope.  I checked the schematic, and checked the actual board too, and no connection.
18  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: June 01, 2012, 03:02:15 pm
I plugged the cable into the aux in on my laptop and recorded the noise into Audacity.  (don't have a proper oscilloscope...   smiley-razz )

Here are 2 of the clicks in the buzzing, normalized and with the space between them cut out (they're normally further apart)



could these be the MIDI messages bleeding through to the output somehow?  not sure how that would happen.
19  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: June 01, 2012, 02:08:58 pm
I still think it's something related to grounding somehow.

If I remove the MIDI code and put in a Serial.begin(), then send stuff from the serial monitor in the IDE, no noise.



GRRRR...  I can unplug the arduino entirely except for the MIDI cable and the audio output cable.  And I still get the noise, but quieter.  Something must be wrong with the breakout?
20  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: June 01, 2012, 11:33:16 am
Yep, now I think it's a grounding issue.

I'm using the Sparkfun MIDI breakout, and I realized it still makes the noise when the Rx pin is disconnected via the switch.

But that breakout does have an optoisolated input, so shouldn't it be fine?
It appears to be isolated, based on the schematic: http://www.sparkfun.com/datasheets/BreakoutBoards/BOB-09598-MIDI_Breakout-v11.pdf

Other info on my circuit:  the DAC's on a breadboard, connected to the Arduino just via 5v, gnd, clock, MOSI, and the slave select pin.  It is already decoupled.  The output of the DAC goes thru a 100uF cap to block DC, to the tip of the jack I'm using.  The sleeve of the jack is to the ground row on the breadboard, which is to the Arduino ground.

The grounding issue must be with the MIDI connection; it's fine as long as there's no MIDI input.  I even tried connecting a battery pack between the pins of the connector (obviously with the midi cable disconnected) and I get noise.
But it's theoretically isolated, so I don't know.
21  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: May 31, 2012, 07:52:58 pm
The SPI in assembler is just because I already was using assembler.

I was already using assembler because it was the most efficient way to do the oscillator calculations.  With 8 oscillators, I want it to be as fast as possible.  I got down to around 33 clock cycles for all the necessary code for one oscillator.  Each oscillator is individually configurable to be a triangle wave, sawtooth wave, or square wave (with ~64 different pulse widths), with an 8-bit volume envelope.  I think that's pretty good for 33 clock cycles!    smiley

I put both SPI transmits in between oscillator calculations so no extra time is used up transmitting.  And having the SPI also in assembly makes things faster; otherwise, 2 inline assembler functions would be needed, which would mean twice the pushing/popping of registers used.
22  Using Arduino / Programming Questions / Re: MIDI synth - noise on serial reception? on: May 31, 2012, 05:16:59 pm
Yes, I mentioned that in my post.  But I don't see how that could be the issue.

As I said above, the DAC has an internal buffer, so even if it is delayed, it should just remain at the same value for a tiny bit longer.  I don't believe that should cause any audible click, at least not nearly as loud as the one in the audio clip.

One more thought:  the loudness of the clicking changes depending on whether the Arduino is powered via USB or the DC jack.  So I think the problem could be the output very briefly going into a floating state, and then the clicking is just a short burst of noise.  That would change depending on how the circuit is grounded, etc.

But still, that doesn't make sense.  The only way the DAC chip will go into a floating state is if bit 4 of the high byte sent to the DAC is cleared.  Which, within my interrupt routine, I don't think it can be, since the high byte is always or'd with 0x70, or 0b01110000.

So I'm still puzzled.
23  Community / Bar Sport / Re: The Audio Post on: May 31, 2012, 05:00:18 pm
I've got a Soundcloud page where I post my music.

I mostly use a hardware setup, which includes my homemade Arduino MIDI synth!

One of my best songs, IMO:
http://soundcloud.com/beefinator-2/sabotage-fixed-mix-hardware
The arduino sampled through various effects makes every synth sound in the song.
24  Using Arduino / Programming Questions / MIDI synth - noise on serial reception? on: May 31, 2012, 04:54:57 pm
So I have a MIDI synth I'm working on, and it's all working nicely, except for one thing.

When the arduino receives any type of MIDI message (and I would assume any serial message in general), I get a small click on the audio output I have set up.  It's really not manageable, since doing things like turning a pitchbend wheel causes an audible buzz.
here's a little soundclip of the synth while I turn the mod and pitchbend wheel on my keyboard:
http://soundcloud.com/beefinator-2/arduino-synth-weirdness
About halfway through, I turn up the gain so the buzzing is more audible.  But the first half, that's at the same recording gain as when I play a couple notes, so you can see how relatively loud it is compared to the actual notes.



I'm using an MCP4822 DAC, but that's irrelevant, because I had this same issue a while ago when I used filtered PWM to generate an analog output.

I have in the program an interrupt routine that runs at 22KHz to update the DAC.

I would guess that the clicking has something to do with the serial reception interrupt, but I don't see how it would affect anything.  My routine is not reentrant, so it can't be that the serial interrupt is firing midway through my interrupt.  The DAC is completely updated by the time my routine is done, and the chip has an internal buffer, so the problem can't be the Serial interrupt slightly delaying my interrupt.

I looked through the Serial source code, the MIDI library code, and the atmega328 datasheet to try to figure out what's going on, but I couldn't find any solutions.  From what I understand, the SPI and USART are independent on the chip, so that's not an issue.  

I dunno.

The sketch is attached; any ideas on something I'm missing?
25  Community / Bar Sport / Re: Chinese clones on: May 28, 2012, 08:30:01 pm
Yep, the problem people have with the chinese (or anywhere) boards is that some are made to look exactly like an arduino, same logo, colors, labels, etc.  They're infringing on the copyright.
26  Community / Bar Sport / Re: Nano Vacuum Tubes in Silicon on: May 27, 2012, 10:15:48 pm
I still like the mechanical calculator my grandpa found at a tag sale...

this one, or maybe a slightly different model
http://retrocalculators.com/monroe_files/Monroe_LX-160_Adding_Machine_Front%20With%20Hand%20Holding%20IMG_9057.jpg


Can you fix a frozen computer with WD-40?  No?  I thought not.    smiley
27  Using Arduino / Audio / Re: Inline Assembler with SPI DAC on: May 27, 2012, 10:08:42 pm
Yeah it's annoying.
When I was actually coming up with the assembler code, I actually just handwrote it.  Found it easier and much more readable...   smiley   I just typed it up and troubleshot (? troubleshooted?) it to make the program.

Then I spent some time playing aro—OH GOD WHAT AM I DOING
28  Using Arduino / Audio / Re: Inline Assembler with SPI DAC on: May 27, 2012, 09:02:14 pm
I don't believe the ISR_NAKED would help much.  I see what you mean, but yes, the compiler knows which registers are used.
In the end of the assembler function block thing, there's a list of output, input, and mangled variables/registers/whatever.
The inputs/outputs it automatically assigns to registers; this is why I never refer to register names in the assembler code... Except with the mangled registers.  The mangled registers are any other registers that are modified in the routine.  The mul instruction modifies R1, so that's listed as mangled.
So between the inputs/outputs, and the mangled register list, the compiler knows exactly what to push/pop.

And woohoo! In typing that I thought of what my problem was.  The outputA variable was only listed as an output operand, so GCC does not load its value into the register at the beginning.  I put an input operand linked to the same register, and it works!
Durrr...
 smiley-razz
29  Using Arduino / Audio / Re: Inline Assembler with SPI DAC on: May 27, 2012, 05:19:39 pm
Not with what I have tried. 

For this application, it was way easier to just write it in assembler than to try to figure out C code that compiled to be fast enough.

To give an idea of how fast this needs to be, this interrupt routine is running at ~32KHz.  With a 16MHz clock, that's only 512 clock cycles between interrupt calls. 
Through lots of assembler optimization, I was able to get the code that runs for each oscillator down to about 32-35 clock cycles.  With 8 (or more) note polyphony, that means the interrupt routine is constantly taking up well over 50% of the CPU. 
All the waveforms are also generated by the interrupt routine: there are no wavetables, to keep SRAM freed up.  Variable pulse width square and triangle waveforms are transformed from a base sawtooth waveform.   Each oscillator also has 256 volume levels.

I don't think that I could get GCC to compile something fast enough for this.    smiley
30  Using Arduino / Audio / Re: Xbox 360-Make a mario sound when "A" is pressed on: May 27, 2012, 03:08:10 pm
The Mario jump sound is essentially a square wave that starts at one pitch, then very quickly jumps down in pitch, then more slowly ramps back up in pitch.

Easy to do with an arduino; there are functions already that play square waves on Arduino pins, and you'd just have to make some code to do the pitch slides.


But for the controller:  do you want to have the controller directly plugged into the arduino?  Or do you want the arduino wired to the actual button so that whenever you jump while playing COD or whatever, it makes the noise?
Pages: 1 [2] 3 4 ... 56