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!

    oh right thanks let me try it out!

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

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

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

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

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

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

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