[SOLVED !] 18F45k22 ADC Conversion Sampling Rate - Page 2


Closed Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35

Thread: 18F45k22 ADC Conversion Sampling Rate2617 days old

  1. #16
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by jom View Post
    ...what kind of limitations on sampling rate can you see on these 18f devices?
    The question is what are you doing between samples?
    If you are doing something simple like storing in an array and then stop sampling and process the data (filter, FFT, DFT, etc.), you can do up to Fs = 100KHz.
    The most I have done was 70KHz and in between samples I did most of the work for a couple of DFT bins. I did have to pause sampling for a couple of mS after taking all the points in the DFT in order to do the final calculations.
    If you are trying to be “continuous” (i.e., never miss a sample) then you are limited by your processing and the performances of the PIC so the sampling rate will be much lower (and better use a
    DSP).

Attention
×

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #17
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,388
    Thumbs Up
    Received: 79
    Given: 46
    Total Downloaded
    1.39 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by jom View Post
    Thanks Norm. You've used the term "unreal" data rate. What is it that you mean by that? Assuming you don't mean "really cool" or some other thing. lol

    jom
    Super fast.

    Norm

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #18
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    According to MAPS the fastest ADC rate you can get on a K22 is 100kSa/s. This would imply you are using the minimum sampling time at maximum clock speed and restart the conversion as soon as it is finished.

    ADC technology varies widely across different PIC ranges. On some you have to manually start and monitor conversions, others can use a special event trigger. On some you can trigger an interrupt on completion, on some it pushes successive results into a FIFO or DMA buffer automatically. If you want the fastest you can get with a PIC, you'll need a dsPIC. I designed a miniature oscilloscope front end (sampling and triggering) on a 33FJ16GS502 which managed 2MSa/s on two channels simultaneously and continuously. Of course you could use an external ADC also, but you are still limited by how fast you can process the data.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #19
    jom
    Guest jom's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quick question on the TIMER:

    The TIMER information in the datasheet is a bit dense and I can't find what I'm looking for. During the TIMER cycle the CCP5 sets off an ADC sample (GO DONE = 1) automatically. That makes sense however when/where is the TIMER data (TMR3H,L) reset to zero (or is it)? CCP5 compares against TMR3H and TMR3L...so shouldn't it reset to get the right count (to 400 in this case)? Where does this happen?

    jom

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #20
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by jom View Post
    Quick question on the TIMER:

    The TIMER information in the datasheet is a bit dense and I can't find what I'm looking for. During the TIMER cycle the CCP5 sets off an ADC sample (GO DONE = 1) automatically. That makes sense however when/where is the TIMER data (TMR3H,L) reset to zero (or is it)? CCP5 compares against TMR3H and TMR3L...so shouldn't it reset to get the right count (to 400 in this case)? Where does this happen?

    jom
    The datasheet spreads the info in too many places so it is hard to follow. Basically, the special event is “automatic” it takes care of the timer and the ADC. The code I posted runs on 18F46K22 and with small variation (using CCP2) on 18FXXK20 so you can add some simple processing and UI/LCD and check it out with some audio signals (if you are using the sampling rate in the example, stay below 2.5KHz!).

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #21
    jom
    Guest jom's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by barak View Post
    The datasheet spreads the info in too many places so it is hard to follow. Basically, the special event is “automatic” it takes care of the timer and the ADC. The code I posted runs on 18F46K22 and with small variation (using CCP2) on 18FXXK20 so you can add some simple processing and UI/LCD and check it out with some audio signals (if you are using the sampling rate in the example, stay below 2.5KHz!).
    Well, I'm actually using a 45K22 so I adjusted to CCP5 instead. I did finally find the info on the clearing of the bits once the compare matches....from a book on Basic for Mikro on a 16F device no less. Only THEN did on go back to the 45K22 datasheet and found it there. argh.

    I also need to kick up the sampling rate a bit and store to an array (or something) to ultimately run a FFT. I'm still working on the best (ie fastest) way to store while still getting a higher sampling rate....

    Thanks

    jom

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #22
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Do you need to sample continuously or is OK to collect samples for a period of time, then stop and process them, then start sampling again.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #23
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    The code sample will work for 18F45K22 and it is already using CCP5 and TMR3. Due to the settings of TMR3 the value you put in CCP5Reg should twice the sampling period (integer only).
    If you have a scope you can toggle a pin to check if you completed your processing in time for the next special event.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #24
    jom
    Guest jom's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by wastrix View Post
    Do you need to sample continuously or is OK to collect samples for a period of time, then stop and process them, then start sampling again.
    I need to run 256 samples (for 256 point fft), calculate FFT then send the data to the GLCD. Then sample 256 again...etc.

    Quote Originally Posted by barak View Post
    The code sample will work for 18F45K22 and it is already using CCP5 and TMR3. Due to the settings of TMR3 the value you put in CCP5Reg should twice the sampling period (integer only).
    If you have a scope you can toggle a pin to check if you completed your processing in time for the next special event.
    Actually, I don't think I quite know where you got the 5 kHz sampling from. I thought it was your Fosc/4 period times 400. That is 10 kHz if Fosc=16 MHz....but I'm probably missing something here. BTW, what do you mean by "integer only"?

    jom

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #25
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    I would just run the conversions in a loop and not worry about interrupts as it only adds complexity and you do not need to be processing while you are sampling. But either way you should get 100kSa/s. Start the conversion, copy the previous result to your array, start the next conversion, etc.

    The quickest way to copy to your array is to use indirect addressing. If you don't know already, you can read about it in the datasheet. Basically load an FSR register (lfsr) with the first address of your array, then copy the AD result register to a POSTINC register. This will automatically write the data to your array at the address in FSR, then increment the address.
    Last edited by wastrix; 3rd December 2012 at 03:55.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #26
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by jom View Post
    ...Actually, I don't think I quite know where you got the 5 kHz sampling from. I thought it was your Fosc/4 period times 400. That is 10 kHz if Fosc=16 MHz....but I'm probably missing something here. BTW, what do you mean by "integer only"?
    Fosc is 64MHz, Instruction clock (Fosc/4) is 16MHz, TMR3 prescale is 1:8 so a tic is 500 nSec (1/16*8=0.5 uS)
    Therefore, the value in CCP5Reg should be twice the required sampling period in microseconds.

    With that said, , the sampling rate in the example I posted is actually 20KHz (sampling period is 50uS) because when I “extracted” the code from the application, I took TMR3 value from the wrong place where it directly uses Fosc as source (64MHz). To make it 5KHz (200uS) TMR3 should be set to use the Instruction clock which is Fosc/4. So please change:
    T3CON = 110010 'timer 3 Instruction clock and prescale 1:8

    "integer only" I ment that your sampling rate accuracy is limited to an integer value in CCP5Reg which in thes case represents muliples of 500 nanseconds
    Last edited by barak; 3rd December 2012 at 23:12.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #27
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Quote Originally Posted by wastrix View Post
    ...The quickest way to copy to your array is to use indirect addressing. If you don't know already, you can read about it in the datasheet. Basically load an FSR register (lfsr) with the first address of your array, then copy the AD result register to a POSTINC register. This will automatically write the data to your array at the address in FSR, then increment the address.
    Hi William, Would you mind posting a short code example demonstrating indirect addressing? Thanks, Barak

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #28
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Code:
    Dim FSR1 As FSR1L.Word
    
    Dim i As Byte
    Dim MyBuffer[256] As Byte At 150            ' MyBuffer crosses a bank boundary
    
    ' Set pointer initially
    FSR1 = VarPtr(MyBuffer)                     ' Could also be done with lfsr mnemonic
    
    For i = 0 To 255                            ' Could be ADC reading loop, or could be placed in ADC interrupt, etc.
        POSTINC1 = i
        ' i.e. POSTINC1 = ADRESH
    Next
    
    Stop
    
    ' MyBuffer is now filled. Each write operation took two instruction cycles (movff) and no indexing or banking was required.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #29
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    724
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    Thanks William,
    Sorry to hack the thread but I think this is probably of interest to others.
    Can you please elaborate more on the use of:
    Dim MyBuffer[256] As Byte At 150 ' MyBuffer crosses a bank boundary ???

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #30
    jom
    Guest jom's Avatar

    0 Not allowed!

    Default Re: 18F45k22 ADC Conversion Sampling Rate

    With that said, , the sampling rate in the example I posted is actually 20KHz (sampling period is 50uS) because when I “extracted” the code from the application, I took TMR3 value from the wrong place where it directly uses Fosc as source (64MHz). To make it 5KHz (200uS) TMR3 should be set to use the Instruction clock which is Fosc/4. So please change:
    T3CON = 110010 'timer 3 Instruction clock and prescale 1:8
    I can't find it at the moment but I thought I found a note in the datasheet that says you should not use Fosc as a source but rather Fosc/4. I don't know why but section 12.11 from the datasheet DS41412F, page 168....maybe I'm reading it wrong. Obviously, I rather use Fosc...it might have something to do with Acquisition time....

    On the T3CON register:

    T3CON = 110010 ' For Fosc/4
    T3CON = 110010 ' For Fosc

    jom

    PS: Go ahead and hack away at the thread!
    Last edited by jom; 4th December 2012 at 03:03.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. LTC2508-32 - 32-Bit Over-Sampling ADC with Configurable Digital Filter
      By normnet in forum New devices and techniques
      Replies: 0
      Last Post: 14th November 2016, 02:46
    2. LTC2348-18 low power 8-Channel 18-Bit Simultaneous Sampling ADC
      By normnet in forum New devices and techniques
      Replies: 0
      Last Post: 7th July 2015, 13:32
    3. ADC conversion clock error
      By cgriffin in forum Labcenter Proteus VSM
      Replies: 1
      Last Post: 16th May 2008, 08:15
    4. Simultaneous ADC Conversion
      By Stephen Moss in forum Proton Plus Compiler v3
      Replies: 22
      Last Post: 2nd May 2008, 22:20
    5. ADC conversion speed
      By [email protected] in forum Proton Plus Compiler v3
      Replies: 6
      Last Post: 20th December 2007, 14:32

    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