PDA

View Full Version : pic18f452 ADC



hamid_knight
- 24th November 2009, 11:37
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?

Acetronics2
- 24th November 2009, 12:24
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 !

colemancol
- 15th December 2009, 12:59
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

Archangel
- 15th December 2009, 16:42
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