pulsin again!anyone plz help!


Closed Thread
Results 1 to 36 of 36
  1. #1
    Join Date
    Mar 2011
    Posts
    30

    Default pulsin again!anyone plz help!

    here is my code:


    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 5/23/2011 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    @ DEVICE pic16F877a, WDT_OFF ' Watchdog Timer
    @ DEVICE pic16F877a, PWRT_OFF ' Power-On Timer
    @ DEVICE pic16F877a, BOD_OFF ' Brown-Out Detect
    @ DEVICE pic16F877a, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877a, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877a, HS_OSC
    Define OSC 20
    Header var word
    Body var word
    i var byte
    tmp var Byte
    irButton var byte
    irDevice var byte
    irIN var PortB.2
    SonyLED var PortB.5

    'TrisA = %00000100
    TrisB = %00000100
    Start:
    LOW SONYLED
    IRBUTTON=255: IRDEVICE=255

    Pulsin irin,0,header
    if header > 1000 or header < 1350 then goto Start

    for i =0 to 11
    pulsin irin,0,tmp
    if tmp >= 480 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111 'Mask 7 bit
    IRDEVICE = (Body >>7) & %00011111 'Mask 5 bit
    If IRDEVICE=255 then goto start

    if IRBUTTON >=0 and IRBUTTON < 255 then
    high Sonyled
    pause 300
    low Sonyled
    endif
    pause 100
    goto start



    plz can anyone find any problem with it.im using 20MHZ oscillator and pic16f877a and pic basic pro!!! plz plz can any one point out the probelm in this.it is not showing any output on portb.5...

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    What value will header need to have to NOT return to Start?
    Code:
    if header > 1000 or header < 1350 then goto Start
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    1200!!!!
    as im using 20mhz crystal which has a resolution of 2microseconds.
    and the sony header is of 2400milliseconds so you get 1200 milliseconds...

  4. #4
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    sorry its a 2400 microsecond header so divide by 2 microsecond get 1200!!!!

  5. #5
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    oh yes the header should be
    header<1000
    n header >1350

    but i have tried wid this..
    its still not working.....

  6. #6
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    -Turn off the Analog to Digital converter
    -Comparators Off
    -Set a maximum count for Pulsin: DEFINE PULSIN_MAX 1350

  7. #7
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    sir i dont think that there would be any point of turning adc off.because i am using portb for input and it is not an analog port in pic 16f877a.in this pic only porta is the analog one!!!

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Hello,
    I have to ask what exactly is your circuit doing or not doing? Does it do anything ?
    Does it flash the LED ? This question next is not designed to offend you . . . Have you checked all of your connections for errors and continuity? Breadboard errors trip me up regularly as do poor connections caused by internal corrosion in the breadboards. You buy one, and unbeknownst to you, it sat on the dealer's shelf for ten years . . . and all the contacts are corroded. I have disassembled some that were really scuzzy.
    One more thing, I think portB inputs default to weak pull ups on, turn them off in the option register.
    EDIT: Nope default off. Easy to check with a hi impedance voltmeter though.

    Last question: are you measuring a high pulse or a low pulse? State 0, indicates a low pulse, is that correct?
    Last edited by Archangel; - 26th May 2011 at 07:16.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    thanku archangel sir for replying.

    now the basic purpose of my project is to turn a relay on or off using sirc(sony protocol).

    for this i need to decode just two keysne for on and one for off.or maybe just one key that if a user presses a button 5v appear on output pin and if it presses the same button then it turns off!!this is one point...

    the next point is that the above code is working for
    Code:
    if IRBUTTON >=0 and IRBUTTON < 255 then
     
     
    but not working for 
    if irbutton=16 then high sony led '16 is for channel up

    it is not working for this the above command
    this is the second point...


    and the third point is that i dont understand this
    One more thing, I think portB inputs default to weak pull ups on, turn them off in the option register.
    EDIT: Nope default off. Easy to check with a hi impedance voltmeter though... cant understand this
    Last edited by Archangel; - 27th May 2011 at 00:56. Reason: code tags [code] your code [/code]

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    OK, RE: I Dont understand . . .
    Just a small argument with myself . . .
    Let me explain my thought process, If the weak pullups were turned on, then applying voltage to that pin might go unnoticed by the MCU because voltage is already present . . .
    Let me ask you this, can you output the value of pulsin to an LCD display or to your computer to find out its value, or flash an LED the number stored therein ?
    That might give you some insight as to what is going on.
    EDIT:
    but not working for
    if irbutton=16 then high sony led '16 is for channel up

    NOT IN POSTED CODE ! Maybe it never gets there, please post
    your code, use code tags as shown in the edit explanation at
    the bottom of your edited last post
    Last edited by Archangel; - 27th May 2011 at 01:28. Reason: add
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  11. #11
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Code:
    'include "ALLDIGITAL.pbp"
    @ DEVICE pic16F877a, WDT_OFF ' Watchdog Timer
    @ DEVICE pic16F877a, PWRT_OFF ' Power-On Timer
    @ DEVICE pic16F877a, BOD_OFF ' Brown-Out Detect
     
    @ DEVICE pic16F877a, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877a, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877a, HS_OSC 
     
    Define OSC 20 
     
    Header var word
    Body var word
    i var byte
    tmp var Byte
    irButton var byte
    irDevice var byte 
     
    irIN var PortB.2 
    SonyLED var PortB.5 
     
     
    'TrisA = %00000100 
    TrisB = %00000100 
     
    Start:
    LOW SONYLED 
    IRBUTTON=255: IRDEVICE=255
     
     
    Pulsin irin,0,header 
    if header < 1000 or header > 1350 then goto Start
     
     
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 480 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
     
    IRBUTTON = Body & %01111111 'Mask 7 bit 
    IRDEVICE = (Body >>7) & %00011111 'Mask 5 bit 
     
    If IRDEVICE=255 then goto start
     
     
    if IRBUTTON >=0 and IRBUTTON < 255 then
    high Sonyled
    pause 300
    low Sonyled
    endif
     
    pause 100
    goto start



    the above code works....
    but it is for all infrared buttons on the remote.i only want one button to do on/off of relay.if i replace this
    Code:
     
    if IRBUTTON >=0 and IRBUTTON < 255 then
    by this

    Code:
     
    if IRBUTTON =16 then 'for channel up

    it is not working .

  12. #12
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Might be a good idea to display the value of .IRBUTTON on a terminal or LCD to see what is going on.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    sir how can i output the value of a button?? im using a sony tv remote...
    so i guess no way to output the value....

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


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Dave meant the value of the IRBUTTON variable.

    When developing software, sometimes you want to monitor what's happening INSIDE the PIC. Like Variables, Register, etc. The debatable lazy way is to use Simulator, but it doesn't solve any real life problem. So what many here do, is to send/display variables value on a LCD... or send it serially to your PC using Hyperterminal, MicroCode Studio Serial Communicator OR else so called "Terminal". If you have a PICKIT 2, you can use the built-in terminal utility.

    To me, when you do PIC stuff, you should have at least the following tools:
    1) Serial adapter To send/receive data to/from your PC AND/OR LCD (serial or Parallel)
    2) Logic Analyzer
    3) Scope

    For IR stuff, using a logic analyzer to record the incoming data make the whole thing a real piece of cake. You could also record the data with your PC soundcard with any decent Wav/Audio editor (SoundForge, Audacity, etc). Once you know what kind of signal comes in (or to be expected), it's easier to create/debug your code.

    HTH
    Last edited by mister_e; - 30th May 2011 at 06:49.
    Steve

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

  15. #15
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    oh right thanks let me try it out!

  16. #16
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    ok i have another question.my code is working the below one.
    as i am very new to pic basic pro i just have one more question and i know that it is a piece of cake for u guys. ok in my code the sensor is on portb.2
    and i am showing the output on portb.5.ok
    the portb.5 is being turned high infinitly when it detects an incoming signal.i want to turn it back low (infinetly)when it detects the signal again and again back high when detects the signal again. can it be done???
    maybe using an ISR?can anyone guide me or help me out???


    Code:
     
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/23/2011                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'include "ALLDIGITAL.pbp"
    @ DEVICE pic16F877a, WDT_OFF  ' Watchdog Timer
    @ DEVICE pic16F877a, PWRT_OFF  ' Power-On Timer
    @ DEVICE pic16F877a, BOD_OFF  ' Brown-Out Detect
    @ DEVICE pic16F877a, LVP_OFF  ' Low-Voltage Programming
    @ DEVICE pic16F877a, CPD_OFF  ' Data Memory Code Protect
    @ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877a, HS_OSC  
    Define OSC 20 
    cmcon=2
    Header var word
    Body var word
    i var byte
    tmp var Byte
    irButton var byte
    irDevice var byte 
    irIN var PortB.2 
    SonyLED var PortB.5 
     
    'TrisA = %00000100 
    TrisB = %00000100 
    Start:
    LOW SONYLED 
    IRBUTTON=255: IRDEVICE=255
     
    Pulsin irin,0,header 
    if header < 1000 or header > 1350 then goto Start
     
    check: 
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 500 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111
    if IRBUTTON <=9 then
    loop:
    high Sonyled
    goto loop
     
    endif
    pause 100
    goto start

  17. #17
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    You could use the INT INT on RB0, I think if you used RBC interrupts the other B pins would interfere, but RB0 has a seperate INT INT interrupt which would be unaffected, but yes and I would use Darrel's instant interrupts
    Code:
    INCLUDE "DT_INTS-14.bas"
    
    ASM
    INT_LIST  macro   ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,    _YourINTHandler,   ASM,  no
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    
    
    YourINTHandler:
    put your code here . . . 
    @  INT_RETURN
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  18. #18
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    No need for interrupts here. First thing to know, outputs will stay in the state you make them until something makes them change. So no need for this:
    Code:
    loop:
    High sonyled
    Goto loop
    all you need is
    High sonyled. That will keep the led on forever if nothing tells it to turn off. Further in your code, you have trapped the program to never leave the loop.

    Next, if you want to "toggle" the led everytime you get the valid pulse, use
    Toggle sonyled instead of high sonyled.

    Hth.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  19. #19
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    @ cncmachineguy
    sir it doesnt work because
    the led is high only when IRbutton is detected.... i want to keep it on forever ntil the next command without pressing the button...... is there any way?? maybe a function etc...???

    @archangel
    sir its difficult for me to understand it..the interrupt portion maybe if u could elaborate a little...
    or could point me out to an exmaple program....

  20. #20
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    sir it doesnt work because
    the led is high only when IRbutton is detected....
    Lets see you non working code based on Bert's advice.
    Dave
    Always wear safety glasses while programming.

  21. #21
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    here you go:


    Code:
     
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/23/2011                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'include "ALLDIGITAL.pbp"
    @ DEVICE pic16F877a, WDT_OFF  ' Watchdog Timer
    @ DEVICE pic16F877a, PWRT_OFF  ' Power-On Timer
    @ DEVICE pic16F877a, BOD_OFF  ' Brown-Out Detect
    @ DEVICE pic16F877a, LVP_OFF  ' Low-Voltage Programming
    @ DEVICE pic16F877a, CPD_OFF  ' Data Memory Code Protect
    @ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877a, HS_OSC  
    Define OSC 20 
    cmcon=2
    Header var word
    Body var word
    i var byte
    tmp var Byte
    irButton var byte
    irDevice var byte 
    irIN var PortB.2 
    SonyLED var PortB.5 
    'TrisA = %00000100 
    TrisB = %00000100 
    Start:
    LOW SONYLED 
    IRBUTTON=255: IRDEVICE=255
     
    Pulsin irin,0,header 
    if header < 1000 or header > 1350 then goto Start
     
    check: 
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 500 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111
    if IRBUTTON <=9 then
    loop:
    toggle Sonyled       '<----------------------change!
     
    endif
    pause 100
    goto start

  22. #22
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Irbutton will never be less then 9 because you and it with 127. So your if will always be false.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  23. #23
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    so u r saying that i should and it with 65???
    BTW it works with less than 9....

  24. #24
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    I'm sorry, I am completely wrong. Need more coffee. I was thinking OR.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  25. #25
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    np.you had me thinking there for a moment
    but my problem is the same just a pulse spike of 5 volts on button press i want to keep it permantently off or on when io press the button only once...

  26. #26
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Quote Originally Posted by engineer7 View Post
    ...but my problem is the same just a pulse spike of 5 volts on button press...
    I'm not very familiar with AND/OR and masks yet, but I wouldn't be surprised if your program did just what you told it to do.

    IF TMP>=500 says to turn on during pulse and then off as soon as pulse stops.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  27. #27
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    if tmp >= 500 then
    Will never be as tmp is BYTE size
    Dave
    Always wear safety glasses while programming.

  28. #28
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Every iteration of your loop turns the led off right after start. There's you problem.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  29. #29
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    thanks for reply everyone..
    @demon and mackaraket guys the above code is working there is nth wrong with it.i just want to add an additional functionality of on/off...

    @cncmachineguy i didnt understand your reply can u elaborate a little.... plz
    Last edited by engineer7; - 5th June 2011 at 13:05.

  30. #30
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Code:
    Start:
    LOW SONYLED <-------------------------Here you turn off the LED
    IRBUTTON=255: IRDEVICE=255
     
    Pulsin irin,0,header 
    if header < 1000 or header > 1350 then goto Start
     
    check: 
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 500 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111
    if IRBUTTON <=9 then
    loop:              
    toggle Sonyled '<----------------------change! 
     
    endif
    pause 100
    goto start  <--------sends program back to the beginning, this will turn off the LED
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  31. #31
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Quote Originally Posted by mackrackit View Post
    if tmp >= 500 then
    Will never be as tmp is BYTE size
    Very good, a byte can count from 0 to 255.

    That could give unpredictable results (except for the gurus that can most likely figure exactly how it will go screwy ); it may work, it may not.

  32. #32
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    @ Demon, I do not at all to be a guru who could figure out how it will go screwy, I am fairly certain IRBUTTON is ALWAYS = 0 after his for loop. Since there is NO way to cram a number bigger then %11111111,$FF,255 in a byte, it will always do the else setting all 11 bits to zero.

    So I would certainly question the OP's statement that it works, I think it prolly does in fact receive the signal, and detect the header. but I think from there it will fail as soon as it is tested for specific button presses.

    We shall wait and see
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  33. #33
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    without to check your code i think you should consider the frames (codes) of the ir Sony protocol... because Sony remotes all appear to repeat each frame a minimum of 3 times...and also i think you toggle the led by pressing too long time the button on the remote ..... add some some long pause for test

  34. #34
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    @cncmachineguy thanx a lot for pointing me the problem.i ve been a fool n i admit... the toggle function works fine... thanx v much again your approach has been dead on...g8 advice for beginners!!
    @demon u r right as well.the code is working for all the buttons of my remote(unexpected results)... not for just button <9 .problem wid temp most probably... i'll declare it a WORD n c how it goes...!

    @bogden thanks for your input as well. i have put a delay of 100...

  35. #35
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    my final code it is toggling on button 6 of your sony remote.n the good thing is no interrupts or timers simple code


    Code:
     
    @ DEVICE pic16F877a, WDT_OFF  ' Watchdog Timer
    @ DEVICE pic16F877a, PWRT_OFF  ' Power-On Timer
    @ DEVICE pic16F877a, BOD_OFF  ' Brown-Out Detect
    @ DEVICE pic16F877a, LVP_OFF  ' Low-Voltage Programming
    @ DEVICE pic16F877a, CPD_OFF  ' Data Memory Code Protect
    @ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877a, HS_OSC  
     
    Define OSC 20 
    cmcon=2
    Header var word
    Body var word
    i var byte
    tmp var word
    irButton var byte
    irDevice var byte 
    irIN var PortB.2 
     
    SonyLED var PortB.5 
     
    TrisB = %00000100 
    Start:
    'LOW SONYLED 
    IRBUTTON=255: IRDEVICE=255
     
    Pulsin irin,0,header 
    if header < 1000 or header > 1350 then goto Start
     
    check: 
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 500 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111
     
    if IRBUTTON=5  then
    loop:
    toggle Sonyled
     
    endif
    pause 100
    goto start

    copy/paste n njoy love PBP!!!!

  36. #36
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: pulsin again!anyone plz help!

    Insignificant, but I would change this:

    Code:
    if IRBUTTON=5  then
    loop:
    toggle Sonyled
     
    endif

    To this:

    Code:
    if IRBUTTON=5  then toggle Sonyled

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