Plz help in completing RC-5 IR remote lamp dimmer project


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22

    Talking Plz help in completing RC-5 IR remote lamp dimmer project

    Hi All,

    I am JUST AN HOBBYIST and trying to make lamp dimmer(AC220V/50hz) using RC5 IR . I have made Zero crossing. I have taken o/p from full wave rectfier and given it to transistor . When I use count command with 1sec time base I get 100 count on lcd.

    When I test IR decoding programm(originally not mine,modifed code from picbasic.nl) I get proper result on LCD. I am using RB0 port for generating Interrupt from ZC.

    I am trying to pass value from IR code to ISR for getting the dimming effect. for example when I press CH UP button then delay = delay+500 ( delay is Word) . Then using Pauseus command to generate necessay dimming.

    I request you all to have a look at code.

    I HAVE FOLLOWING PROBLEMS.

    1. I cant get IR and Interrupt woking together I cant pass value from IR code to RB ISR

    2. When entire code is put together, IR DECODE STOPS working and only ISR IS WORKING.

    3. How to configure Interrupt so that everything will work.

    4. I think using long PAUSEUS 8000 may lead to lose data from IR, Is there any other trick.


    '==================CODE IS BELOW ==============================


    @ device pic16F72 ' its very cheaply available
    @ DEVICE HS_OSC
    define osc 20
    DEFINE LCD_DREG PORTC'LCD data port
    DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 3 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 2 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'READ/WRITE SELECT PORT
    DEFINE LCD_RWBIT 1 'READ/WRITE SELECT BIT
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    lcdout $fe,1,"LCD OK"
    PAUSE 500
    'INCLUDE "modedefs.bas" ' not used
    ALL_DIGITAL
    ADCON1 = 7 'disable A/d work digital

    'INTERRUPT FROM ZC ON PORTB.0
    INTCON =%10010000' interrupt on portb.0

    on interrupt goto firefan
    BeginingCycle var PORTB.0
    fan var portb.5

    ;Normal aliases (constants)
    Glitch con 52 ;Max 255: Reduction glitches
    SYMBOL LED_Time = 500 ;mSec: Error LED's burning time
    Ok con 50 ;Max 255: Controltime of the RC5 code is received ok

    ;Port aliases
    IR_Receiver var PORTA.4 ;TSOP1736
    ByName var PORTA.0 ;When low the IR-code is given else (unconnected) the System-name and Command-name

    ; ' 76543210
    TRISA = %11110000
    DELAY VAR WORD
    Command VAR BYTE
    CommandOld VAR BYTE
    Systeem VAR BYTE
    SysteemOld VAR BYTE
    BD1 VAR BYTE ;Byte Dummy
    ;BIT
    ByNameOld VAR BIT ;When switching between code- and text-mode'and sending 'the same RC5 code then should the LCD not been updated
    ToggBit VAR BIT
    Value VAR BIT
    ' ID1 VAR BIT ;bIt Dummy
    CLEAR
    low portb.4 ' not used
    low portb.7 ' not used
    ;Subroutines
    BitOphalen:
    Value = IR_Receiver ;Make value 0 or 1 dependent from received IR-code
    BD1 = 0
    WHILE IR_Receiver = Value AND BD1 < Ok;Level must change within time 'Ok'
    BD1 =bd1+1
    WEND

    IF Ok = BD1 THEN ErrorReceive ;No level-change whitin the 'Ok' time
    pauseUS 1100 ;950 - 1600
    RETURN


    ;Mainprogram
    Start:

    ByNameOld = ByName

    BD1 = 0
    WHILE IR_Receiver = 1
    WEND ;Wait until a IR-signal is received

    WHILE IR_Receiver = 0
    if BD1 < Glitch then BD1 =bd1+1 'Glitch val 52
    WEND

    IF BD1 < Glitch THEN GOTO ErrorGlitch

    CommandOld = Command ;Save old values for repair in case of a error
    SysteemOld = Systeem

    pauseUS 500 ;200 - 825; Avoid RC5 header

    GOSUB BitOphalen
    Command.6 = Value ^ 1 ;Extended bit

    GOSUB BitOphalen
    ToggBit = Value

    GOSUB BitOphalen
    Systeem.4 = Value

    GOSUB BitOphalen
    Systeem.3 = Value

    GOSUB BitOphalen
    Systeem.2 = Value

    GOSUB BitOphalen
    Systeem.1 = Value

    GOSUB BitOphalen
    Systeem.0 = Value

    GOSUB BitOphalen
    Command.5 = Value

    GOSUB BitOphalen
    Command.4 = Value

    GOSUB BitOphalen
    Command.3 = Value

    GOSUB BitOphalen
    Command.2 = Value

    GOSUB BitOphalen
    Command.1 = Value

    GOSUB BitOphalen
    Command.0 = Value

    if command= 32 then 'CH UP
    high portb.4
    pause 10
    delay = delay+500' STEP OF 500
    IF delay >8500 then delay = 8500' upper limit
    endif

    if command =33 then ' CH DW
    high portb.7
    pause 10
    delay = delay-500
    if delay < 500 then delay =0 ' lower limit
    endif

    lcdout $fe,1
    lcdout $fe,$80,"Sys:", DEC Systeem
    lcdout $fe,$c0,"Com:", DEC Command , "del:",dec delay

    goto start

    ErrorGlitch:
    'Receive error (No RC5 code or glitch)
    'pause LED_Time
    GOTO Start

    ErrorReceive:
    'No RC5 code or no optimal receiving
    'pause LED_Time
    Command = CommandOld ;Repair Command and Systeem
    Systeem = SysteemOld
    GOTO Start

    ' ISR
    firefan:
    disable

    while BeginingCycle=1 'CHK RB0=1
    wend
    Pauseus delay 'delay value rcvd from IR decode
    high fan

    While BeginingCycle=0 'CHK RB0 =0
    Wend
    low fan
    '76543210
    INTCON=%10010000 'enable portb.0 interrupt
    resume
    enable

    '================================================= ==============

    Thank you very much for ur precious time.

    Please help in completing project.

    Mahesh-VU2IIA
    www.vu2iia.blogspot.com

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    in your isr you will need to change the INTCON line. you don't want to re-enable the interrupt anyway. PIC will do it for you. What you need to do.. is to clear the interrupt flag

    INTCON.1=0
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    2 things I noticed:
    DEFINE OSC 20 ( must be ALL CAPS )

    Put disable in firefan before firefan label, not after firefan label.

  4. #4
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22


    Did you find this post helpful? Yes | No

    Smile

    Thank you friends , I will try ur suggestion and bother you again. To be honest I have just copy pasted code from two different programs by doing some changes, hence I belive I am not able to get it working.

    Thanks
    VU2IIA
    Mahesh

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52

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