pic18f452 ADC


Closed Thread
Results 1 to 4 of 4

Thread: pic18f452 ADC

  1. #1
    hamid_knight's Avatar
    hamid_knight Guest

    Default pic18f452 ADC

    I am writing a code in protonbasic 1.0.3.6 to read the analogue signal from AN0 and then send it to max232. Here is the code:

    Include "PROTON_G4.INT"
    Device = 18F452
    Dim sample As Word

    TRISA = %00000001
    ADCON0 = %11000001
    ADCON1 = %11001110

    again:
    sample = ADIn 0
    DelayMS 2
    HRSOut sample ;
    GoTo again

    Now i need to set sampling frequency to 500 Hz, I think i need to use a timer but dont know how to. Besides , i don't know what is the internal frequency of the pic that i am using, is it easier to use a crystal?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Hamid_Night ... all forums are grey , hey ???

    Did you notice, in the fog, it is PicBasicPro Forum, here???


    To answer your question ...

    How do you want to scan @ 500 Hz with a 2 millisec. pause, PLUS HSerout (?), PLUS sampling ADC Time, PLUS adc converting time, PLUS ... ???

    Ok, ... I stop joking

    use TMR0, 8 or 16 bits ... preload it to .... ??? ( 63 543 @ 4Mhz )

    Arrrggggh ... don't know YOUR clock freq !!!!


    a TMRO interrupt will occur every 2 ms ...

    just launch conversion, then ...

    Alain

    PS: what is proton ??? does proton even exist ??? Hope it is a free compiler - ROFL !
    Last edited by Acetronics2; - 24th November 2009 at 12:27.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Dec 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I'm using PIC to digitize/sample the audio signal, then send to another PIC and a D/A converter to get back the audio.
    Currently I'm testing with only a single PIC, sample and D/A. I've just tested with PIC16F88, I found that the quality of the D/Aed output is not that good at 2 kHz and above, around 10 kHz and above, aliasing happened.
    Then I found from Microchip site that the maximum sampling rate of 16F is only 30 ksps, while a few 18F PIC can be up to 200 ksps.
    As a first time user of 18F PIC, I write my first 18F program in MPLAB. There are so many configuration settings!! And the format of the configuration is different from 16F as well.
    The datasheet of the 18F PIC is really complicated, the opcode is also more :'(.

    Is there any solution for using 16F PIC? Or I should start using 18F?

    Thanks

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by colemancol View Post
    Hi,
    I'm using PIC to digitize/sample the audio signal, then send to another PIC and a D/A converter to get back the audio.
    Currently I'm testing with only a single PIC, sample and D/A. I've just tested with PIC16F88, I found that the quality of the D/Aed output is not that good at 2 kHz and above, around 10 kHz and above, aliasing happened.
    Then I found from Microchip site that the maximum sampling rate of 16F is only 30 ksps, while a few 18F PIC can be up to 200 ksps.
    As a first time user of 18F PIC, I write my first 18F program in MPLAB. There are so many configuration settings!! And the format of the configuration is different from 16F as well.
    The datasheet of the 18F PIC is really complicated, the opcode is also more :'(.

    Is there any solution for using 16F PIC? Or I should start using 18F?

    Thanks
    Hi colemancol,
    Take a sneaky look into your MPASM SUITE directory and find a zillion files named starting with the letter "P" the chip number and the suffix .inc, open the one you need and view ALL the config settings possible for that chip.
    HTH
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. 10 bit ADC display on LCD using 16f873
    By pr2don in forum mel PIC BASIC
    Replies: 3
    Last Post: - 6th March 2010, 18:29
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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