pulsin again!anyone plz help!


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    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]

  2. #2
    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.

  3. #3
    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 .

  4. #4
    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.

  5. #5
    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....

  6. #6
    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.

  7. #7
    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!

Members who have read this thread : 0

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