Pulsin ir receiver and osc speeds


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    33

    Default Pulsin ir receiver and osc speeds

    Hello with my pic running at 4 mhz this works. At 16 mhz it doesn't. It is due to the pulsin resolution but I can't work out what I need to change in order to get it working. Can someone explain it to my rather meagre brain?

    Thanks

    DEFINE PULSIN_MAX 1140 '>1140 RETURNS 0


    IR VAR byte[4]
    pulse VAR word
    i VAR byte
    stx VAR word 'start of transmission

    init: IR[0]=0:IR[1]=0:IR[2]=0:IR[3]=0:i=0
    PulsIn PORTA.4, 0, stx
    If (stx<760) Then init

    While PORTB.4=1:Wend 'wait space
    Repeat
    PulsIn PORTA.4, 1, pulse
    If (pulse>100) Then
    IR.0(i)=1 'set bit
    EndIf
    i=i+1

    Until (i>31)
    serout portA.5,6,[#IR[0],10,13,#IR[1],10,13,#IR[2],10,13,#IR[3],10,13]

    GoTo init

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


    Did you find this post helpful? Yes | No

    Default Re: Pulsin ir receiver and osc speeds

    This may be a stupid question bur are you changing the OSC define to.
    DEFINE OSC 16
    when you change resonators or crystals
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2009
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Pulsin ir receiver and osc speeds

    Yes. it's actually an internal osc but I understand the pulsin command doesn't care anyway.

  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 ir receiver and osc speeds

    Correct, PULSIN works with the actual speed the MCU is running at. Are you sure the internal is setup properly... confirmed the MCU is running at the desired speed?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2009
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Pulsin ir receiver and osc speeds

    I am pretty sure it is. (I tested it with a blink led set to pause 2000 and it was a 2 second gap...well two Mississippis by my count. I spent a while trying to figure out the OSCCON) My understanding of it is that because the pulsein is "narrower" than when the osc is running at 4mhz the timings for reading IR signals is different.so "if stx<760" actually should be a different value. I am trying to understand the maths of what that value should be.
    p.s. I know there is a typo in the code portb.4 is incorrect and I have corrected it in my actual code.

  6. #6
    Join Date
    Nov 2008
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Pulsin ir receiver and osc speeds

    ok i'm sure youve checked this but have you checked the ports Analog input is turned off.


    ANSELA = 0
    ANSELB = 0
    ANSELC = 0 ' Config A2d All OFF

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