Struggling again with SEROUT2 and numbers format


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Struggling again with SEROUT2 and numbers format

    from the manual :-
    The resolution of PULSIN is dependent upon the oscillator frequency. If a 4MHz oscillator is used, the pulse width is returned in 10us increments. If a 20MHz oscillator is used, the pulse width will have a 2us resolution. Defining an OSC value has no effect on PULSIN. The resolution always changes with the actual oscillator speed.

    more info
    @16 MHz that's 2.5uS units
    8.5mS =3400 ,1.5mS =600
    Last edited by richard; - 11th April 2014 at 13:12.

  2. #2
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: Struggling again with SEROUT2 and numbers format

    Quote Originally Posted by richard View Post
    from the manual :-
    The resolution of PULSIN is dependent upon the oscillator frequency. If a 4MHz oscillator is used, the pulse width is returned in 10us increments. If a 20MHz oscillator is used, the pulse width will have a 2us resolution. Defining an OSC value has no effect on PULSIN. The resolution always changes with the actual oscillator speed.

    more info
    @16 MHz that's 2.5uS units
    8.5mS =3400 ,1.5mS =600
    Thank you both for your usefull comments.

    @ Richard,

    you are correct, I've done my self calculations and we are the same.
    The problem must be somewhere else or at PIC configuration (maybe ??)

    Since I don't have any other way to see what happens here, I'm simply printing on LCD the values I'm reading with the PULSIN command.
    My results are correct @4 MHz but wrong at 16 MHz.

    @4 MHz I get for "Start" pulse, "0" pulse and "1" pulse respectively : 898, 56, 168. These results are correct according to the NEC protocol (for ex. 898 * 10 us ~ 9 ms which is fine for the start pulse).

    But @ 16 MHz I get : 3600, 229, 129.

    The 3600 result is correct (~ 898 * 4),
    The 229 result is also correct (~ 56 * 4),
    BUT 128 is wrong and should be ~ 168 * 4 = 672 !!!

    So here is my problem, I can read @16 MHz the "Start" pulse and "0" pulse, but the "1" pulse is wrong, it's way LOWER value than it should be.

    What do you think about this ?

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Struggling again with SEROUT2 and numbers format

    does it really matter why not call it a "0" if < 180 or a "1" if > than 180
    what are you using for ir receiver , could it be noise or the "carrier wave" slipping through
    how good is your power supply ,is everything bypass capped properly ?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Struggling again with SEROUT2 and numbers format

    Hi,
    I'm not sure which is what here but I see only one WORD variable (Leader) being declared. If you expect PULSIN to return a value >255 then make sure to give it a WORD variable to store that result in.

    /Henrik.

Similar Threads

  1. Still Struggling with the formula!
    By Ramius in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 10th April 2012, 06:58
  2. Struggling Newbie
    By plakey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th March 2012, 14:05
  3. Struggling with a P18f2550
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th November 2011, 07:58
  4. Still Struggling with IF THEN
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 25th March 2007, 10:47

Members who have read this thread : 2

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