Optical gate and microphone, preparation for future projects
Used tools, methods and technologies:
This week was time for some electronics. I spent my time this week remebering Arduino programming and testing key sensors for my future projects. And prepared a PCB design for a bigger project coming up next week. I also got into Fritzing to improve my ability of showing my schematics.
Microphone
First, I tried an microphone module with an integrated amplifier. It could detect sound, but on a very tight range and unreliably.
A operational amplifier (Op-Amp) solved it, but I rather builded a whole new circuit off my own to test out specs of a better microphone. A single part microphone with a built in pre-amplifier which I intended to use in a future project. Circuit and its schematics can be seen down below.
The future project I intend to build will be an Arduino-based tuner device. It will have a OLED display and a 8x8 LED matrix to show the output. It will actually have multiple purposes, like a frequency analyser and sound visuliser.
Fritzing schematic of the Op-Amp circuit with microphone
Scheme of the prototype circuit for reference. You can really tell the difference! Try connecting pins from this image alone.
Opto-interruptor
Second sensor I tested out was a opto-interruptor. Its an optical based sensor of position. V shaped case holds a diode and photodetector facing each other and when beam from diode is interrupted by an object, the drop of voltage generated on the photodiode detector is amplified and measured by a microcontroller.
So its binary sensor, ON/OFF, optical switch of sort. But it can be used in various use cases. In mine, I plan to use it to measure RPMs of a rotating disk in my final project. The disk will have a small cut-out on its side that will once per rotation pass right through the opto-interruptor. The cut-out will open the optical way interrupted bz the disk before. At 1920 RPM I aim to have ¨ the disk spinning at it has to be fast. That's 32 RP second! I will most likelz olso be my source of disk orientation, since stepper motors are not powerful enough and I am going to use a strong DC motor.
Math and code
The code is simple. Program detects binary state of the signal/gate and sets a variable at this state: obstructed = true/false. Then if checks previous state of this variable. The hole is more then one point big, so it can´t just wait for the unobstructed state. Rather, it detect what can be called leading edge in signal theory. Only if the previous state was unobstructed and now it is obstructed state, program counts it as detection of a new rotation. It measures time between each rotation, period T in microseconds and uses a simple formula to count the frequency: f = 1000000/(t*1000) in Hz. This is based on just one measurement, so it is a very unstable measurement. But I will frequency of a wheel spining at very much constant speed and without much friction or distortions that would change it, so its intended.
I also tried a different method. Counting revalations of the disk in a second with the same principle as before, which is actually the RPM of the wheel by definition. But this approach has a problem: it can only detect whole number frequency. If the RPM is for example 1800.4 , it will display only 1800. So that is a little bit unprecise and I´m pretty sure, it will not work for the final project. Its the second code, _count.ino . Arduino code can be downloaded down here:
Fritzing schematic of the opto-interruptor circuit with microphone
Scheme of the prototype circuit for reference
measured carboard wheels. I wanted to save time and filament
Summary
For two wheels from cardboard I measured around 2900 RPM for the bigger 60 mm diameter one and around 8000 RPM for the smaller 24 mm one. These rpm´s are well enough for my final project, so this sensor will do good. I am only considering a smaller one.
That is all for this week. Next time, a big project will be assambled using the microphone circuit from this week.