November, so soon! I kind of had to put this one down for awhile and work on things that were not laptop-centric, I just was spending too much time in front of a computer screen. Luckily, Tiuri De Jong was on the case, and he has developed the proof-of-concept code I posted earlier into a fully-working demonstration.
I uploaded it to my Arduino, and I’m getting stable results with an apparently linear response, although the specific numerical values themselves aren’t particularly meaningful. For example, under my workbench lamp that I metered at about 40fc and has a CCT of 5000K, it measured 290fc at 3500K. I get that the part would require calibration before it would be useful, but it’s strange to me that it would be off by 1500K color temperature and a factor of 5 for illuminance, out of the box? I’d be interested to know if anyone else has a similar experience.
What I’m working on now is measuring the values given by the TCS3414 vs. a known accurate illuminance and color temperature meter, to tell if the deviation from true value is a constant, or a linear function, or what. I’ve verified that the calculations are done correctly in the code per the datasheet.
But in the meantime, it seems like a shame to deprive everyone else of Tiuri De Jong’s complete and, might I add, lucidly written code, so it may be downloaded here:
Well, this was a productive night: I’ve been working with the Taos TCS3414, which is a light and RGB color sensor. It’s a tiny little guy, about 2.5 x 3.5 mm I would guess, and shown above is mounted on breakout boards. I just had a breakthrough night with it, getting it to correctly return values from the sensors, so I thought I’d share my preliminary code for the benefit of all.
These are some quick reference guides I made for my dad, for Christmas. I am posting it now because June is the next month after December, clearly. So my dad has been hampered in working on his classic cars and rental properties with their myriad electrical problems because he’s never been exposed to the fundamentals of electricity. I figured that what he needed in lieu of a formal physics course was a quick reference that he could refer to as needed. Continue reading “Electricity Quick Reference Cards” »
It’s finally done, jesus. A few years ago, I bought some electronics components from a former Eastern Bloc country. Nixie tubes are apparently still widely available over there, so since the largest line item in the order was shipping costs, I had them throw some Nixies in with the order. They sat in my parts bin until, a few months ago, I decided to make a clock out of them. Continue reading “My Nixie Clock Build” »
Tested and working with IDE version 0021. I have not tested it with the new Arduino Uno hardware, but can’t think of any reason why it wouldn’t work. If you have any success or otherwise with the new hardware, drop a line in the comments.
A bug has been fixed in the addressing routine caused by button debounce, and the addressing routine logic has been simplified and made clearer. Big thanks to Ron Barber for pointing out the source of the bug and contributing new code.
There is now a check when the previously stored address is read from EEPROM to ensure that it is in the valid range of 1-511, to prevent a bad value being read in from uninitialized EEPROM.
Fixed a potential bug in the break detection routine that could cause the read values to be off by one in cases where the break from the microcontroller was exactly 88uS.
The Hardware, Oh the Hardware. I’ve been making some great progress on shaping the generated tone and getting some more musicality — I’ve programmed a decay function and that’s made a huge difference, depending on the input values I’ve got a pretty good harp simulacrum, and also something that sounds like an early 1980′s analog synth piano, which I <3. I’ll try to get a demo up of where I’m at with tonality. Mainly, I’ve been trying to figure out the analog inputs to control the tone sensing, as well as volume, attack, decay, echo, etc. This is really two separate problems. For the frequency control, I want to detect distance from 2″-3′ with good precision, stability, and ideally linearity. For the volume and effects control, I want a 0-5V analog input over about 1-1.5″ of travel, that can be operated with a single finger. Here’s what I’ve looked at: Continue reading “Arduino Theremin/Synth Update II” »
So. There are a bewildering variety of options for generating sound via the Arduino, but I’m trying to make a real-time synthesizer, with the following features:
Arbitrary waveform shape, including the ability to add harmonics for a more musical sound
Generate any frequency dependent on sensor input
Efficient processor usage to allow for effects such as reverb, echo, envelope shaping, etc.
A minimum of external hardware
Audio output for the Arduino is pretty well-tilled soil, but surprisingly most of the previously published options are geared towards canned sound playback, or tone generation without a focus on musicality. I’ve implemented an algorithm called Pulse Code Modulation, and I think it has a lot of potential. Keep reading for an explanation of how it works and why it’s awesome.
Banana bread and chips were vital to the DAC processing
An Update: I’ve made considerable progress in improving the quality of the audio output. In the prior post, I was generating a square wave with the pulse frequency determined by an input from a capacitive sensor. It sounded, to put it succinctly, awful. Since I was generating it through the main loop() code, it was also susceptible to processor load problems, i.e. when an analogRead() was done, it would stop the waveform generation and start it again for ~100mS. I’m now using interrupt-driven Pulse Code Modulation to generate an arbitrary waveform, and it sounds surprisingly decent, actually.
It’s Like This, Y’all: Since with this setup I can generate an arbitrary waveform, I first spent some time investigating what makes a tone sound musical, or not. I started by taking a recorded piano key and doing a frequency spectrum analysis of it in Audacity. Here’s what that looks like:
The waveform of a middle C (261.626Hz) piano key
And the accompanying spectrum analysis:
You can see that the strongest tone is at the fundamental frequency of middle C, 261Hz. But there are also spikes at the harmonics of that frequency, e.g. 523Hz, 784Hz, 1046Hz. Interestingly enough, the strongest harmonics are those corresponding to powers of 2, i.e. f * 2n. I’ve read that even-numbered harmonics are more pleasant-sounding than odd-numbered harmonics, and this would seem to support that idea. Also, as you add in the odd-numbered harmonics, the waveform approaches a triangle wave, which is definitely less pleasant to listen to than a sine wave.
Thus Informed, I started working to create a waveform of my own. I set up a frequency and a bunch of multiples of it in Audacity, and played around with increasing or decreasing the amplitude of specific overtones, until I had a sound I was happy with, like so:
On the left, you can see that I’ve varied the amplitude of the various overtones
From this I discovered that the undertone (1/2 * f) and other partials make a huge difference in the quality of the tone. I wanted to post this file up so other people can play around with it, but apparently with the associated sample files it’s around 50Mb, so you’ll have to recreate it yourself. I highly recommend it, it’s interesting. For comparison, here is a recording of a piano, middle c tone:
The generated version sounds different because there’s no envelope shaping on it– it’s just a constant amplitude. However, I if you listen to both a few times the tone is somewhat similar.
Next, I started working at digitizing a single waveform. I couldn’t figure out an easy way to do this directly from my generated tone, so instead I built the values in Excel:
I then copied the summed values (column N) into a 48 element char array in my Arduino sketch. If you want this spreadsheet, here ya go. Finally, here’s another Unintended Comedy Amateur Hour video of me playing around with the generated sound in the Arduino:
I’m going to talk a little more about the specific programming techniques I used to make the Arduino do this in a separate post.