tessel / ambient-attx4

Tessel library for the Ambient (light and sound) module.
Other
20 stars 7 forks source link

SI units? #47

Open MartinMalinda opened 9 years ago

MartinMalinda commented 9 years ago

I cant find any information what is the format of the audio and light data. Is it possible to convert that value somehow to lux and Bel values? Is it possible to use the module in a way to measure light and noise responsibly, e.g. is it precise? If so it would be great addition to the climate module for me.

Thanks in advance for any response.

jiahuang commented 9 years ago

The values are read by calling analog read on the corresponding audio/light sensor. This is then normalized according to the max analog read (1024).

You could technically convert this to lux/bel values by getting a lux meter and mapping the values. Not sure if there's a better way to do it. @ekolker any ideas?

ekolker commented 9 years ago

Way ahead of you, Jia.

Background: I did the hardware design, @johnnyman727 did most of the firmware. SI units weren't something we designed for explicitly, but that doesn't mean you can't make some measurements to calibrate the device or solve for the transfer functions. Right now, we basically aim to provide resolution on the order of "is it loud/bright?"

The module's schematic is here. You'll also probably need the datasheet for the phototransistor and the microphone.

The phototransistor's current passes through a 1k resistor, then a buffer and a filter, neither of which should change its amplitude.

The sound side of the module is a fair bit more complicated, but it has the added benefit of being adjustable (this also means that, statistically, it's less likely to be uniform from one board to another, but also that you can compensate for this fact). I actually did a presentation on how it works, complete with some LT SPICE simulations, but the basic steps on the signal path are below:

The second to last part means that, sadly, the system is nonlinear in the Signals And Systems sense of the term because it has that DC offset. That said, in a mathematical sense, there should be a y = ax + b-style linear relationship between the mic signal and the value you get out with our API.

All the while, the signal needs to stay within the 3.3V rail (plus whatever our op amp needs) or it will saturate.

ekolker commented 9 years ago

Also worth mentioning that all the resistors on that board are 5%. This basically just means that the best and fastest way to figure all this out is to calibrate everything to a known-good source...which you should probably do anyway.

MartinMalinda commented 9 years ago

Thank you so much. Luckily the light measuring is much more important for me than sound. It looks like the spectral sensitivity is quite different than that of human eye. It peaks at 900nm while human eye does at 555nm, that could produce higher values in the mornings and evenings when the light wavelengths are higher. Unfortunately my hardware skills are still super basic so I am left with software solutions mostly. I will try some calibrations and mappings and see if I can produce any reliable values.