Problems with ADC-modul!?

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Problems with ADC-modul!?

Post by CS » Thu Jun 19, 2008 9:20 am

Hi again,

I'm using an EasyPic4 with the PIC 18F4620 at 20MHz.

The problem with the ADC:

When I use the follwoing code I get values between 0 and 511:

Code: Select all


Device = 18F4620
Clock = 20

Include "usart.bas"
Include "convert.bas"
Include "adc.bas"

SetBaudrate(br19200)

Repeat

USART.Write("ADC-Value: ", DecToStr(ADC.Read(0)),13,10)

DelayMS(1000)

Until false
When I now change the Device to a PIC 18F452 (Of course I change the Line in the code also to Device = 18F452) I get values between 0 and 1023 like expected. Also changing to the PIC18F4680 (Pincompatible with the PIC18F4620) returns only values between 0 and 511.

Can anyone help, please?

Thanks

CS

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Jun 19, 2008 11:19 am

You probably need to take a look at the datasheet, there are quite a few values to play with. You could start by trying something like:

Code: Select all

SetBaudrate(br19200)
ADC.SetConvTime(FOSC_8)
Repeat 
   ...

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Thu Jun 19, 2008 12:47 pm

Hi David,

that's the trick! I have set the Conversion Time to FOSC/4 and now I get the expected values!

Thanks

CS

Post Reply