Remote control with frequencies


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    14

    Default Remote control with frequencies

    Hello
    I'm sory my english language is not good.

    I built a circuit with pic16f628 and clock=4 mhz and:

    _CP_OFF
    _DATA_CP_OFF
    _LVP_OFF
    _BODEN_OFF
    _MCLRE_OFF
    _PWRTE_ON
    _WDT_OFF
    _XT_OSC

    the circuit saves two signals in eeprom and then compares the received signal with the saved signal (+/- 10).
    the first output opens when the received signal is corresponding to the saved signal,and the second do the same thing .
    I have two inputs: the first RB6 is the signal input, and the second RB5 is the programming switch.
    and the outputs are : RA1 and RA2.
    in the first of code I read the eeprom.

    I have the following problems:

    1- the project is very slow, and it takes about 3 seconds to read the signal.
    2- I want to make toggle outputs (in the first press on , the second off , the third on ,... and so on .but in my project the output opens for one second then closes and I failed to keep it open until the second press.
    3- when I reboot the circuit it didn't work (don,t read eeprom or don't save ?).

    this is my full code in mikrobasic:

    Code:

    program FC_TMR1_2

    dim freq,freqL,freqH,data as word

    dim freq1 as word absolute 0x30
    dim freq1L as byte absolute 0x30
    dim freq1H as byte absolute 0x31

    dim freq2 as word absolute 0x32
    dim freq2L as byte absolute 0x32
    dim freq2H as byte absolute 0x33


    dim T1 as word absolute 14
    dim i,j,tmp as byte

    sub procedure led1on
    porta.1=1
    end sub

    sub procedure led2on
    porta.2=1
    end sub

    sub procedure led1off
    porta.1=0
    end sub

    sub procedure led2off
    porta.2=0
    end sub

    sub procedure led1onoff
    'porta=porta xor %00000010 'I use these manners but didn't work well
    porta.1=not(porta.1)
    end sub

    sub procedure led2onoff
    'porta=porta xor %00000100
    porta.2=not(porta.2)
    end sub

    main:
    porta=0
    portb=0

    trisa=%00000000
    trisb=%01100000
    OPTION_REG=%01010101
    cmcon=0x07
    intcon=0


    'read eeprom
    j=0
    gosub read_code
    freq1L=tmp

    j=1
    gosub read_code
    freq1H=tmp

    j=2
    gosub read_code
    freq2L=tmp

    j=3
    gosub read_code
    freq2H=tmp

    porta=$ff
    portb=$ff
    delay_ms(1000)
    porta=0
    portb=0

    check_code:
    freq=0

    tmr1h=0
    tmr1l=0
    t1con=7
    delay_ms(985)
    t1con=0
    freq = T1

    freqL=freq-10
    freqH=freq+10

    CHECK1:
    if freq1>=freqL then
    if freq1<=freqH then
    led1onoff
    delay_ms(1000)
    else
    goto CHECK2
    end if
    else
    goto CHECK2
    end if

    CHECK2:
    if freq2>=freqL then
    if freq2<=freqH then
    led2onoff
    delay_ms(1000)
    else
    goto prog_check
    end if
    else
    goto prog_check
    end if


    prog_check:
    if portb.5=1 then
    delay_ms(2000)
    goto enter_prog_mode
    else
    led1off
    led2off
    goto check_code
    end if

    enter_prog_mode:
    led1on
    led2on
    delay_ms(1000)
    led1off
    led2off
    delay_ms(1000)
    led1on
    led2on
    enter2:
    if portb.5=1 then
    goto enter2
    end if
    led1off
    led2off
    Delay_ms(500)
    led1on
    led2on

    prog_loop:
    gosub count
    freq1=freq
    data=freq
    i=0
    gosub write_code
    led1off
    delay_ms(1000)
    led1on

    delay_ms(1000)
    gosub count
    freq2=freq
    data=freq
    i=2
    gosub write_code
    led2off
    delay_ms(1000)
    led2on
    delay_ms(1000)
    led1off
    led2off

    goto check_code

    '************************************************* ****************
    '************************************************* ****************
    write_code:
    eeprom_write(i,data)
    return

    read_code:
    tmp=EEprom_read(j)
    return


    count:
    if portb.6=1 then
    delay_ms(100)
    goto count2
    else
    goto count
    end if

    count2:
    freq=0
    tmr1h=0
    tmr1l=0
    t1con=7
    delay_ms(985)
    t1con=0
    freq = T1
    return

    end.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Exclamation

    Hi, Tohu

    The right address for your post is :

    http://www.mikroe.com/forum/viewforu...c16ffd7f9c548f

    Here it is PicBasicPro forum ... some help available, but about MKBasic its a bit trickier for us ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Aug 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Thank you Alian

    Thank you Alain
    I send my problem to mikroe, many days ago, but no one answer me.

Similar Threads

  1. Newbie remote control question?
    By Clodoaldo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th July 2009, 17:20
  2. Remote Control World !
    By iugmoh in forum General
    Replies: 4
    Last Post: - 22nd April 2008, 23:03
  3. IR Remote Control Issues
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 28th August 2007, 14:12
  4. No one-way approach to learning ir remote control frequencies
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd June 2007, 13:26
  5. Remote control
    By Radiance in forum General
    Replies: 2
    Last Post: - 6th August 2003, 15:13

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts