Pulsin to pulsout with up than 4MHZ crystal ?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Unhappy Pulsin to pulsout with up than 4MHZ crystal ?

    Hello members.
    I'll try to explain my problem in a comprehensive english but don't blame me if my language is not perfect, English is not native for me.

    Well, i just wanna do that :

    Pulsin a value on a pin and pulsout this value on another pin.
    it's okay with a 4Mhz crystal but not with another one :O(

    Here is my code :
    -=-=-=-=-=-=-=-=-=-=-=-=-=
    @ device PIC16F871, HS_osc, wdt_off, pwrt_off, protect_off, bod_on, lvp_off, cpd_off, wrt_off, debug_off

    ADCON1 = 7 'Need this to turn off ADC

    DEFINE NO_CLRWDT 1 'Do not auto insert watchdog timer
    Define OSC 20 'Not important to define in this case but i want
    Clear

    TRISA = %11111111 'Pins A are in input mode
    TRISC = %00000000 'Pins C are in Output mode
    PORTC = %00000000 'Clear Port C

    Init:
    PULSIN PORTA.2,1,ValInPulse 'Measure the pulse who vary from 1ms to 2ms
    PULSOUT PORTC.5, ValInPulse 'Output the pulse
    GOTO Init 'Do it always
    -=-=-=-=-=-=-=-=-=-=-=-=-=

    And now, here is is what i don't understand :
    I know Pulsin and pulsout depend from the crystal, so, if the pulsin have a 5 times higher resolution with à 20MHZ crystal, it's the same for the pulsout (?) I think i don't have to multiply or divide the pulsin value before i output it via PORTC.5...

    May be someone could explain ?

    Thanx.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    RCtech , Yes you are correct. The commands resolution depends on the oscillator used. So you must multiply or divide the variable accordingly.

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink Pulsin and Pulsout Mysteries

    Hi, RCTech

    Assuming DEFINE OSC doesn't interfere with osc speed for pulsin and pulsout, result won't be the same @ 4Mhz and @ 20 MHz. ratio will be 5 , as you tell.
    The Valinpulse value will be the same for Pulsin and Pulsout.

    Now, as RC is in your pseudo ... RC pulses values are ~ 80 to 220 @ 4Mhz and 400 to 1100 @ 20 Mhz ... okay, but...

    @ 4Mhz, you write: Valinpulse var BYTE ....and @ 20 Mhz you MUST write : Valinpulse var WORD !!!

    and I didn't see that in your code ...

    Also take care, if you ever use DEFINE PULSIN_MAX to allow for the full signal ( 0 AND 1 state duration = full period )

    Now, a little Trick seen nowhere :

    Always Write : LOW PORTX.Y before a Pulsout statement ... many ununderstandable bugs come from here !!! ( explanation is in High capacitive loads behaviour of PICs ... and the Pulsout way of work )

    Alain
    30 years of R/C ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Acetronics
    Hi, RCTech

    .../...The Valinpulse value will be the same for Pulsin and Pulsout.
    Okay, i'm not totally wrong ;O)

    Quote Originally Posted by Acetronics
    @ 4Mhz, you write: Valinpulse var BYTE ....and @ 20 Mhz you MUST write : Valinpulse var WORD !!!
    Whow, i didn't know that little difference !

    Quote Originally Posted by Acetronics
    .../...
    Now, a little Trick seen nowhere :
    Always Write : LOW PORTX.Y before a Pulsout statement .../...
    Thanx, i'm just a little bit more intelligent than yesterday, many many thanx.
    Now it's half past 3 AM : too late for me to do the tests but tomorrow probably, i'll post a feedback.

    And.... Nice to see i'm not the only one froggy here !

    Dave, i've tested with multiplying etc (just in case), but, today i'm sure it was a mistake because pulsin & pulsout have the same res. depending the X-tal used so if pulsin have a 5 times ratio at 20Mhz, then, the pulsout too and i don't need to do some corrections by calcs.

    I'll come back on the forum tomorrow or next day to tell if it's okay.

    RCTech

  5. #5
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18


    Did you find this post helpful? Yes | No

    Thumbs up It's Okay !

    Back to confirm everything is okay, this stupid ''BYTEs'' are changed for ''WORDs'' now !

    Thanx for your help.

  6. #6
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    If you don't mind me asking what is your application for this?

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 03:17
  2. pulsout pulsin on same pin - timing?
    By vacpress in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th January 2009, 08:21
  3. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 11:17
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 21:10
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 04:46

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