Strange output from ADC


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    3

    Default Strange output from ADC

    I am trying to get the ADC module of the PIC16F870 to work. Unfortunately I am using somebody else's code as I have little experience with microcontrollers. The ADC works but seems to be susceptible to jumping from one "plateau" to another. At the bottom of this post I have included two images with examples of the voltage traces I'm getting when I input a sine wave or a triangle signal. I've also included the relevant code. Has anyone ever experienced this kind of thing? Please let me know if any more information is needed.

    Code:
    adcstart    clrf    temph        clrf    templ    
            clrf    store
            bcf    portc,3        ;ADC CLK low
            bcf    portc,4        ;ADC CS LOW
            bsf    portc,5        ;ADC DIN HIGH START
            bsf    portc,3        ;CLKH1
            bcf    portc,3        ;CLKL1
            bsf    portc,5        ;DIN LOW=DIFFERENTAL MODE/single=High    
            bsf    portc,3        ;CLKH2
            bcf    portc,3        ;CLKL2
            return        
    
    
    adcfinish    bcf    portc,5        ;ADC DIN low
            movlw    d'4'        ;CLK7-10
            movwf    adcclk2
    Code:
    ;PROGRAM STARTSmain        clrf    sendreg
            clrf    highmanh
            clrf    highmanl
            clrf    templ
            clrf    temph
            clrf    store
            bsf    portc,4        ;ADC CS high
            call    longdly        ;debounce        
            bcf    portb,7        ;led off
            call    longdly        ;debounce
    
    
    div5        bsf    portb,7        ;sample time
    spaced        movlw    0xf0        ;test data high
            movwf    store
            call    manconvert
            call    uart_out
            nop
            movlw    0xf0        ;test data high
            movwf    store
            call    manconvert
            call    uart_out
            nop
            call    adcstart
            call    cha
            call    adcfinish
            call    adcstart
            call    chb
            call    adcfinish
            call    adcstart
            call    chc
            call    adcfinish
            call    adcstart
            call    chd
            call    adcfinish
            call    adcstart
            call    che
            call    adcfinish
            bcf    portb,7
            goto    div5
            end
    Name:  1Hz-triangle.jpg
Views: 352
Size:  21.7 KBName:  low-amp-1Hz-sine.jpg
Views: 323
Size:  17.3 KB

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Strange output from ADC

    Well, this forum is for PicBasic. Although, there are few people here that might be able to help you with asembly. And, yes indeed that's a very strange output you are getting there.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  3. #3
    Join Date
    Jan 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Strange output from ADC

    What would be a better forum to post to?

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


    Did you find this post helpful? Yes | No

    Default Re: Strange output from ADC

    Vellamike, For starters this is not the input to a PIC but the input from some external A/D converter isn't it? Looking at the code, I can see that you are manipulating the starting of the conversion and receiving the result. Unless you are going to also include the circuit and, components you are using, there is no way of helping you....
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Jan 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Strange output from ADC

    Quote Originally Posted by Dave View Post
    Vellamike, For starters this is not the input to a PIC but the input from some external A/D converter isn't it? Looking at the code, I can see that you are manipulating the starting of the conversion and receiving the result. Unless you are going to also include the circuit and, components you are using, there is no way of helping you....
    The input is directly into the PIC which has it's own ADC module. What makes you think that I am getting the input from an external ADC?

    I will post the circuit diagram in a bit as I don't have it available to me at the moment.

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Strange output from ADC

    Quote Originally Posted by vellamike View Post
    What would be a better forum to post to?
    You can try here

    http://www.microchip.com/forums/f16.aspx
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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