• 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.

Lazer Tag– concept

    Blog entry posted in 'Electronics and Other Ramblings...', May 29, 2012.

    Looking for some cool stuff to add playtime with the kids, we found the Phoenix LTX Lazer Tag from Hasbro.
    70231

    The system consists of two guns which use infra-red (IR) to “communicate” with each other. There are two modes of operation:
    1. Free Play (everybody against everybody else)
    2. Team Play (team 1 vs. team 2)

    The system is based on IR transmitter and receiver integrated into the same gun. The IR transmitter/receiver uses 38kHz modulation and simple pulse width modulation for communications. The system operates very well both inside and outside the house. But after a while we wanted to add more guns and/or targets. Of course the first step to do this is to figure out the actual operation. A quick search of the web says that the units use 38kHz IR transmitters and receivers. Using the already built IR receive module shown in “Basic IR Communications” and the Saleae Logic, the LTX systems were decoded with ease. Typical transmissions are as follows.
    • If Free Play is selected
    70232

    • If Team Play – Team1 is selected
    70233

    • If Team Play – Team2 is selected
    70234

    For the initial trial, we used the already built IR receive and transmit modules form “Basic IR Communications” to simulate the LTX Lazer Tag system. We got really good results and range with the transmitter and the LTX system as a receiver, and easy decoding with the receiver and the LTX system as a transmitter; even though the receive and transmit modules were used at 40kHz; instead of the 38kHz the LTX system uses.

    Next step; use the 38kHz modulation for both transmit and receive; and modify a NERF gun to use it.

    Oshonsoft code used for transmitter checkout:

    Code:
    '* PIC12F683 * Phoenix LTX Lazer Tag *'
    'Title: Lazer Tag Transmitter
    'Description: Uses MCU to decode Lazer Tag information from Phoenix LTX
    'Author: languer (©2012)
    'Pin Allocation:
    'PIN# Main_Fn Secondary_Fn
    'GP0 -> RS232_OUT ICSP-DAT
    'GP1 -> TAG_OUT ICSP-CLK
    'GP2 -> PWM_OUT
    'GP3 -> MCLR
    'GP4 -> TAG_IN
    'GP5 -> TEAM_IN

    'Usage Information:
    'RS232 Baud Rate: 9600bps
    'Version Info: v1
    '-> internal clock @ 8MHz
    '-> RS232 output
    '-> IR transmitter output decoding

    'General Configuration
    Define CONF_WORD = 0x33c4 'for internal 8MHz osc

    'Oscillator/Clock Configuration for internal 8MHz osc
    Define CLOCK_FREQUENCY = 8
    OSCCON = 0x71

    'Debug Option
    Dim debug As Bit
    debug = True
    debug = False

    'Variable Declarations
    '>>I/O
    Symbol rs232_out = GP0 'rs232 output
    Symbol tag_out = GP1 'tag led output
    Symbol pwm_out = GP2 'pwm output
    Symbol tag_in = GP4 'tag/trigger input
    Symbol team_in = GP5 'team select input

    '>>Constants
    Const _trisio = %11111000

    '>>Variables
    Dim _true As Bit
    Dim _false As Bit
    _true = True
    _false = False

    Dim data As Word
    Dim decoded_data As Byte
    Dim cnt As Byte
    Dim flag_start As Bit

    'Main Program
    main:
    If debug = _false Then
    WaitMs 2500
    Endif

    Call init()

    While _true
    If tag_in = 0 Then
    Select Case team_in
    Case 0
    Call pwm_enable()
    Call team1_tag()
    Call pwm_disable()
    If debug = _false Then
    WaitMs 200 'debounce
    Endif
    'wait until tag button is released
    While tag_in = 0
    Wend
    Case 1
    Call pwm_enable()
    Call team2_tag()
    Call pwm_disable()
    If debug = _false Then
    WaitMs 200 'debounce
    Endif
    'wait until tag button is released
    While tag_in = 0
    Wend
    EndSelect
    Endif
    Wend
    End

    Proc init()
    AllDigital
    TRISIO = _trisio

    'pwm settings
    '>>>pwm period to 40kHz
    PR2 = 49
    '>>>pwm duty cycle to 50%
    CCPR1L = 25 'using 8-bit mode (for 10-bit mode, 100 would be written to CCPR1L:CCP1CON<5:4>)
    '>>>pwm tmr2 prescaler 1:1 (for 40kHz)
    T2CON.T2CKPS1 = 0
    T2CON.T2CKPS0 = 0
    '>>>pwm tmr2 enable
    T2CON.TMR2ON = 1
    '>>>pwm enable
    CCP1CON.CCP1M3 = 1
    CCP1CON.CCP1M2 = 1
    CCP1CON.CCP1M1 = 0
    CCP1CON.CCP1M0 = 0

    Low pwm_out
    Low tag_out

    If debug = _false Then
    Serout rs232_out, 9600, "Phoenix LTX Lazer Tag Transmitter", CrLf
    Endif

    End Proc

    Proc pwm_enable()
    '>>>pwm enable
    CCP1CON.CCP1M3 = 1
    CCP1CON.CCP1M2 = 1
    CCP1CON.CCP1M1 = 0
    CCP1CON.CCP1M0 = 0
    End Proc

    Proc pwm_disable()
    '>>>pwm disable
    CCP1CON.CCP1M3 = 0
    CCP1CON.CCP1M2 = 0
    CCP1CON.CCP1M1 = 0
    CCP1CON.CCP1M0 = 0
    End Proc

    Proc team2_tag()
    'preamble
    Low tag_out
    WaitMs 6
    High tag_out
    WaitMs 3
    'bit7 (1)
    Low tag_out
    WaitMs 6
    High tag_out
    WaitMs 3
    'bit6 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit5 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit4 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit3 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit2 (1)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 2
    'bit1 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit0 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'finish
    Low tag_out
    Serout rs232_out, 9600, "team2", CrLf
    End Proc

    Proc team1_tag()
    'preamble
    Low tag_out
    WaitMs 6
    High tag_out
    WaitMs 3
    'bit7 (1)
    Low tag_out
    WaitMs 6
    High tag_out
    WaitMs 3
    'bit6 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit5 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit4 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit3 (1)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 2
    'bit2 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit1 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'bit0 (0)
    Low tag_out
    WaitMs 2
    High tag_out
    WaitMs 1
    'finish
    Low tag_out
    Serout rs232_out, 9600, "team1", CrLf
    End Proc


    Code used for receiver checkout:
    Code:
    '* PIC12F683 * Phoenix LTX Lazer Tag *'
    'Title: Lazer Tag Receiver
    'Description: Uses MCU to decode Lazer Tag information from Phoenix LTX
    'Author: languer (©2012)
    'Pin Allocation:
    'PIN# Main_Fn Secondary_Fn
    'GP0 -> RS232_OUT ICSP-DAT
    'GP1 -> ALLPLAY_OUT ICSP-CLK
    'GP2 -> TAG_IN
    'GP3 -> MCLR
    'GP4 -> TEAM1_OUT
    'GP5 -> TEAM2_OUT

    'Usage Information:
    'RS232 Baud Rate: 9600bps
    'Version Info: v1
    '-> internal clock @ 8MHz
    '-> RS232 output
    '-> IR receiver input decoding

    'General Configuration
    Define CONF_WORD = 0x33c4 'for internal 8MHz osc

    'Oscillator/Clock Configuration for internal 8MHz osc
    Define CLOCK_FREQUENCY = 8
    OSCCON = 0x71

    'Debug Option
    Dim debug As Bit
    debug = True
    debug = False

    'Variable Declarations
    '>>I/O
    Symbol rs232_out = GP0 'rs232 output
    Symbol tag_in = GP2 'ir receiver input
    Symbol allplay_out = GP1 'team1 tag led out
    Symbol team1_out = GP4 'team1 tag led out
    Symbol team2_out = GP5 'team1 tag led out

    '>>Constants
    Const _trisio = %11001100

    '>>Variables
    Dim _true As Bit
    Dim _false As Bit
    _true = True
    _false = False

    Dim data As Word
    Dim decoded_data As Byte
    Dim cnt As Byte
    Dim flag_start As Bit

    'Main Program
    main:
    If debug = _false Then
    WaitMs 2500
    Endif

    Call init()

    While _true
    data = func_pulsein()
    If data > 500 Then
    If flag_start = False Then
    If data > 2500 Then
    flag_start = True
    decoded_data = 0
    cnt = 0
    Endif
    Else
    If data > 1500 Then
    decoded_data = ShiftLeft(decoded_data, 1)
    decoded_data = decoded_data + 1
    Else
    decoded_data = ShiftLeft(decoded_data, 1)
    Endif
    If cnt = 7 Then
    flag_start = False
    Select Case decoded_data
    Case %10000000
    High allplay_out
    Serout rs232_out, 9600, "all play", CrLf
    Low allplay_out
    Case %10000100
    High team1_out
    Serout rs232_out, 9600, "team1", CrLf
    Low team1_out
    Case %10001000
    High team2_out
    Serout rs232_out, 9600, "team2", CrLf
    Low team2_out
    Case Else
    High allplay_out
    High team1_out
    High team2_out
    Serout rs232_out, 9600, "team1", CrLf
    Low allplay_out
    Low team1_out
    Low team2_out
    EndSelect
    Else
    cnt = cnt + 1
    Endif
    Endif
    Else
    flag_start = False
    Endif
    Wend
    End

    Proc init()
    AllDigital
    TRISIO = _trisio
    'set TMR0 to tick every 32us (~30)
    OPTION.PSA = 0 'assign prescaler to TMR0
    'set TMR0 prescaler to 1:64
    OPTION.PS2 = 1
    OPTION.PS1 = 0
    OPTION.PS0 = 1
    OPTION.T0CS = 0
    flag_start = 0
    Low allplay_out
    Low team1_out
    Low team2_out
    If debug = _false Then
    Serout rs232_out, 9600, "Phoenix LTX Lazer Tag Receiver", CrLf
    Endif
    End Proc

    Function func_pulsein() As Word
    Dim temp_byte As Byte
    While Not tag_in
    'wait for rising edge
    Wend
    TMR0 = 0
    INTCON.T0IF = 0
    While tag_in
    'wait for falling edge
    Wend
    temp_byte = TMR0
    If INTCON.T0IF = True Then
    func_pulsein = 0
    Else
    func_pulsein = temp_byte * 30
    Endif
    End Function

    Comments
 

EE World Online Articles

Loading

 
Top