## 1800Hz digital filter

16 posts / 0 new
Author
Message

I'm making lasertagstyle IR-guns for playing with my friends. The gun sends a 38kHz modulated signal to the receiver which demodulates it. Problem is that normal it reacts also on TV-remotes so I modulated the signal again, this time at 1800Hz. Now I want my ATMega8 to react only on signals modulated at 1800Hz signal. Any idea how this can be done? I'm using timer1 and 2 for modulating the signal so I have only timer 0 left. Is it better to use a hardwarefilter? If so, how to design it?

1800 Hz means T/2 = 277.7 usec.

4MHz xtal
prescaler on 8
23 rounds

99.38% -> this will be 276 usec -> f = 1/T = 1/2*276 usec = 1811 Hz.
11 Hz error. (11/1800*100% = 0.61% (not bad ?)

:roll:

Umm... I maybe didn't make myself clear enough. I already know how to generate the signals, I just want to know how to make my uC respond to only 1800Hz modulated signals.
And for powersaving I use 1MHz clock.

Sample at 3600 Hz.

Require that alternate samples be high and low.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Thats good! In thata way I can use the same clock for sending and recieving. Thank you very much!

Posted: 25 May 2004 09:12 pm Post subject:

Sample at 3600 Hz.

Require that alternate samples be high and low.

Jim

Posted: 25 May 2004 09:43 pm Post subject:
Thats good! In thata way I can use the same clock for sending and recieving. Thank you very much!

Also thank Nikola Tesla for that one! 8-)

Tom Pappano
Tulsa, Oklahoma

Tom Pappano
Tulsa, Oklahoma

3600 Hz wont work well. When Sender and Receiver are phase-shifted by 90 degrees your measurements would always be at the rising/falling edge an thus be at 50% signal level. (Thats Shanons theoreme).

You should measure at 7200 Hz, 1 sample is low, 1 high, 2 undefined.

Stephan

What about connecting the signal to T0 and count to let's say 30 pulses and measure the time it takes with another timer? If the timer is runnning at 3600Hz (which mine already is) then it would be about 60 timer cycles. This way it will be possible to compensate for slight deviances in frequency from different transmitters. And I won't have to consider phase shifting. Will it work?

Posted: 26 May 2004 01:17 pm Post subject:
What about connecting the signal to T0 and count to let's say 30 pulses and measure the time it takes with another timer? If the timer is runnning at 3600Hz (which mine already is) then it would be about 60 timer cycles. This way it will be possible to compensate for slight deviances in frequency from different transmitters. And I won't have to consider phase shifting. Will it work?

That should work nicely. Just see if the incoming signal fits inside a time window
to determine a valid signal. I have a product that has been doing exactly that for
a long time, and it works great!

Tom Pappano
Tulsa, Oklahoma

Tom Pappano
Tulsa, Oklahoma

Hi wileur,
why it is 1800Hz and not, say, 38kHz/20=1900Hz.
Is it pure or coded IR signal?
Best regards, Szymon

It works like this: The 38kHz signal is the carrier that receiver reacts on and only on this. Thus it is insensitive to sunlight and can be used in daylight.
As i wrote in the first post remotes for TVs and VCRs also transmit a 38kHz carrier. And it's no fun if, in a game, someone shoots you with a remote instead of their gun that has run out of ammo.
So 38kHz just gets rid of ambient noise. This signal is in turn modulated at another fixed frequency, in this case 1800Hz. The receiver (ELIRM860x) decodes the demodulates the 38kHz signal, so if a proper gun is used, the uC will receive a 1800Hz signal.
The uC has to count no other signal the 1800Hz as a hit. For this I used the same timer that clocks the outgoing signal. I set it up to count a fixed amount of time and counted the incoming pulses during that time. For the counting I used the 8bit Timer0 with T0 (signal in here) as external clocksource.
I finally got it working, but I had to change the frequency because my IR-receiver couldn't detect the too short pulses that 1800Hz is.
It accepts frequencies between 625 and 1250Hz, but that still leaves a lot of room.
I realized that if every unit used a slightly different frequency it would after a game be possible to tell which ones that shot me and the others.
But because the same clock is used for input and output, each unit will have to have a different frequencytable, that is based the units frequency and calculated relative to the others. The unit running running at 1000Hz wouldn't, during the same amount of time, receive as many pulses from another unit as would the slower 800Hz unit.
All this calculations will be done in a computer program I'll write to setup the units and calculate scores and show results. The settings will be stored in EEPROM and be accessible via the UART/RS232.

Because almost everything is done in software my system will not need many external circuitry except IR-LED-driver and detectors. This makes it rather cheap and simple to build.
In it's present state the code handles shooting and being hit (Remote-proof!) . If anyone is interested in the code and project I can post it all on the forum and I'll be glad to receive comments on everything.

I have to give credit to Dave Bodger and his LasterTag info which can be found at http://www.cix.co.uk/~lasertag/lasertag.htm. I used some ideas but all the developing is mine and I think it's rather an improvement to fit all into a single chip .

Why send 1800 Hz square wave? Because you could send bits with the light pulses, maybe a protocol like 500µs of 38kHz burst and then if the bit to send is 0 you send 500µs space and if the bit is 1 you send 1000µs space. This is how remote controllers work, but of course they use their own bit protocols. Then there would be no need to understand different frequencies, and you can make up your own protocol for sending lots of information who shot who, where, how much damage and in what part of the body.

What I would do is to connect the receiver to an UART RX pin maybe, and receive whole bytes of information. They could be sent with the UART TX pin, but you would have to take the 38kHz modulation into account, so propably software uart that enables the output compare pin or disables it, and just program the timer to produce 38kHz square wave.

My 0.02 euros.

Using the UART was my first idea, but now it's used for data transfers to PC and the code is almost finished. Now I use Timer1 to generate the 38kHz carrier AND to time the pulses recieved.
Of course it's possible to rewrite the code so the UART is shared between the RS232-interface and the transmitter/reciever.

Is it hard to write a software UART? I don't need any fancy stuff, just simple protcols for sending and detecting a few different signals.

There is an Atmel apnote on software uarts. It ought to be on the Freaks website OR at Atmel.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net