Timer0 Reload based on ADC result


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With 36 samples per cycle (of your 50Hz sine wave) this sounds about right.

    The app continuously adjusts PWM duty cycle to create the sine waves, so
    1.8kHz/36 (samples per cycle)=50Hz.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Jan 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    All right. Thank you very much.

  3. #3
    Join Date
    Jan 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Hi again,

    I changed my sine entries to 72 samples from 0 to 350 in steps of 5. According to calculations above, TMR0 interrupt is generated every 141us (88*1.6us) so for 142 samples the frequency is 50 Hz (1/0.02 s). However, I am getting at the output 40 Hz sine wave! What I am doing wrong ? I used 72 samples instead of 142 also as it is one complete sine wave but I still get 40 Hz!

    In the first post, the sine table had 19 entries from 270 - 90 in steps 10 and I was getting 50 Hz sine wave.

    I am simulating my program on Proteus 7.5.

    Thanks

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    What do you get with a timer reload value of 65,362?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jan 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    I get 37.5 Hz

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Is your ADC=200?

    How many entries do you have in the new table?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Jan 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    My ADC value is 200 (50 Hz) and my new table has 72 entries from 0 to 350 in steps of 5.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 03:18
  2. Strugling without floating point
    By pjsmith in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th March 2011, 07:29
  3. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 22:22
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 16:54
  5. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 15:21

Members who have read this thread : 1

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