how to generate two signals from two ports at the same time by using p16f84


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    the program i posted in that thread uses 1 timer. That timer is used to generate a time base to drive 4 software counters. these counters become my timers.
    -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!

  2. #2
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    hi cncmachineguy

    yes i recognized it but pic16f84 drived by max 10 mhz and we need so precision time period , max +-2 micro second precision, when we use instructions like if ,else we have problem.

    when we are asked to generate two signals 630 micro seconds and 453 micro second by porta.0 and porta.1, for example, 633 micro seconds is not acceptable.

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    well how about you post what you have so far, and maybe we can help you to get it done. Did you teacher have any suggestions how he thinks you will do it? I am sure there are several ways to get it done, but you must understand how and why it works. We will help you, but we won't do it for you (not saying you asked us to). So show us what you have and we can go from there.
    -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!

  4. #4
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    yes i have an advisor teacher but he does not say anything about how i can do it. i guess he just wonder how i find a solution for this project.

    i have started usual basic loop without using tmr0, and for a signal it works well but generating second one with different frequencies causes timing problem. i also tried to implement assembler codes in order to have more time space however it did not help me.

    at least i want to find a method so as to generate these signals having pulse witdh x8 ( 8,16,..320 mic. sec ). in this program i am trying to use basic timing by using tmr0 and interrupt. i guess i need a 8 micro seconds time period which constant?

    thanks a lot


    define OSC 10
    timer0 var word
    timer1 var word

    A0 VAR PORTA.0
    A1 VAR PORTA.1


    on interrupt goto int_timer

    OPTION_REG=%00000000
    TMR0=255
    INTCON=%10100000

    TRISA=0
    LOW PORTA

    timer1=0
    timer0=0


    enable
    main:

    goto main

    disable
    int_timer:

    timer0=timer0+1
    if timer0=>3 then ' 3 is a random number
    timer0=0
    toggle a0
    else
    endif

    timer1=timer1+1
    if timer1=>10 then ' 10 is a random number
    timer1=0
    toggle a1
    else
    endif


    INTCON.2=0
    TMR0 = 255
    resume

    end

  5. #5
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    i have tried to obtain accurate time by changing tmr0 and prescaler, but still no answer

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


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    You have a lot of stuff in the ISR. Take the IF_THEN_ELSE out of the ISR.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jul 2011
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to generate two signals from two ports at the same time by using p16f84

    yes, i have tried it also, i put them in main loop but i could not obtain time accuracy.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts