Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help selecting microcontroller

Status
Not open for further replies.

joejohn

New Member
I can use some help selecting the most efficient microcontroller / demo board for my project.

The MC will need to trigger on a analog signal input (a microphone), so should be able to handle A2D. Also be able to produce a reasonably clean sine wave at moderate frequencies (< 40KHz max). By clean, I just mean that an audio amp should be able to amplify the signal. I'm not going for hi fi quality sound or anything like that. Those are the 2 main needs of my project. Very simple chip should do.
 
Are you looking for an MCU that will perform full on audio signal processing/DSP? Or is the microphone just being used as a sound activated "trigger"? Perhaps we could be of better assistance if you tell us exactly what you're trying to build.
 
Last edited:
"most efficient" is much harder to use (specially by inexperienced) than "all bells and whistles".
 
Yes, the mic input will be used as a general sound activated trigger. Would like to be able to trigger on loud offensive sounds. And not on small sounds. I think a high/med/low sound sensitivity would be fine.

In terms of efficient I mean low cost / don't need any extra features. what I'm really looking for is a cheap dev board with some i/o connectors, a dc power jack, and can output a sine wave up to 40KHz.

As far as program size, I can't imagine id need more than 100 lines of code to perform the logic. Perhaps as little as 50.

On a scale of things this is a ultra simple project. I'm guessing a 8bit MC could handle it.
 
Last edited:
to generate sine wave at 40kHz you need either at least 80kHz pulse output and filter. you will not have much control over such signal without doing things externally (amplitude control for example).

if you want to use DAC and have full control in the MCU, then you need to choose resolution and type of DAC. if you are using parallel DAC, sampling does not need to be nearly as fast as for serial DAC (SPI or I2C for example).
 
I thought MCUs usually have a frequency output where you just tell it what freq to use and it produces a sine wave. I've heard on at least one like this it needs an external cap to filter/clean up the wave. Is that what you mean? Why 80KHz? By pulse output do you mean a square wave? Id rather go with a MCU that does a sine wave for simplicity. I reason that a DAC can produce the analog sine.
 
my bad, we are not sampling... i am way too tired and should avoid posting when it is this late (or early).

functionality of microcontrollers vary but in general same principles apply.
for example if you are using PWM, you can set frequency and duty cycle.
note that such signal will be square, not sinusoidal.
you can use filter to remove higher harmonics and keep only fundamental frequency component.
square wave can be repersented as sum of bunch of sinusoids (f, 3f, 5f, 7f....)
note that even harmonics cancel out if the duty cycle is 50%.
amplitude of higher harmonics decreases but to get pure sine output, you need to remove everything but f (frequency you want).
quality of output will depend on your filter, higher order in general produces cleaner output because of sharper cutoff.

downside of doing this is that if you change f (unless change is small), you also need to change filter cut off frequency.

if you do not know precisely what frequency this has to be or if you want more control, you can use DAC to generate sine from lookup table.
overhead will have different impact depending on type of interface (parallel/serial).
if you send data through parallel interface you get faster throughput but this ties more IO pins.
the better quality you want, the more IO pins you need to sacrifice (and get better DAC).
this approach allows you to change amplitude, frequency and offset using just program.
filter can be very simple (RC for example) and it should still be ok over wide range of frequencies.
DAC simply converts digital value to analog (hence Digital to Analog Converter or DAC).
 
Dog bark stopper?

I think the project is done more easily with a 2 transistor vox to detect audio at the microphone, then something like a 555 timer to make the output tone and some RC filtering after the 555 as it is unlikely to need a perfect sine, just something that will transfer a reasonable amount of power to the amp and transducer.

The vox amp and output amp both need to be made anyway, so basically you are swapping a microcontroller for a cheap 555.
 
Yep a bark zapper!

I was thinking a MC with a built in DAC (to generate sine output) and ADC (to sense bark via microphone input) would be the easiest way to go. I have limited access to lab equipment to analyze/test.

Can a DAC produce a good enough quality sound wave to which an audio amp can boost it? If a external filter is needed I can go that route, but only if its necessary for the amp. I doubt the dogs will care if it sounds perfect or not. Id like to make a melody if possible that ranges from 20KHz to 40KHz. I think a lookup table would serve well for this. Is there any MC that you would recommend? I doubt id need a parallel output for this.

Thanks for the replies
 
Simple micros typically don´t have DACs, so if you could bear with a slightly rounded square wave things will be much easier.
Also, does the sinewave need to be variable? If it needs to be as sine-wave-like as possible, you could trigger some external oscillator with the micro.

Edit: Now I noticed the bark zapper thing, I am pretty sure the dog won´t care whether it is sine or square wave. So some 8pin micro with ADC should do the job very easily.
 
Last edited:
Dog bark stopper?

I think the project is done more easily with a 2 transistor vox to detect audio at the microphone, then something like a 555 timer to make the output tone and some RC filtering after the 555 as it is unlikely to need a perfect sine, just something that will transfer a reasonable amount of power to the amp and transducer.

The vox amp and output amp both need to be made anyway, so basically you are swapping a microcontroller for a cheap 555.

I've though about using a 555 but I'm affraid my programming skills are better than my electrical skills.
 
may i offer something else to think about?

i think defining what you want and need is good starting place - let's see what is reasonable.

first of all, no dog hears 50kHz or above. some university research has found upper frequency limit any dog can possibly hear to be some 46kHz or so:
https://www.lsu.edu/deafness/HearingRange.html

next, if you are generating square wave with 50% duty cycle (it does not get simpler than this), even harmonics cancel out.
all you get is fundamental frequency (1x) and odd harmonics (3x, 5x, 7x, 9x, 11x...).
their magnitude decays quickly so even if the dogs could hear it, we would probably be very little
interested in anything above 5x or 7x.

but since the frequency range you are interested in is 20...40kHz, and lowest harmonic is 3x which is
60...120kHz, this is already outside of hearing range of any dog.

if they cannot hear 3x, then they certainly cannot hear 5x, 7x etc. of your frequencies.

in other words - you can filter or not, they won't notice the difference.

next thing is what is the frequency response of your speakers?
even IF you were to drive them with a perfect square wave (with steep slopes), they will NOT be able to reproduce signal exactly.
if speakers cannot reproduce signal, there is no point in making pure sine signal, using hifi amp etc.
speaker is one of natural filters in the "osc-amp-speaker-ear-brain" chain.
the weakest link (lowest frequency limit) is what determines bandwidth of entire chain.

one of them was ear as mentioned before. amp will be another component that has limited frequency response
so it will also act as a filter (although this one can easier be realized with such characteristics to not be the weak link).
filtering before amp simply affects efficiency of the circuit because if we remove higher harmonics,
which are not even used, your amp would not need to amplify those components.

so if we are generating some signal, even square wave is acceptable. suppose we are not happy with that and we would rather have something that resembles sine wave to some degree to attenuate most of harmonics.

with 4 bits, you can have 16 levels. so your sine would look something like
https://en.wikipedia.org/wiki/File:Pcm.svg

given all the restrictions in hearing, speaker response etc. this is not only good enough, it is way above what is needed for the job as no filtering is required. and for only 4bit or less, simple resistor DAC is more than acceptable.
https://en.wikibooks.org/wiki/Circuit_Idea/Parallel_Voltage_Summer

how about 1k, 2k, 4k, 8k? (or 1k, 2.2k, 3.9k, 8.2k)

so can you think of any MCU that can pump out 4-bits to one of the ports at 40kHz? i cannot think of any that can't...

the next question is how small this has to be? how much can it cost? you can get MCU kits for $5
https://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)

or you gen get board with cortex processor (32bit, 64k Flash, 8k ram, and TONS of IO) for mere $8
https://www.digikey.com/product-sea...-and-kits-mcu-dsp-fpga-cpld/2621773?k=stm32f0
 
Last edited:
Great analysis! Thanks!

I found this tweeter which seems to handle the frequency range that I need: **broken link removed**

If you know of something better, please let me know.

Do you think a 4-bit resolution sine wave will mess up an audio amp? I've heard either amps or speakers (thinking speakers now) can be destroyed with square waves. I'm guessing the amp, like you said, will do some filtering on the wave and make it less destructive to a speaker.

So just to be clear, 4-bits would be related to the DAC?

I still need to find an appropriate amp. Any suggestions are welcome.

Thanks again!
 
the problem with square wave is resulting transients when driving inductive load (speaker).
this is why switched DC inductive loads have flyback diodes across.

by reshaping signal into bunch of (small) steps (sine like) rather than one large steep edge (square), resulting transients are much smaller.
the closer the approximation to a sinewave (more bits to DAC), the less artefacts and less trouble.
 
That depends panic mode, the bit depth of a DAC can have it's harmonic components removed with a slew rate limiter or filter circuitry. More bits are not always needed for low harmonic distortion.

If the micro can generate a high enough frequency square wave a simple resistor and capacitor can be used as a low pass filter to remove higher harmonics.
 
Ok good to know. I was reading up on the MSP430 LaunchPad. It looks like a really great valued product. Do you know if the MSP430 chip can pragmatically output 20K-40KHz waves though? It didn't appear to have a DAC in the limited reading I've done so far. Further I found someone's project that appears to connect it to a TI TLV5620 (4 channel 8-bit DAC) for wave generation. Do you know if this is required for this particular product?

Here's the guys project I was talking about:
**broken link removed**
 
@sceadwian
i know, that was mentioned earlier (post 7)

@joejohn
one measure of performance is MIPS (millions of instructions per second) which depends on
clock and how many clocks each instruction takes (CPI). then you need to figure how many instructions are
needed for one loop iteration...

supposedly some arbitrary MCU needs 1 clock per instruction and runs at internal clock of 1MHz so we get 1MIPS.

lets say your code happens to needs 10 instructions per loop iteration.
so 1MIPS/10=100000 loops per second (100kHz).

a basic series like MSP430x1xx does some 8MIPS for example.

the other board with cortex processor runs on 48MHz and scores some 38DMIPS, also has 12bit DAC and bunch of ADCs built in
https://microcontroller.com/news/STMicroelectronics_STM32F0.asp
 
I think the Discovery board is sounding promising.

next problem to tackle is amplifying the output wave. I want to send amplified waves through as many as 4 transducers. Is there an amp that can take in the sine wave and output on 4 channels? Or do I need a MC that has 4 DACs with each connected to it's own amp?
 
here is also interesting article
https://www.romanblack.com/onesec/SineDDS.htm

using more channel would make sense if you want to create particular effect (stereo).
while interesting, it looses output power, how much power do you want?
you do not want to liquefy brains or make deaf.
the 200W mentioned can't be real power, either way using 4 of them sounds like overkill...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top