Author |
Message |
Feifer
Joined: May 16, 2012 Posts: 54 Location: San Diego
|
Posted: Sun Jun 08, 2014 5:29 pm Post subject:
Developing voltage quantizer |
|
|
So as my first project in micro controllers I'm making a quantizer using a pic16f877a. I know there are simpler ones that can be made out there but I wanted a lcd readout, 2 channels, and enough IOs to talk to the DAC, an encoder and 2 buttons, so I went with this larger chip.
The ADC samples in 10 bits which will eventually cover 10 octaves, 5 up and 5 down. 8 decimal units covers 1 semitone, so 96 is 1 octave. The sample is divided by 96 to get the octave and also % by 96 to get the note. It compares that note to a list notes for a particular scale and then outputs the closest note with the octaves added back in.
Anyways, I got a working prototype right now or rather a proof of concept. I was playing around with it by giving it random pitches from noise into a sample and hold. Everything works pretty good except it seems like it lands on these in between notes quite often, where it can't decide which way to round. Is this sort of an inherent problem of quantizers? Is there some way to deal with this in the code? I'm not sure how many people out there have made their own quantizers but I though I'd throw it out there.
thanks.
edit: I'm guessing the first suggestion would be to get an ADC with more than 10 bits? |
|
Back to top
|
|
|
sneakthief
Joined: Jul 24, 2006 Posts: 569 Location: Berlin
|
|
Back to top
|
|
|
Feifer
Joined: May 16, 2012 Posts: 54 Location: San Diego
|
Posted: Thu Jun 12, 2014 11:04 am Post subject:
|
|
|
Thanks sneakthief,
Well it looks like they're only using a 10 bit ADC also. And the only thing they're doing to process the signal is to level shift it so the pic can read it. That's what I was planning on doing on my final product, but shouldn't have anything to do with jitter. I would think that the main thing is to have a very well regulated reference voltage, but for the input signal, I'm not sure what to do about that. |
|
Back to top
|
|
|
sneakthief
Joined: Jul 24, 2006 Posts: 569 Location: Berlin
|
Posted: Mon Jun 16, 2014 1:00 am Post subject:
|
|
|
Yes, quantizer jitter is a problem with many CV quantizers when voltages are near the note-switchover point. Is your source voltage completely clean?
Using a trigger signal in conjunction with the CV input is usually the best solution if you want to eliminate jitter.
Properly grounding the input end is important. Also, if you have your circuit assembled on a prototyping board, that may be causing problems due to stray capacitance inherent with non-soldered connections..
Here's another two PIC-based quantizer projects you can reference: http://www.bartonmusicalcircuits.com/cvquant/
http://www.clsound.com/quantizer.html _________________ Sneak-Thief - raw electrofunk |
|
Back to top
|
|
|
helge-h
Joined: Jun 17, 2014 Posts: 24 Location: Norway
Audio files: 2
|
Posted: Tue Jun 17, 2014 4:37 pm Post subject:
|
|
|
I have made an oscillator with an arduino uno, and a quantizer, and I have the exact same problem. I believe one solution could be to use hysteresis on the CV (a software schmitt trigger). I have not yet tried it, but the algorithm could be something like this: when the CV rises, just pass it through, but if it falls you should wait until it drops more than a set limit (determined through experimentation). And of course the other way around for initially falling CV.
Helge |
|
Back to top
|
|
|
Feifer
Joined: May 16, 2012 Posts: 54 Location: San Diego
|
Posted: Fri Jun 20, 2014 9:17 pm Post subject:
|
|
|
helge-h, you read my mind.
I was just implementing a hysteresis into my code! Basically, I'm introducing 2 other variables for the previous output and the previous midpoint (crossover point between 2 notes in the scale list)
Code: | if (current ADC value >= previous midpoint - 1 && current ADC value <= previous midpoint + 1){
output = previous output;
}
previous output = output;
previous midpoint = midpoint;
|
Just got done flashing it. Still gotta take it to the garage and see how it performs. Last edited by Feifer on Sat Jun 21, 2014 10:09 am; edited 1 time in total |
|
Back to top
|
|
|
Feifer
Joined: May 16, 2012 Posts: 54 Location: San Diego
|
Posted: Sat Jun 21, 2014 12:21 am Post subject:
|
|
|
Well that worked a treat! A little hysteresis is just what the doctor ordered. I can't even force it to jitter! |
|
Back to top
|
|
|
|