Record, storage and compare analog signals


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    25

    Default Record, storage and compare analog signals

    Hi, all, please I need help
    I need record analog signal (10Bit) to PIC with length 60us, storage as reference (red line) and compare with next one incoming (blue line). My question is, how to sampling and storage reference signal and compare those signals? I want to use PIC18F2455.
    Look Fig1Name:  fig1.jpg
Views: 706
Size:  8.4 KB
    Thanks Kuba

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Looking at the Data sheet of the chip 18F2455 and especially in the A/D Acquisition Requirements, it seems that you need a 2.45usec for every sample. Of course you need also a little time to transfer the AD value to an array and start AD again. Say for the sake of the discussion the the total time is 3usec.

    This leaves you with only 20 samples in the 60usec period.

    Is that OK with you?

    Ioannis

  3. #3
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    I think, 20 samples is enough.
    How can I obtain this 20 samples and storage as numbers for calculation?

    Thanks Kuba

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    The assumption of 2.45us was based on the fact that Vdd is 5Volts and the source impedance less than 2.5Kohm.

    What will be the clock of the your controller?

    Ioannis

  5. #5
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    I will use osc. 20MHz

    Kuba

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Lets then suppose you have the analog input at AN0.

    Code:
    ADCON0=%00000001    ' Channel 0, ADC on
    ADCON1=%00001110    ' AN0 as analog,rest as digital
    ADCON2=%10010101    ' Right justify result and Fosc/16
    
    analog_res_array    VAR WORD[40]
    counter             VAR BYTE
    start_array         VAR BYTE     ' first element of the array to store samples
    stop_array          VAR BYTE     ' last element of the array to store samples
    
    start_array=0:stop_array=19      ' first group of 20 samples
    gosub adc_routine
    start_array=20:stop_array=39     ' second group of 20 samples
    gosub adc_routine
    
    ......
    
    adc_routine:
        for counter=start_array to stop_array
            high adcon0.1
            while adcon0.1:wend
            analog_res_array[counter]=adresh*256+adresl
        next counter
    return
    Now in the array you have 40 samples (two groups of 20) and you can compare them.

    Note that code is untested, but you get the idea.

    Ioannis
    Last edited by Ioannis; - 22nd April 2014 at 17:58.

Similar Threads

  1. how to record sound into eeprom
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th November 2009, 21:16
  2. How to read analog signals?
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 8th March 2009, 05:00
  3. Using a PIC to record voice
    By weirdjim in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th December 2007, 20:21
  4. Replies: 6
    Last Post: - 20th August 2006, 22:00
  5. The best way to record non-volatile data
    By johnson in forum General
    Replies: 3
    Last Post: - 19th July 2004, 09:03

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