The MASM Forum

General => The Campus => Topic started by: ImmortalPr1nce on September 07, 2013, 01:53:49 AM

Title: Simple pulse counter and emitter program
Post by: ImmortalPr1nce on September 07, 2013, 01:53:49 AM
Ok so i know very little about programming but i need to make find a pic and make a program that will count pulses and every 53 pulses emit 1 pulse. the pulses will be coming from an induction magnetic pickup. can someone point me in the proper direction to get me started?
Title: Re: Simple pulse counter and emitter program
Post by: hutch-- on September 07, 2013, 02:08:10 AM
Usually someone who cannot write their own software pays someone else to do it for them. try Rent A Coder.
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 07, 2013, 05:25:49 AM
you don't need a program, you need a circuit
induction pick-ups are tricky little beasts, especially in noisy environments
you can probably google a simple transitor circuit, though
try looking around at "flow meter circuits"
they typically use magnetic induction pickoffs - some are RF induction types

as for the "divide-by-53" circuit
use a CD4040 (or MC14040) with a few gates (i would use a CD4081, i think)
wire the gates on the output to "detect" the value 53 (that's 4 bits of binary)
when 53 is reached, reset the 4040 and use the reset pulse for output
it will be a narrow pulse, but you can make it wider with an R-C time delay

that'll be $50   :P
Title: Re: Simple pulse counter and emitter program
Post by: anunitu on September 07, 2013, 05:43:13 AM
Hay Dave,You have any "Ray gun" Circuits? Just a little one though,enough to melt a small car.... :dazzled: :shock: :badgrin:
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 07, 2013, 05:49:05 AM
i new a guy named Ray Gunn, once
does that count ?   :lol:
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 07, 2013, 06:10:36 AM
Did he have any Gunn diodes?  :biggrin:
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 07, 2013, 06:27:08 AM
his brother, Peter, may have   ::)
Title: Re: Simple pulse counter and emitter program
Post by: Magnum on September 07, 2013, 07:08:46 AM
I could use a ray gun too with dealing with some Lin@x "help" groups.

Andy

Vater gib mir bitte mehr Geduld.

Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 01:58:07 AM
With a PIC, I suggest a 16F84A, use RA4T0CK as input to the TMR0, initialize the TMR0 with 203, set the interrupt of the TMR0 overflow, to generate the pulse, use a sub routine, some delay to shape the width of the pulse, and you are on your way, is hard to build circuits in noisy enviroments, make sure your PCB is properly shielded.
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 03:14:18 AM
a quicky sketch....

(http://img23.imageshack.us/img23/5811/isw.gif)

you are looking at about $1.50 in parts   :P
it will run from 5 to 15 volts and draws nano-amps
unless there is some reason for going with a PIC, i say keep it simple   :t

of course, there is still the amplifier circuit, but that would be needed, either way
Title: Re: Simple pulse counter and emitter program
Post by: qWord on September 10, 2013, 03:48:31 AM
dave,
that look nice, but isn't it problematic to connect the reset port with the AND-gates (because of glitches / race conditions)?

EDIT: OK I see you use a capacity to avoid that problem(?).
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 03:55:11 AM
no - that should be pretty reliable
you may have to play with the R-C values, to pick a more suitable time-constant
i picked those values out of the air, but i have been playing with CMOS for about 35 years - lol
you could drop the 100 K resistor to about 10 K for a narrower pulse
you could even eliminate the capacitor and use a larger resistor
the RESET input has something like 5 pf capacitance, on it's own

as for glitches - well - you put a cap on the power supply lead, of course
CMOS has pretty good noise-immunity

there is no race condition in this circuit, per se
there is a time-delay (we call it propagation delay) across the counter and each gate
in this case, the delay is actually desirable
we even add an R-C circuit to make it longer, so that the pulse has a little more width

race conditions occur when you expect state transitions to arrive at a gate at the same time
one logic path has a long delay and the other path has a short one - that is a race

i might add....
you can hard-wire any practical divisor you like
53 is 110101 binary, which corresponds to the selection of Q6, Q5, Q3, and Q1
those four outputs all go hi -> little time delay -> the counter resets and starts over
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 04:17:13 AM
One could also do it with a small 8 pin micro.

(http://s13.postimg.org/fw5fmaj4n/Simple_Pulse_Gen.jpg)

Datasheet here:

http://www.atmel.com/Images/1006s.pdf (http://www.atmel.com/Images/1006s.pdf)
Title: Re: Simple pulse counter and emitter program
Post by: qWord on September 10, 2013, 04:19:22 AM
Quote from: dedndave on September 10, 2013, 03:55:11 AM
as for glitches - well - you put a cap on the power supply lead, of course
CMOS has pretty good noise-immunity
I thought on glitches that are caused by the propagation delay Qn -> Qn+1 (TI says 100ns @ 5V).
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 04:26:44 AM
Quote from: qWord on September 10, 2013, 04:19:22 AM
Quote from: dedndave on September 10, 2013, 03:55:11 AM
as for glitches - well - you put a cap on the power supply lead, of course
CMOS has pretty good noise-immunity
I thought on glitches that are caused by the propagation delay Qn -> Qn+1 (TI says 100ns @ 5V).

I must admit that I thought about that too.
Would it not be better to use a 4 input AND gate instead of cascading 2 input ones?
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 04:29:06 AM
you are talking about the delay between Q outputs
because it is a ripple-carry counter, that is a possibility
but, when you are decoding a single specific value on the output, it shouldn't be an issue

you'll just have to trust me - lol
i have used similar decoding dividers many, many times   :biggrin:
Title: Re: Simple pulse counter and emitter program
Post by: qWord on September 10, 2013, 04:38:28 AM
Quote from: dedndave on September 10, 2013, 04:29:06 AMyou'll just have to trust me
I do  :P
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 04:44:22 AM
How about a "gated" counter?
An extra chip but this way no chance of glitches.
(note that RC time delay not shown on reset going to counter).

(http://s10.postimg.org/n72wwqd0p/Gated_Counter.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 05:58:53 AM
hello Paulo, the idea is good, but how the output pulse is generated?, with your circuit will be needed an additional input clock to lower the output of the gate.
Title: Re: Simple pulse counter and emitter program
Post by: qWord on September 10, 2013, 06:11:17 AM
Quote from: georg on September 10, 2013, 05:58:53 AM
hello Paulo, the idea is good, but how the output pulse is generated?, with your circuit will be needed an additional input clock to lower the output of the gate.
The latch triggers on falling edges. Therefore the reset is delayed by the duration of the input pulse (AFAICS).
Title: Re: Simple pulse counter and emitter program
Post by: qWord on September 10, 2013, 06:20:24 AM
OK, I see - the latch needs also a rest input. Otherwise the output will be reset for the falling edge of the next pulse.
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 06:38:05 AM
Quote from: georg on September 10, 2013, 05:58:53 AM
hello Paulo, the idea is good, but how the output pulse is generated?, with your circuit will be needed an additional input clock to lower the output of the gate.

Good point, I missed that.
I will redraw the circuit.
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 06:48:18 AM
yes - that's the issue - between synchronous and asynchronous counters

synchronous counters use the same clock input for all stages
transitions on all ouptuts are synchronized

(http://sub.allaboutcircuits.com/images/04353.png)

asynchronous counters (including ripple-carry counters like the 4040)
use the output of a previous stage to clock the next successive stage

(http://daniel.robert9.pagesperso-orange.fr/Digit/images/Compteur_asynchrone_binaire_a_12_bits_CD4040.gif)

when the later method is used, there are small periods
when the overall output value may be invalid, as qWord suggested
there are sometimes "glitches" or small spikes that might occur in a decoder
and - it can be overcome by latching the outputs, as Paulo mentioned

fortunately, CMOS is not very fast - lol
at 12 VDC, you're doing well to get a 4040 to count 10 MHz
the width of the spikes is small enough that a gate doesn't decode them   :biggrin:
and - the minimum reset pulse width is probably longer than the spike - lol

this can be a big problem when working with TTL circuits, because they are a bit faster
i really like playing with CMOS   :t
low power consumption - good noise immunity - wide operating range - inexpensive
it's great for things that don't need to haul ass   :P

anyways.....
as you can see, it wouldn't take much to use a synchronous counter
we only need 6 stages
with a little extra circuitry, i could make a near-squarewave output, too
but, for what he wants to do, my original cicuit will work fine
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 07:22:13 AM
An RC circuit could solve the problem, like Dave's schematics.
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 07:29:05 AM
like a high band filter;
                                    C
          And Gate >-------| |---------------------> Reset
                                                |
                                                |
                                               | | R
                                               | |
                                                |
                                               \/
                                             GND
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 07:38:59 AM
How about?

(http://s18.postimg.org/703sman3t/Gated_Counter2a.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 08:01:45 AM
that's a good one, but you can make Reset the real output, with another AND acting as a follower, and a high-band filter, are two options anyway. EdITED: with the solution you provide.
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 08:07:06 AM
One could certainly use the RESET output as the main output.
To buffer one could use another gate or even a BS170 type FET if another gate was not available.
The FET would provide a low impedance output whilst not loading the RC circuit like a BJT would.

Luckily the 4082B has two quad input AND gates so could use the second one to buffer the RESET output.
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 10, 2013, 08:07:34 AM
No adding cost with that AND gate, the package for a four input AND come with two gates I believe.
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 08:11:50 AM
Very true, I modified my previous post.

(http://s18.postimg.org/nceaveid5/4082.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 08:40:34 AM
I would still be tempted to use a small micro as it's easy to reprogram if any changes are required (no hardware changes needed)
and it's easy to include a RS232 output with the addition of some code and a MAX232.
A USB to Serial convetor would also work.
This could be a very handy feature for logging.

(http://s7.postimg.org/sxpk451wr/Counter_With_Serial.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 06:36:23 PM
What I have done in the past for a quick and dirty solution to monitoring external pulses
is make a simple keyboard interface and a small script to display the results.

Keyboards are very cheap these days, hack one open and connect the following circuit in
parallel with the "Y" key.

(http://s7.postimg.org/4eq1ldl8r/Key_Board_Mod.jpg)

A few notes:

1) Obviously the input pulses cannot have too high a frequency or too short a duration (depends to a certain extent on your telematic repeat rate).

2) The batch script uses the CHOICE command which for some reason is not available in XP (and NT I think) but is in Windows prior to XP and after it.
To get CHOICE for XP, download it here (from Microsoft):

ftp://ftp.microsoft.com/Services/TechNet/samples/PS/Win98/Reskit/SCRPTING/choice.exe (http://ftp://ftp.microsoft.com/Services/TechNet/samples/PS/Win98/Reskit/SCRPTING/choice.exe)
Note that the CHOICE version from the above link has a slighlt different syntax to the standard one, so check the help and modify the script as required.

3) Edit the DivisionRatio variable to the required number.

4) Never bothered to convert the batch file to a proper exe as it serves my needs perfectly without the need for messing about with com ports, USB or the like.


:: ========================================
:Start
:: ========================================

:: Change The DivisionRation variable to
:: required division ratio.
:: I have set it to 4 just for quick testing

cls
@echo off
setlocal EnableDelayedExpansion
set count=0
set DivisionRatio=4

echo Press y to carry on or N to terminate
echo ^|

:: ========================================
:MainLoop
:: ========================================

choice /N >null
if '%errorlevel%'== '1' goto CarryOn
if '%errorlevel%'== '2' goto End
goto MainLoop

:: ========================================
:CarryOn
:: ========================================

set /a count+=1
if '%count%'=='%DivisionRatio%' goto Display
goto MainLoop

:: ========================================
:Display
:: ========================================

echo ^|
echo ^|
echo ######## %TIME%
echo ^|
echo ^|
set /a count=0
goto Mainloop

:: ========================================
:End
:: ========================================

echo Terminated.


To test without the interface, start the batch file, it will wait for input, now press the Y key 4 times, it will display ###### TheCurrentTime.
It will continue in a loop until one presses the N key.

To "catch" faster or narrow pulses it's possible to use a "prescaler" circuit instead.
The total division ratio then becomes PrescalerDivision X DivisionRatio (in the script).
There are limits to this and don't expect to process very fast or narrow pulses.
The script has limitations mainly due to the processing time (writing to screen and so on) and also the response time of the keyboard buffer
but as a quick method to monitor an event and perhaps log to file it works a treat.

(http://s10.postimg.org/4bbc2ucqh/Prescaler.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 08:05:43 PM
yikes !   :icon_eek:

just hook it up to a serial port   :P

stay away from my soldering iron, Paulo - lol
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 08:34:35 PM
a while back, Marinus mentioned something about using the sound port as an A-D converter
that has possibilities, too
all you need is a decoupling capacitor...
...and some FFT code   :P
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 08:36:55 PM
Quote from: dedndave on September 10, 2013, 08:05:43 PM
yikes !   :icon_eek:

just hook it up to a serial port   :P

Of course a serial port or even LPT is a better choice but not many PC's have them these days and guaranteed a USB to serial is never at hand when needed.
Plus to monitor a single slow frequency event, programming the serial port is much more effort.  :biggrin:
First did this many years ago and still have the old (PS2) keyboard with the opto inside and a RCA connector sticking out the back to enable me to connect all
sorts of interface circuits to it.
Still use it every now and again.

Plus these days one can pick up a USB keyboard for about 5 bucks.
Every experimenter should have one of these.  :biggrin:

Quote from: dedndave
stay away from my soldering iron, Paulo - lol

Don't worry, I have a nice Weller Soldering station.  :biggrin:
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 08:40:43 PM
A sound card is also feasible and especially the new ones that support 192KHz sample rate.
Still can't beat the old batch script + hacked keyboard for simplicity though.  :P
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 10, 2013, 10:20:45 PM
the line input port has a lot of possibilities
may have to play with that, some day
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 10, 2013, 10:46:38 PM
Another possibility is the VGA output, yes VGA.
It has I2C on two of the pins (15 and 12) which is used by the OS to get monitor info.
As far as I know the OS always checks the monitor capabilities at a fixed I2C address (0x50 if I remember correctly)
so theoretically one could put other I2C chips (set to different addresses) on the bus and the OS would not find them but an app written especially could.
There are lots of I2C chips available ranging in function from attenuators to output latches.
In "the other OS" it's not too difficult to do, don't know how to in Windows though.
Title: Re: Simple pulse counter and emitter program
Post by: Siekmanski on September 11, 2013, 12:23:48 PM
Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113 (http://masm32.com/board/index.php?topic=1239.msg12113#msg12113)
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 11, 2013, 01:04:47 PM
hi Marinus

you could even go wireless   :P

http://proto-pic.co.uk/2-4ghz-transceiver-ic-nrf24l01/ (http://proto-pic.co.uk/2-4ghz-transceiver-ic-nrf24l01/)
Title: Re: Simple pulse counter and emitter program
Post by: Siekmanski on September 11, 2013, 04:10:47 PM
Hi Dave,
I've got 2 of those breakout boards with that chip, but nothing done with it yet.
Done some experiments with a bluetooth chip (BTM222), they work like a charm.  :biggrin:
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 11, 2013, 05:36:37 PM
Quote from: Siekmanski on September 11, 2013, 12:23:48 PM
Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113 (http://masm32.com/board/index.php?topic=1239.msg12113#msg12113)

I quite like the FT232 and have also used the 245 (parallel version).
Another nice interface chip is the ENC28J60 stand alone ethernet interface with SPI port.
http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf (http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf)

The reason I posted the other circuits is that I enjoy unusual ways of interfacing computers with real world devices.
One of the whackiest was back when the top of the range computer was a 286 and a friend that owned a small store wanted motion detection on the CCTV system
which would trigger an alarm, log the date and time and also start a VCR to record for a few minutes.

He had one camera covering the back door and another for the front of the store.
I got an LDR plus small suction cup and placed it on the CCTV monitor covering the required area.
The LDR was connected to a comparator and an edge detector so when the picture content that the LDR was "seeing" changed, it would give an output to the LPT of the computer
which would log the date and time and also trigger a VCR to record for a few minutes.
All programmed in either GWbasic or Qbasic, can't remember which.

He was very happy and told a few other people.
I landed up selling a few of these crazy setups and made a few bucks in the process.

These days one can get a complete CCTV system with DVR for several hundred bucks but back in the day, can you imagine getting a 286 to grab video, do line selection then analyze that data.
It would take for ever.

The circuit went something like this:

(http://s23.postimg.org/eso3un3uz/CCTV1.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: K_F on September 12, 2013, 05:42:41 AM
Quote from: dedndave on September 10, 2013, 03:55:11 AM
.. but i have been playing with CMOS for about 35 years - lol
Usefull things CMOS..
This XRF machine we had, leaked coolant (water) every now and then, which would blow the Xray tx.
The water would flood the floor under the machine and of course nobody would be able to see this.
The company quoted some ridiculous price for replacement parts, which were not necessary.

Brite spark here, got a PP9 battery.. 1x CMOS chip (cannot remember which), vero board, piezo buzzer, and 2x short brass rods that extended out of this small plastic box onto the floor.
Essentially it was a touch sensor which set off the piezo... water contact did the same thing. Placed this under the machine where the water usually flooded.
The battery lasted 2 years at my last check.. then I left. They never blew another transmitter. The cost might have been 2USD, but it saved 1000s of USDs
A simple very low power cmos device...
:)

Title: Re: Simple pulse counter and emitter program
Post by: georg on September 12, 2013, 12:38:29 PM
Quote from: Paulo on September 11, 2013, 05:36:37 PM
Quote from: Siekmanski on September 11, 2013, 12:23:48 PM
Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113 (http://masm32.com/board/index.php?topic=1239.msg12113#msg12113)

I quite like the FT232 and have also used the 245 (parallel version).
Another nice interface chip is the ENC28J60 stand alone ethernet interface with SPI port.
http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf (http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf)

The reason I posted the other circuits is that I enjoy unusual ways of interfacing computers with real world devices.
One of the whackiest was back when the top of the range computer was a 286 and a friend that owned a small store wanted motion detection on the CCTV system
which would trigger an alarm, log the date and time and also start a VCR to record for a few minutes.

He had one camera covering the back door and another for the front of the store.
I got an LDR plus small suction cup and placed it on the CCTV monitor covering the required area.
The LDR was connected to a comparator and an edge detector so when the picture content that the LDR was "seeing" changed, it would give an output to the LPT of the computer
which would log the date and time and also trigger a VCR to record for a few minutes.
All programmed in either GWbasic or Qbasic, can't remember which.

He was very happy and told a few other people.
I landed up selling a few of these crazy setups and made a few bucks in the process.

These days one can get a complete CCTV system with DVR for several hundred bucks but back in the day, can you imagine getting a 286 to grab video, do line selection then analyze that data.
It would take for ever.

The circuit went something like this:

(http://s23.postimg.org/eso3un3uz/CCTV1.jpg)

hey man that's classified!!  :dazzled:
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 12, 2013, 12:49:14 PM
it's a very cool idea, but really I need to cover some wide area, not only CV, but also is useful speech recognition in my case
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 12, 2013, 04:49:03 PM
Hi georg

I'm not sure what you mean by CV.

As regards speech/voice recognition, you have a few choices:

1) Use a library or add-on such as:
(Note that I have never used them)

http://voce.sourceforge.net/ (http://voce.sourceforge.net/)

http://code.google.com/p/dragonfly/ (http://code.google.com/p/dragonfly/)

2) Try WSR (Windows Speech Recognition).
It was first released with Vista but it is included with 7, just tried on my 7 box and it's there.
See here:

http://windows.microsoft.com/en-us/windows-vista/common-commands-in-speech-recognition (http://windows.microsoft.com/en-us/windows-vista/common-commands-in-speech-recognition)

3) If you just want to detect speech but not interested in actual words, you may want to try a bit of FFT, you may even be able to code something on a micro such as the ATmega range.

4) Human speech is mainly concentrated in the range 300Hz to around 3KHz so perhaps experiment using several tone decoders.
The more you use the less false triggers you will get.
Don't know how accurate and reliable a method this will be.
Perhaps something like this:

(http://s13.postimg.org/ud430jtzr/Speech_Det.jpg)

Datasheet for LM567 tone decoders here:
http://www.ti.com/lit/ds/symlink/lm567.pdf (http://www.ti.com/lit/ds/symlink/lm567.pdf)

To make a more "intelligent" circuit, replace the AND gate with a micro, then you could pgm the micro to give a valid output
if certain combinations of tones/frequencies are present.

You could also replace the tone decoders with active bandpass filters (using op-amps) and then rectify each frequency output.
See here"
http://www.seattlerobotics.org/encoder/200003/AudioDetector.gif (http://www.seattlerobotics.org/encoder/200003/AudioDetector.gif)

Although in my circuit above, I chose random frequencies (between 300 and 3000Hz), you may want to be more scientific
about it and choose them according to this:
http://www.newscientist.com/article.ns?id=dn4031 (http://www.newscientist.com/article.ns?id=dn4031)

5) Use a DSP chip like those available from Ti.
http://www.ti.com/lsds/ti/dsp/overview.page (http://www.ti.com/lsds/ti/dsp/overview.page)
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 12, 2013, 09:51:45 PM
i think they use FFT in software, rather than hardware, to do that
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 12, 2013, 11:38:27 PM
Hi dedndave
Agree 100% that proper voice recognition is done via software but if all one wants is to detect if there is speech rather then wanting to detect actual words then either software or hardware can be used.
The hardware option may be simpler to implement but will certainly not be as accurate or flexible as using a pure software based FFT.
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 13, 2013, 01:06:14 AM
Hi Paulo CV, stands for 'computer vision'
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 13, 2013, 01:15:44 AM
As always, is not a bad idea to do it in hardware, the FFT is fine, especially if you can trigger an alarm and record a few minutes of sample. as you did in your motion detector.
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 13, 2013, 01:57:30 AM
Quote from: georg on September 13, 2013, 01:06:14 AM
Hi Paulo CV, stands for 'computer vision'

Aaahh OK got it now.

Quote from: georg
As always, is not a bad idea to do it in hardware, the FFT is fine, especially if you can trigger an alarm and record a few minutes of sample. as you did in your motion detector.

Did a quick frequency analysis and below is the result showing frequencies and closest note on musical scale.
(http://s22.postimg.org/5vycli88x/Freq_Plot.jpg)

So if you decide on the hardware option, set up say 12 (or more)  "monitoring" frequencies  ranging from A4 (440Hz) to around F7 (2793Hz) as most speech will fall between these
then get a micro to give an output if more then 75% of them are present.
The chances of other "noises" containing such a high percentage of these frequencies will be rather low.
Of course it will be a compromise between checking on how many of the "notes" are present and rejecting other "noises" by making the percentage high versus the possibility
of missing some speech by reducing that percentage but increasing the chances of a false trigger.

Frequencies of musical scale here:
http://www.phy.mtu.edu/~suits/notefreqs.html (http://www.phy.mtu.edu/~suits/notefreqs.html)

It all depends on what you are trying to achieve with your project.
If you want to build something just to tinker and for the educational value, then go the hardware route.
However if you want to make a commercial product them I would say rather go the computer+software FFT route.
These days computers are very cheap compared to the processing power you get for your buck (even a entry level PC will have more than enough grunt).
Keep in mind that when I did the ldr motion sensor, computers did not have the capability they have now and stand alone DSP chips, Pics and ATmegas did not exist
so I had to make do with what was available.
Title: Re: Simple pulse counter and emitter program
Post by: georg on September 13, 2013, 03:46:19 AM
I'm very aware of the limitation at that time Paulo, but your idea is very good because is easy to implement, and is very very cheap, I'll keep in mind your suggestions, very good approach  :eusa_boohoo:
Title: Re: Simple pulse counter and emitter program
Post by: dedndave on September 13, 2013, 04:47:58 AM
some amateur radio equipment uses 300 to 2400 Hz
that's probably a little tight for someone with a high voice, like a female

but, for speech recognition, you could probably get all you need from 350 to 2450 Hz
likely you don't even need that much
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 13, 2013, 05:05:19 AM
Hi dedndave

Interesting point so ran another frequency plot but this time with a woman saying hello.
Below is the unfiltered response:

(http://s15.postimg.org/qty6h4g5n/Freq_Plot_Woman.jpg)

And with filtering.
As can be seen, most of the speech is still within the pass band so unless the person has just inhaled a lot of helium gas,
350 to 2400Hz should be fine.  :biggrin:

(http://s13.postimg.org/vpekl0lxz/Freq_Plot_Woman_FIltered.jpg)
Title: Re: Simple pulse counter and emitter program
Post by: Paulo on September 13, 2013, 05:11:31 AM
georg

Glad you liked the idea.
Sometimes doing things in an unconventional manner pays off   :t