lasertag

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I'm trying to build my own lasertag game set.
My problem is to write the infra red transmitter and receiver program. I am new to µ processors, this is my first project.

Has anyone an example code to handle with IR communications in assembler code? Do i have to do the job with registers and timers, or do I need the to make use of the uart.
I am going tho use the 90S2313.

Who has some tips?

Greets, jerre

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to explain more about what it is you want to do. Is the 2313 going to run the guns electronics? If so you should use a protocol such as RC5, since there's way too much IR noise for simple on/off bursts.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 2313 is the central hearth. It is connected with the gun, (IR transmitter) and the IR receivers. By connecting both on the same processor, it is possible to disable automaticly the gun when you ran out of lives.
When everything works fine, i want a RS232 connection with the pc, so that i can write a program to load easily the game parameters in each player gun.

For the the IR-code, i found on the web the code of the miles:
http://lightbrain.8m.com/mtforma...
This is the one i want to implement.

My problem is to transmit and to detect this code.
For the transmitting, I need a carrier. Which will have to be modulated with the code.

So I am new to microcontrollers, this is my suggestion:
-the transmitting code is placed in a register
-I copy the lowest bit to a portb pin (which is connected to luminate the IR-led)
-I wait some cycles
-shift the register so the second bit is the lowest
-I copy the lowest bit to the portbpin
-and so on til the code is send

But how do I mix it with the carrier, to decrease power consumption?

For the receiver.
I want to work with interrupts, instead of polling.
The processor is in sleep mode.
On an interrupt, it wakes up and starts reading a portb pin, which is connected with the IR receiver. It counts the high pulses each period, (it counts the "1" carrier pulses). If they are more than a certain value, a "1" is dected, otherwise it was a 0. The bits are one by one written in a register.

Is this the method to work with IR signals? Or are there better solutions? (using the uart?)
My thoughts are perhaps somewhat simplistic, but I need to have a point to start from ;-)

Greetings, Jerre

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the Thread "Laser Challenge" some posts down this forum you can find some informations and discussions about Laser tags.

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jerre wrote:
Hello,
I'm trying to build my own lasertag game set.
My problem is to write the infra red transmitter and receiver program. I am new to µ processors, this is my first project.

Has anyone an example code to handle with IR communications in assembler code? Do i have to do the job with registers and timers, or do I need the to make use of the uart.
I am going tho use the 90S2313.

Who has some tips?

Greets, jerre

Hi frieand.
you have to know that this is an easy work, but no for someones first project.
you have to write about more words about your problems for the freaks understanding but I think that my words would be helpfull. So Listen.
There are so many circuits doing an infrared comunication. For doing this you need a MAX232 (full dublex CMOS-TTL) or a (DS275 half dublex (CMOS-TTL) an AT90S2313 (read the data sheets).
Using an Infrared circuit based on Phillips RC5 Protoccol you have to make a PWM 30 - 40 Khz Square wave for the transmitter. Read for example the data sheet of the TSOP1736 Infrared Receiver and you will understand what I mean.
Using energy from PC's Serial Port you have to make a small Duty Cycle (about 10%). Remember that TSOP17XX has an internall inverter that inverts the Received data and the better you can do is 2400 bps comunication. Using an IrDa Circuit you may have much better Baud Rates but no large distances.
The AVRs software is so easy just reading the sheets you can do it.

I know that these words are dificult to undertand but I'm sure that now you have the keys to unlock the infrareds door just reading about these things.

Icarus1

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, i started programming, and came to this first result. I want to send the code by the uart, and the carrier will be mixed with the code extern of the µ-processor.
Is this the way of solving the problem, or am I on the wrong way?

.include"2313def.inc"
.org 0x0000
rjmp	RESET
rjmp	EXT_INT0

.equ	fck			=	4000000		;kristalfreq in hz


.def	Rtemp		=	R16
.def	Rsendcode	=	R17


RESET:
ldi		Rtemp,ramend				;initialize stack pointer
out		SPL,Rtemp
ldi		Rsendcode,0b10101010		; code to send
ldi		Rtemp,103					;intitialize baud rate 2400 (0.2% errormargin)
out		ubrr,Rtemp			

sbi		ucr,TXEN					;transmit enable
sbi		ucr,TXB8					;select 8bits sending
ldi		Rtemp,0b11110010			;initialize port d
out		portd,Rtemp
ldi		Rtemp,0b11110010			;initialize port data transfer direction
out 	ddrd,Rtemp
sei
rjmp 	main

EXT_INT0:							;sendIRcode
;nog ontwaakpuls meegeven
out		udr,Rsendcode				;places code to send in the uart
reti

MAIN:
nop
rjmp main

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One way to mix the signal is to use timer compare match that toggles a pin (CTC). Then you just start/stop the timer according to your code to be sent.
-Extin

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

can I use the uart for the infra red signal, to transmit the bits and let timer 1 realize the carrier wave? On compare match toggle the TXD pin between output and high impedance?